python类Unauthorized()的实例源码

test_token_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_anonymous_user_delete(self):
        """Test anonymous user is not allowed to delete an oauth token"""
        for token in self.auth_providers:
            assert_raises(Unauthorized,
                      ensure_authorized_to, 'delete', 'token', token=token)
test_token_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_anonymous_user_create(self):
        """Test anonymous user is not allowed to create an oauth token"""
        for token in self.auth_providers:
            assert_raises(Unauthorized,
                      ensure_authorized_to, 'create', 'token', token=token)
test_token_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_anonymous_user_read(self):
        """Test anonymous user is not allowed to read an oauth token"""
        for token in self.auth_providers:
            assert_raises(Unauthorized,
                      ensure_authorized_to, 'read', 'token', token=token)
test_project_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_anonymous_user_cannot_create(self):
        """Test anonymous users cannot projects"""
        assert_raises(Unauthorized, ensure_authorized_to, 'create', Project)
test_project_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_anonymous_user_cannot_read_given_draft(self):
        """Test anonymous users cannot read draft projects"""
        project = ProjectFactory.create(published=False)

        assert_raises(Unauthorized, ensure_authorized_to, 'read', project)
test_project_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_anonymous_user_cannot_update(self):
        """Test anonymous users cannot update a project"""
        project = ProjectFactory.create()

        assert_raises(Unauthorized, ensure_authorized_to, 'update', project)
test_project_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_anonymous_user_cannot_delete(self):
        """Test anonymous users cannot delete a project"""
        project = ProjectFactory.create()

        assert_raises(Unauthorized, ensure_authorized_to, 'delete', project)
test_blogpost_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_anonymous_user_create_given_blogpost(self):
        """Test anonymous users cannot create a given blogpost"""

        project = ProjectFactory.create()
        blogpost = BlogpostFactory.build(project=project, owner=None)

        assert_raises(Unauthorized, ensure_authorized_to, 'create', blogpost)
test_blogpost_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_anonymous_user_create_blogposts_for_given_project(self):
        """Test anonymous users cannot create blogposts for a given project"""

        project = ProjectFactory.create()

        assert_raises(Unauthorized, ensure_authorized_to, 'create', Blogpost, project_id=project.id)
test_blogpost_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_anonymous_user_create_blogposts(self):
        """Test anonymous users cannot create any blogposts"""

        assert_raises(Unauthorized, ensure_authorized_to, 'create', Blogpost)
test_blogpost_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_anonymous_user_read_given_blogpost_draft_project(self):
        """Test anonymous users cannot read a given blogpost of a draft project"""

        project = ProjectFactory.create(published=False)
        blogpost = BlogpostFactory.create(project=project)

        assert_raises(Unauthorized, ensure_authorized_to, 'read', blogpost)
test_blogpost_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_anonymous_user_read_blogposts_for_given_draft_project(self):
        """Test anonymous users cannot read blogposts of a given project if is a draft"""

        project = ProjectFactory.create(published=False)

        assert_raises(Unauthorized, ensure_authorized_to, 'read', Blogpost, project_id=project.id)
test_blogpost_auth.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_anonymous_user_delete_blogpost(self):
        """Test anonymous users cannot delete blogposts"""

        blogpost = BlogpostFactory.create()

        assert_raises(Unauthorized, ensure_authorized_to, 'delete', blogpost)
__init__.py 文件源码 项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_ensure_authorized_raises_401_anonymous_non_authorized(self, auth):
        auth.return_value = False

        assert_raises(Unauthorized, ensure_authorized_to, 'create', User)
test_gamecenter.py 文件源码 项目:drift 作者: dgnorth 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_missing_fields(self):
        # Verify missing field check. The exception will list out all missing fields, so by removing
        # a single field, we should only be notified of that one missing.
        with self.assertRaises(Unauthorized) as context:
            t = template.copy()
            del t['salt']
            validate_gamecenter_token(t)
        self.assertIn("The token is missing required fields: salt.", context.exception.description)
test_gamecenter.py 文件源码 项目:drift 作者: dgnorth 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_app_bundles(self):
        # Verify that the token is issued to the appropriate app.
        with self.assertRaises(Unauthorized) as context:
            validate_gamecenter_token(template, app_bundles=['dummy'])
        self.assertIn("'app_bundle_id' not one of ['dummy']", context.exception.description)
test_gamecenter.py 文件源码 项目:drift 作者: dgnorth 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_broken_cert(self):
        # Verify that broken certs fail.
        with self.assertRaises(Unauthorized) as context:
            t = template.copy()
            t['public_key_url'] = 'broken cert'
            validate_gamecenter_token(t)
        self.assertIn("Can't load certificate", context.exception.description)
test_gamecenter.py 文件源码 项目:drift 作者: dgnorth 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_cert_validation(self):
        # Make sure cert is issued to a trusted organization.
        _tmp = TRUSTED_ORGANIZATIONS[:]
        TRUSTED_ORGANIZATIONS[:] = ['Mordor Inc.']
        try:
            with self.assertRaises(Unauthorized) as context:
                validate_gamecenter_token(template)
            self.assertIn("Certificate is issued to 'Apple Inc.' which is not one of ['Mordor Inc.'].", context.exception.description)
        finally:
            TRUSTED_ORGANIZATIONS[:] = _tmp
gamecenter.py 文件源码 项目:drift 作者: dgnorth 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def abort_unauthorized(description):
    """Raise an Unauthorized exception.
    """
    raise Unauthorized(description=description)
steam.py 文件源码 项目:drift 作者: dgnorth 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def abort_unauthorized(description):
    """Raise an Unauthorized exception.
    """
    raise Unauthorized(description=description)




# Steam provider details schema


问题


面经


文章

微信
公众号

扫码关注公众号