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