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


Python TokenAuthenticationPolicy.effective_principals方法代码示例

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


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

示例1: test_effective_principals_uses_callback

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import effective_principals [as 别名]
    def test_effective_principals_uses_callback(self, fake_token, pyramid_request):
        def callback(userid, request):
            return [userid + ".foo", "group:donkeys"]

        policy = TokenAuthenticationPolicy(callback=callback)
        pyramid_request.auth_token = fake_token

        result = policy.effective_principals(pyramid_request)

        assert set(result) > set(["acct:[email protected]", "acct:[email protected]", "group:donkeys"])
开发者ID:hypothesis,项目名称:h,代码行数:12,代码来源:policy_test.py

示例2: test_effective_principals_uses_callback

# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import effective_principals [as 别名]
    def test_effective_principals_uses_callback(self, pyramid_request):
        def callback(userid, request):
            return [userid + '.foo', 'group:donkeys']
        policy = TokenAuthenticationPolicy(callback=callback)
        pyramid_request.auth_token = 'valid123'

        result = policy.effective_principals(pyramid_request)

        assert set(result) > set(['acct:[email protected]',
                                  'acct:[email protected]',
                                  'group:donkeys'])
开发者ID:chinmaygghag,项目名称:h,代码行数:13,代码来源:policy_test.py

示例3: test_effective_principals_uses_callback

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

        result = policy.effective_principals(request)

        assert set(result) > set(['acct:[email protected]',
                                  'acct:[email protected]',
                                  'group:donkeys'])
开发者ID:ficolo,项目名称:h,代码行数:15,代码来源:policy_test.py


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