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


Python TokenAuthenticationPolicy.unauthenticated_userid方法代码示例

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


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

示例1: test_unauthenticated_userid_passes_token_to_extractor_functions

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_passes_token_to_extractor_functions(self, jwt, api_token):
        policy = TokenAuthenticationPolicy()
        api_token.return_value = None
        jwt.return_value = None
        request = DummyRequest(headers={'Authorization': 'Bearer f00ba12'})

        policy.unauthenticated_userid(request)

        api_token.assert_called_once_with('f00ba12')
        jwt.assert_called_once_with('f00ba12', request)
开发者ID:ficolo,项目名称:h,代码行数:12,代码来源:policy_test.py

示例2: test_unauthenticated_userid_returns_userid_from_token

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_userid_from_token(self, fake_token, pyramid_request):
        policy = TokenAuthenticationPolicy()
        pyramid_request.auth_token = fake_token

        result = policy.unauthenticated_userid(pyramid_request)

        assert result == "acct:[email protected]"
开发者ID:hypothesis,项目名称:h,代码行数:9,代码来源:policy_test.py

示例3: test_unauthenticated_userid_returns_none_if_token_invalid

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_none_if_token_invalid(self, pyramid_request):
        policy = TokenAuthenticationPolicy()
        token = DummyToken(valid=False)
        pyramid_request.auth_token = token

        result = policy.unauthenticated_userid(pyramid_request)

        assert result is None
开发者ID:hypothesis,项目名称:h,代码行数:10,代码来源:policy_test.py

示例4: test_unauthenticated_userid_returns_none_if_token_invalid

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_none_if_token_invalid(self, pyramid_request, token_service):
        policy = TokenAuthenticationPolicy()
        token_service.validate.return_value = None
        pyramid_request.auth_token = 'abcd123'

        result = policy.unauthenticated_userid(pyramid_request)

        assert result is None
开发者ID:chinmaygghag,项目名称:h,代码行数:10,代码来源:policy_test.py

示例5: test_unauthenticated_userid_returns_none_if_neither_token_valid

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_none_if_neither_token_valid(self, jwt, api_token):
        policy = TokenAuthenticationPolicy()
        api_token.return_value = None
        jwt.return_value = None
        request = DummyRequest(headers={'Authorization': 'Bearer f00ba12'})

        result = policy.unauthenticated_userid(request)

        assert result is None
开发者ID:ficolo,项目名称:h,代码行数:11,代码来源:policy_test.py

示例6: test_unauthenticated_userid_returns_userid_from_jwt_as_fallback

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_userid_from_jwt_as_fallback(self, jwt, api_token):
        policy = TokenAuthenticationPolicy()
        api_token.return_value = None
        jwt.return_value = 'acct:[email protected]'
        request = DummyRequest(headers={'Authorization': 'Bearer f00ba12'})

        result = policy.unauthenticated_userid(request)

        assert result == 'acct:[email protected]'
开发者ID:ficolo,项目名称:h,代码行数:11,代码来源:policy_test.py

示例7: test_unauthenticated_userid_returns_userid_from_api_token_if_present

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_userid_from_api_token_if_present(self, jwt, api_token, pyramid_request):
        policy = TokenAuthenticationPolicy()
        api_token.return_value = 'acct:[email protected]'
        jwt.return_value = 'acct:[email protected]'
        pyramid_request.headers = {'Authorization': 'Bearer f00ba12'}

        result = policy.unauthenticated_userid(pyramid_request)

        assert result == 'acct:[email protected]'
开发者ID:djcun95,项目名称:h,代码行数:11,代码来源:policy_test.py

示例8: test_unauthenticated_userid_returns_none_for_invalid_query_param_token

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_none_for_invalid_query_param_token(self, pyramid_request):
        """When the path is `/ws` but the token is invalid, it should still return None."""

        policy = TokenAuthenticationPolicy()
        pyramid_request.GET['access_token'] = 'expired'
        pyramid_request.path = '/ws'

        result = policy.unauthenticated_userid(pyramid_request)

        assert result is None
开发者ID:chinmaygghag,项目名称:h,代码行数:12,代码来源:policy_test.py

示例9: test_unauthenticated_userid_returns_userid_from_query_params_token

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_returns_userid_from_query_params_token(self, pyramid_request):
        """When the path is `/ws` then we look into the query string parameters as well."""

        policy = TokenAuthenticationPolicy()
        pyramid_request.GET['access_token'] = 'valid123'
        pyramid_request.path = '/ws'

        result = policy.unauthenticated_userid(pyramid_request)

        assert result == 'acct:[email protected]'
开发者ID:chinmaygghag,项目名称:h,代码行数:12,代码来源:policy_test.py

示例10: test_unauthenticated_userid_skips_query_param_for_non_ws_requests

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_skips_query_param_for_non_ws_requests(self, pyramid_request):
        """
        When we have a valid token in the `access_token` query param, but it's
        not a request to /ws, then we should ignore this access token.
        """

        policy = TokenAuthenticationPolicy()
        pyramid_request.GET['access_token'] = 'valid123'
        pyramid_request.path = '/api'

        result = policy.unauthenticated_userid(pyramid_request)

        assert result is None
开发者ID:chinmaygghag,项目名称:h,代码行数:15,代码来源:policy_test.py

示例11: test_unauthenticated_userid_is_none_if_no_token

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_is_none_if_no_token(self, pyramid_request):
        policy = TokenAuthenticationPolicy()

        assert policy.unauthenticated_userid(pyramid_request) is None
开发者ID:hypothesis,项目名称:h,代码行数:6,代码来源:policy_test.py

示例12: test_unauthenticated_userid_is_none_if_header_incorrectly_formatted

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_is_none_if_header_incorrectly_formatted(self, value):
        policy = TokenAuthenticationPolicy()
        request = DummyRequest(headers={'Authorization': value})

        assert policy.unauthenticated_userid(request) is None
开发者ID:ficolo,项目名称:h,代码行数:7,代码来源:policy_test.py

示例13: test_unauthenticated_userid_is_none_if_header_missing

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_is_none_if_header_missing(self):
        policy = TokenAuthenticationPolicy()
        request = DummyRequest()

        assert policy.unauthenticated_userid(request) is None
开发者ID:ficolo,项目名称:h,代码行数:7,代码来源:policy_test.py

示例14: test_unauthenticated_userid_is_none_if_header_incorrectly_formatted

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import unauthenticated_userid [as 别名]
    def test_unauthenticated_userid_is_none_if_header_incorrectly_formatted(self, pyramid_request, value):
        policy = TokenAuthenticationPolicy()
        pyramid_request.headers = {'Authorization': value}

        assert policy.unauthenticated_userid(pyramid_request) is None
开发者ID:djcun95,项目名称:h,代码行数:7,代码来源:policy_test.py


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