Exemple #1
0
 def test_write_auth_checks_rw_users_field(self):
     user = User('test1', 'sdfsdf', 'sdfsdf')
     user2 = User('test2', 'sdfsdf', 'sdfsdf')
     doc = Doc('docid', 'title', ['test1'], [], None, None, None, False)
     with app.test_request_context("/"):
         BokehServerTransaction(user, doc, 'rw')
     with app.test_request_context("/"):
         self.assertRaises(AuthenticationException, BokehServerTransaction,
                           user2, doc, 'rw')
Exemple #2
0
 def test_read_auth_checks_both_fields(self):
     user2 = User('test2', 'sdfsdf', 'sdfsdf')
     user = User('test1', 'sdfsdf', 'sdfsdf')
     doc = Doc('docid', 'title', ['test1'], ['test2'], None,
               None, None, False)
     with app.test_request_context("/"):
         BokehServerTransaction(user, doc, 'r')
     with app.test_request_context("/"):
         BokehServerTransaction(user2, doc, 'r')
Exemple #3
0
 def test_read_auth_checks_both_fields(self):
     user2 = User('test2', 'sdfsdf', 'sdfsdf')
     user = User('test1', 'sdfsdf', 'sdfsdf')
     doc = Doc('docid', 'title', ['test1'], ['test2'], None, None, None,
               False)
     with app.test_request_context("/"):
         BokehServerTransaction(user, doc, 'r')
     with app.test_request_context("/"):
         BokehServerTransaction(user2, doc, 'r')
Exemple #4
0
 def test_write_auth_checks_rw_users_field(self):
     user = User('test1', 'sdfsdf', 'sdfsdf')
     user2 = User('test2', 'sdfsdf', 'sdfsdf')
     doc = Doc('docid', 'title', ['test1'], [], None,
               None, None, False)
     with app.test_request_context("/"):
         BokehServerTransaction(user, doc, 'rw')
     with app.test_request_context("/"):
         self.assertRaises(AuthenticationException, BokehServerTransaction,
                           user2, doc, 'rw')
Exemple #5
0
 def test_transaction_with_anonymous_user(self):
     self.server_docobj.published = True
     with app.test_request_context("/"):
         self.assertRaises(AuthenticationException, BokehServerTransaction,
                           None, self.server_docobj, 'rw')
     with app.test_request_context("/"):
         doc = BokehServerTransaction(None,
                                      self.server_docobj,
                                      'rw',
                                      temporary_docid='temp')
         assert doc
Exemple #6
0
 def test_transaction_with_anonymous_user(self):
     self.server_docobj.published = True
     with app.test_request_context("/"):
         self.assertRaises(
             AuthenticationException,
             BokehServerTransaction,
             None, self.server_docobj, 'rw'
         )
     with app.test_request_context("/"):
         doc = BokehServerTransaction(None, self.server_docobj, 'rw',
                                      temporary_docid='temp')
         assert doc
Exemple #7
0
 def test_permissions_with_temporary_docid(self):
     user = User('test1', 'sdfsdf', 'sdfsdf')
     doc = Doc('docid', 'title', [], ['test2'], None,
               None, None, False)
     # with temporary docid, a user must be able to read in order to get write access
     # this call should fail
     with app.test_request_context("/"):
         self.assertRaises(AuthenticationException, BokehServerTransaction,
                           user, doc, 'rw', temporary_docid="foobar")
Exemple #8
0
    def test_writing_in_cow_context_persists(self):
        with app.test_request_context("/"):
            t = self.transaction('test1')
            t.load()
            t.clientdoc.add(Plot(title='plot2'))
            t.save()

            t = self.transaction('test1')
            t.load()
            assert len(t.clientdoc.context.children) == 2
            assert t.clientdoc.context.children[1].title == 'plot2'
Exemple #9
0
    def test_writing_in_cow_context_persists(self):
        with app.test_request_context("/"):
            t = self.transaction('test1')
            t.load()
            t.clientdoc.add(Plot(title='plot2'))
            t.save()

            t = self.transaction('test1')
            t.load()
            assert len(t.clientdoc.context.children) == 2
            assert t.clientdoc.context.children[1].title == 'plot2'
Exemple #10
0
 def test_permissions_with_temporary_docid(self):
     user = User('test1', 'sdfsdf', 'sdfsdf')
     doc = Doc('docid', 'title', [], ['test2'], None, None, None, False)
     # with temporary docid, a user must be able to read in order to get write access
     # this call should fail
     with app.test_request_context("/"):
         self.assertRaises(AuthenticationException,
                           BokehServerTransaction,
                           user,
                           doc,
                           'rw',
                           temporary_docid="foobar")
Exemple #11
0
    def test_writing_in_cow_context_does_not_modify_original(self):
        with app.test_request_context("/"):
            t = self.transaction('test1')
            t.load()
            t.clientdoc.add(Plot(title='plot2'))
            t.save()

            t = self.transaction('test1')
            t.load()
            assert len(t.clientdoc.context.children) == 2

            t = self.transaction(None)
            t.load()
            assert len(t.clientdoc.context.children) == 1
Exemple #12
0
    def test_writing_in_cow_context_does_not_modify_original(self):
        with app.test_request_context("/"):
            t = self.transaction('test1')
            t.load()
            t.clientdoc.add(Plot(title='plot2'))
            t.save()

            t = self.transaction('test1')
            t.load()
            assert len(t.clientdoc.context.children) == 2

            t = self.transaction(None)
            t.load()
            assert len(t.clientdoc.context.children) == 1
Exemple #13
0
 def test_base_object_exists_in_cow_context(self):
     with app.test_request_context("/"):
         t = self.transaction('test1')
         t.load()
         assert t.clientdoc.context.children[0].title == 'plot1'
Exemple #14
0
 def test_cannot_save_to_read_only_context(self):
     with app.test_request_context("/"):
         t = self.transaction(None, mode='r')
         t.load()
         t.clientdoc.add(Plot(title='plot2'))
         self.assertRaises(AuthenticationException, t.save)
Exemple #15
0
 def test_cannot_gc_read_only_context(self):
     with app.test_request_context("/"):
         t = self.transaction(None, mode='r')
         self.assertRaises(AuthenticationException, t.load, gc=True)
Exemple #16
0
 def test_cannot_save_to_read_only_context(self):
     with app.test_request_context("/"):
         t = self.transaction(None, mode='r')
         t.load()
         t.clientdoc.add(Plot(title='plot2'))
         self.assertRaises(AuthenticationException, t.save)
Exemple #17
0
 def test_cannot_gc_read_only_context(self):
     with app.test_request_context("/"):
         t = self.transaction(None, mode='r')
         self.assertRaises(AuthenticationException, t.load, gc=True)
Exemple #18
0
 def test_base_object_exists_in_cow_context(self):
     with app.test_request_context("/"):
         t = self.transaction('test1')
         t.load()
         assert t.clientdoc.context.children[0].title == 'plot1'