Beispiel #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')
Beispiel #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')
Beispiel #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')
Beispiel #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')
Beispiel #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
Beispiel #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
Beispiel #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")
Beispiel #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'
Beispiel #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'
Beispiel #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")
Beispiel #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
Beispiel #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
Beispiel #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'
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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'