def test_reset_owner_to_none(self, events, extra_principals, root): from kotti.resources import Content from kotti.views.users import user_delete request = DummyRequest() root["content_1"] = Content() root["content_1"].owner = "bob" assert root["content_1"].owner == "bob" request.params["name"] = "bob" request.params["delete"] = "delete" user_delete(root, request) assert root["content_1"].owner is None
def test_reset_owner_to_none(self, events, extra_principals, root): from kotti.resources import Content from kotti.views.users import user_delete request = DummyRequest() root['content_1'] = Content() root['content_1'].owner = 'bob' assert root['content_1'].owner == 'bob' request.params['name'] = 'bob' request.params['delete'] = 'delete' user_delete(root, request) assert root['content_1'].owner is None
def test_reset_owner_to_none(self, events, extra_principals, root): from kotti.resources import Content from kotti.views.users import user_delete request = DummyRequest() root[u'content_1'] = Content() root[u'content_1'].owner = u'bob' assert root[u'content_1'].owner == u'bob' request.params['name'] = u'bob' request.params['delete'] = u'delete' user_delete(root, request) assert root[u'content_1'].owner is None
def test_deleted_group_removed_in_usergroups(self, events, extra_principals, root): from kotti.security import get_principals from kotti.views.users import user_delete request = DummyRequest() bob = get_principals()[u'bob'] bob.groups = [u'group:bobsgroup'] assert bob.groups == [u'group:bobsgroup'] request.params['name'] = u'group:bobsgroup' request.params['delete'] = u'delete' user_delete(root, request) with pytest.raises(KeyError): get_principals()[u'group:bobsgroup'] assert bob.groups == []
def test_deleted_group_removed_from_localgroups(self, events, extra_principals, root): from kotti.security import set_groups from kotti.resources import LocalGroup from kotti.views.users import user_delete request = DummyRequest() set_groups(u'group:bobsgroup', root, ['role:admin']) local_group = LocalGroup.query.first() assert local_group.principal_name == u'group:bobsgroup' assert local_group.node == root request.params['name'] = u'group:bobsgroup' request.params['delete'] = u'delete' user_delete(root, request) assert LocalGroup.query.first() == None
def test_deleted_group_removed_from_localgroups(self, events, extra_principals, root): from kotti.security import set_groups from kotti.resources import LocalGroup from kotti.views.users import user_delete request = DummyRequest() set_groups("group:bobsgroup", root, ["role:admin"]) local_group = LocalGroup.query.first() assert local_group.principal_name == "group:bobsgroup" assert local_group.node == root request.params["name"] = "group:bobsgroup" request.params["delete"] = "delete" user_delete(root, request) assert LocalGroup.query.first() is None
def test_deleted_group_removed_from_localgroups(self, events, extra_principals, root): from kotti.security import set_groups from kotti.resources import LocalGroup from kotti.views.users import user_delete request = DummyRequest() set_groups('group:bobsgroup', root, ['role:admin']) local_group = LocalGroup.query.first() assert local_group.principal_name == 'group:bobsgroup' assert local_group.node == root request.params['name'] = 'group:bobsgroup' request.params['delete'] = 'delete' user_delete(root, request) assert LocalGroup.query.first() is None
def test_deleted_group_removed_from_localgroups( self, events, extra_principals, root ): from kotti.security import set_groups from kotti.resources import LocalGroup from kotti.views.users import user_delete request = DummyRequest() set_groups("group:bobsgroup", root, ["role:admin"]) local_group = LocalGroup.query.first() assert local_group.principal_name == "group:bobsgroup" assert local_group.node == root request.params["name"] = "group:bobsgroup" request.params["delete"] = "delete" user_delete(root, request) assert LocalGroup.query.first() is None
def test_user_delete(self, events, extra_principals, root): from kotti.security import get_principals from kotti.views.users import user_delete request = DummyRequest() bob = get_principals()["bob"] request.params["name"] = "" user_delete(root, request) assert request.session.pop_flash("error") == ["No name was given."] assert "bob" in get_principals().keys() request.params["name"] = "bob" result = user_delete(root, request) assert "api" in result api = result["api"] assert api.principal == bob assert api.principal_type == "User" assert "bob" in get_principals().keys() request.params["name"] = "john" request.params["delete"] = "delete" user_delete(root, request) assert request.session.pop_flash("error") == ["User was not found."] assert "bob" in get_principals().keys() request.params["name"] = "bob" request.params["delete"] = "delete" user_delete(root, request) with pytest.raises(KeyError): # noinspection PyStatementEffect get_principals()["bob"]
def test_user_delete(self): from kotti.resources import get_root from kotti.security import get_principals from kotti.tests.test_node_views import TestNodeShare from kotti.views.users import user_delete root = get_root() request = DummyRequest() TestNodeShare.add_some_principals() bob = get_principals()[u'bob'] request.params['name'] = u'' user_delete(root, request) assert request.session.pop_flash('error') == [u'No name given.'] assert u'bob' in get_principals().keys() request.params['name'] = u'bob' result = user_delete(root, request) assert u'api' in result api = result[u'api'] assert api.principal == bob assert api.principal_type == u'User' assert u'bob' in get_principals().keys() request.params['name'] = u'john' request.params['delete'] = u'delete' user_delete(root, request) assert request.session.pop_flash('error') == [u"User not found."] assert u'bob' in get_principals().keys() request.params['name'] = u'bob' request.params['delete'] = u'delete' user_delete(root, request) with pytest.raises(KeyError): get_principals()[u'bob']
def test_user_delete(self, events, extra_principals, root): from kotti.security import get_principals from kotti.views.users import user_delete request = DummyRequest() bob = get_principals()[u'bob'] request.params['name'] = u'' user_delete(root, request) assert request.session.pop_flash('error') == [u'No name was given.'] assert u'bob' in get_principals().keys() request.params['name'] = u'bob' result = user_delete(root, request) assert u'api' in result api = result[u'api'] assert api.principal == bob assert api.principal_type == u'User' assert u'bob' in get_principals().keys() request.params['name'] = u'john' request.params['delete'] = u'delete' user_delete(root, request) assert request.session.pop_flash('error') == [u"User was not found."] assert u'bob' in get_principals().keys() request.params['name'] = u'bob' request.params['delete'] = u'delete' user_delete(root, request) with pytest.raises(KeyError): get_principals()[u'bob']
def test_user_delete(self, events, extra_principals): from kotti.resources import get_root from kotti.security import get_principals from kotti.views.users import user_delete root = get_root() request = DummyRequest() bob = get_principals()[u'bob'] request.params['name'] = u'' user_delete(root, request) assert request.session.pop_flash('error') == [u'No name given.'] assert u'bob' in get_principals().keys() request.params['name'] = u'bob' result = user_delete(root, request) assert u'api' in result api = result[u'api'] assert api.principal == bob assert api.principal_type == u'User' assert u'bob' in get_principals().keys() request.params['name'] = u'john' request.params['delete'] = u'delete' user_delete(root, request) assert request.session.pop_flash('error') == [u"User not found."] assert u'bob' in get_principals().keys() request.params['name'] = u'bob' request.params['delete'] = u'delete' user_delete(root, request) with pytest.raises(KeyError): get_principals()[u'bob']
def test_user_delete(self, events, extra_principals, root): from kotti.security import get_principals from kotti.views.users import user_delete request = DummyRequest() bob = get_principals()['bob'] request.params['name'] = '' user_delete(root, request) assert request.session.pop_flash('error') == ['No name was given.'] assert 'bob' in get_principals().keys() request.params['name'] = 'bob' result = user_delete(root, request) assert 'api' in result api = result['api'] assert api.principal == bob assert api.principal_type == 'User' assert 'bob' in get_principals().keys() request.params['name'] = 'john' request.params['delete'] = 'delete' user_delete(root, request) assert request.session.pop_flash('error') == ["User was not found."] assert 'bob' in get_principals().keys() request.params['name'] = 'bob' request.params['delete'] = 'delete' user_delete(root, request) with pytest.raises(KeyError): # noinspection PyStatementEffect get_principals()['bob']
def test_deleted_group_removed_from_localgroups(self, events, extra_principals): from kotti import DBSession from kotti.resources import get_root from kotti.security import set_groups from kotti.resources import LocalGroup from kotti.views.users import user_delete root = get_root() request = DummyRequest() set_groups(u'group:bobsgroup', root, ['role:admin']) local_group = DBSession.query(LocalGroup).first() assert local_group.principal_name == u'group:bobsgroup' assert local_group.node == root request.params['name'] = u'group:bobsgroup' request.params['delete'] = u'delete' user_delete(root, request) assert DBSession.query(LocalGroup).first() == None
def test_reset_owner_to_none(self): from kotti.resources import get_root from kotti.resources import Content from kotti.views.users import user_delete from kotti.tests.test_node_views import TestNodeShare root = get_root() request = DummyRequest() TestNodeShare.add_some_principals() root[u'content_1'] = Content() root[u'content_1'].owner = u'bob' assert root[u'content_1'].owner == u'bob' request.params['name'] = u'bob' request.params['delete'] = u'delete' user_delete(root, request) assert root[u'content_1'].owner == None
def test_deleted_group_removed_in_usergroups(self, events, extra_principals, root, db_session): from kotti.security import get_principals from kotti.views.users import user_delete request = DummyRequest() bob = get_principals()['bob'] bob.groups = ['group:bobsgroup'] assert bob.groups == ['group:bobsgroup'] request.params['name'] = 'group:bobsgroup' request.params['delete'] = 'delete' user_delete(root, request) db_session.expire(bob) with pytest.raises(KeyError): # noinspection PyStatementEffect get_principals()['group:bobsgroup'] assert bob.groups == []
def test_deleted_group_removed_in_usergroups(self): from kotti.resources import get_root from kotti.security import get_principals from kotti.tests.test_node_views import TestNodeShare from kotti.views.users import user_delete root = get_root() request = DummyRequest() TestNodeShare.add_some_principals() bob = get_principals()[u'bob'] bob.groups = [u'group:bobsgroup'] assert bob.groups == [u'group:bobsgroup'] request.params['name'] = u'group:bobsgroup' request.params['delete'] = u'delete' user_delete(root, request) with pytest.raises(KeyError): get_principals()[u'group:bobsgroup'] assert bob.groups == []
def test_deleted_group_removed_from_localgroups(self): from kotti import DBSession from kotti.resources import get_root from kotti.security import set_groups from kotti.resources import LocalGroup from kotti.views.users import user_delete from kotti.tests.test_node_views import TestNodeShare root = get_root() request = DummyRequest() TestNodeShare.add_some_principals() set_groups(u'group:bobsgroup', root, ['role:admin']) local_group = DBSession.query(LocalGroup).first() assert local_group.principal_name == u'group:bobsgroup' assert local_group.node == root request.params['name'] = u'group:bobsgroup' request.params['delete'] = u'delete' user_delete(root, request) assert DBSession.query(LocalGroup).first() == None