当前位置: 首页>>代码示例>>Python>>正文


Python ProjectFactory.has_permission方法代码示例

本文整理汇总了Python中tests.factories.ProjectFactory.has_permission方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectFactory.has_permission方法的具体用法?Python ProjectFactory.has_permission怎么用?Python ProjectFactory.has_permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.factories.ProjectFactory的用法示例。


在下文中一共展示了ProjectFactory.has_permission方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_has_permission_on_parent_node_copyfrom

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_on_parent_node_copyfrom(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, is_public=False, parent=self.node)

        assert_false(component.has_permission(self.user, 'write'))
        res = views.check_access(component, Auth(user=self.user), 'copyfrom', None)
        assert_true(res)
开发者ID:mattspitzer,项目名称:osf.io,代码行数:9,代码来源:test_addons.py

示例2: test_has_permission_on_parent_node_copyto_fail_if_not_registration

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_on_parent_node_copyto_fail_if_not_registration(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, parent=self.node)

        assert_false(component.has_permission(self.user, 'write'))
        with assert_raises(HTTPError):
            views.check_access(component, Auth(user=self.user), 'copyto', None)
开发者ID:mattspitzer,项目名称:osf.io,代码行数:9,代码来源:test_addons.py

示例3: test_has_permission_on_parent_node_copyto_pass_if_registration

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_on_parent_node_copyto_pass_if_registration(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, parent=self.node)
        component.is_registration = True

        assert_false(component.has_permission(self.user, 'write'))
        res = views.check_access(component, Auth(user=self.user), 'copyto', None)
        assert_true(res)
开发者ID:mattspitzer,项目名称:osf.io,代码行数:10,代码来源:test_addons.py

示例4: test_has_permission_read_scope_write_action_forbidden

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_read_scope_write_action_forbidden(self):
        component = ProjectFactory(creator=self.user, is_public=False, parent=self.node)
        cas_resp = cas.CasResponse(authenticated=True, status=None, user=self.user._id,
                                   attributes={'accessTokenScope': {'osf.nodes.data_read'}})

        assert_true(component.has_permission(self.user, 'write'))
        with assert_raises(HTTPError) as exc_info:
            views.check_access(component, Auth(user=self.user), 'upload', cas_resp)
        assert_equal(exc_info.exception.code, 403)
开发者ID:mattspitzer,项目名称:osf.io,代码行数:11,代码来源:test_addons.py

示例5: test_has_permission_write_scope_read_action

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_write_scope_read_action(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, is_public=False, parent=self.node)
        cas_resp = cas.CasResponse(authenticated=True, status=None, user=self.user._id,
                                   attributes={'accessTokenScope': {'osf.nodes.data_write'}})

        assert_false(component.has_permission(self.user, 'write'))
        res = views.check_access(component, Auth(user=self.user), 'download', cas_resp)
        assert_true(res)
开发者ID:mattspitzer,项目名称:osf.io,代码行数:11,代码来源:test_addons.py

示例6: test_has_permission_private_not_authenticated

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_private_not_authenticated(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, is_public=False, parent=self.node)
        cas_resp = cas.CasResponse(authenticated=False)

        assert_false(component.has_permission(self.user, 'write'))
        with assert_raises(HTTPError) as exc_info:
            views.check_access(component, Auth(user=self.user), 'download', cas_resp)
        assert_equal(exc_info.exception.code, 403)
开发者ID:mattspitzer,项目名称:osf.io,代码行数:11,代码来源:test_addons.py

示例7: test_has_permission_private_irrelevant_scope_forbidden

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_private_irrelevant_scope_forbidden(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, is_public=False, parent=self.node)
        cas_resp = cas.CasResponse(authenticated=True, status=None, user=self.user._id,
                                   attributes={'accessTokenScope': {'osf.users.all_read'}})

        assert_false(component.has_permission(self.user, 'write'))
        with assert_raises(HTTPError) as exc_info:
            views.check_access(component, Auth(user=self.user), 'download', cas_resp)
        assert_equal(exc_info.exception.code, 403)
开发者ID:mattspitzer,项目名称:osf.io,代码行数:12,代码来源:test_addons.py

示例8: test_has_permission_public_irrelevant_scope_allowed

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_public_irrelevant_scope_allowed(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, is_public=True, parent=self.node)
        cas_resp = cas.CasResponse(
            authenticated=True, status=None, user=self.user._id, attributes={"accessTokenScope": {"osf.users.all_read"}}
        )

        assert_false(component.has_permission(self.user, "write"))
        res = views.check_access(component, Auth(user=self.user), "download", cas_resp)
        assert_true(res)
开发者ID:ycchen1989,项目名称:osf.io,代码行数:12,代码来源:test_addons.py

示例9: test_has_permission_decommissioned_scope_no_error

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import has_permission [as 别名]
    def test_has_permission_decommissioned_scope_no_error(self):
        component_admin = AuthUserFactory()
        component = ProjectFactory(creator=component_admin, is_public=False, parent=self.node)
        cas_resp = cas.CasResponse(
            authenticated=True,
            status=None,
            user=self.user._id,
            attributes={"accessTokenScope": {"decommissioned.scope+write", "osf.nodes.data_read"}},
        )

        assert_false(component.has_permission(self.user, "write"))
        res = views.check_access(component, Auth(user=self.user), "download", cas_resp)
        assert_true(res)
开发者ID:ycchen1989,项目名称:osf.io,代码行数:15,代码来源:test_addons.py


注:本文中的tests.factories.ProjectFactory.has_permission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。