コード例 #1
0
    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
コード例 #2
0
    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
コード例 #3
0
    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
コード例 #4
0
ファイル: test_security_views.py プロジェクト: Kotti/Kotti
    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
コード例 #5
0
ファイル: test_security_views.py プロジェクト: ddimmich/Kotti
    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 == []
コード例 #6
0
ファイル: test_security_views.py プロジェクト: ddimmich/Kotti
    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
コード例 #7
0
    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
コード例 #8
0
    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 == []
コード例 #9
0
    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
コード例 #10
0
ファイル: test_security_views.py プロジェクト: Kotti/Kotti
    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
コード例 #11
0
ファイル: test_security_views.py プロジェクト: Kotti/Kotti
    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"]
コード例 #12
0
    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']
コード例 #13
0
    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"]
コード例 #14
0
    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']
コード例 #15
0
    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']
コード例 #16
0
    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']
コード例 #17
0
    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
コード例 #18
0
    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
コード例 #19
0
    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
コード例 #20
0
ファイル: test_security_views.py プロジェクト: castaf/Kotti
    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 == []
コード例 #21
0
    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 == []
コード例 #22
0
    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 == []
コード例 #23
0
    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 == []
コード例 #24
0
    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