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


Python DummyRequest._get_authentication_policy方法代码示例

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


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

示例1: test_request_wrong_auth

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import _get_authentication_policy [as 别名]
    def test_request_wrong_auth(self):
        from pyramid.testing import DummyRequest
        from c2cgeoportal import get_user_from_request
        from c2cgeoportal import default_user_validator
        from c2cgeoportal.lib.authentication import create_authentication

        request = DummyRequest(
            headers={"Authorization": "Basic " + base64.b64encode("__test_user:__wrong_pass").replace("\n", "")}
        )
        request.registry.validate_user = default_user_validator
        request._get_authentication_policy = lambda: create_authentication(
            {"authtkt_cookie_name": "__test", "authtkt_secret": "123"}
        )
        request.set_property(get_user_from_request, name="user", reify=True)

        self.assertEqual(request.user, None)
开发者ID:DavMerca007,项目名称:c2cgeoportal,代码行数:18,代码来源:test_request_property.py

示例2: test_request_right_auth

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import _get_authentication_policy [as 别名]
    def test_request_right_auth(self):
        from pyramid.testing import DummyRequest
        from c2cgeoportal.pyramid_ import default_user_validator
        from c2cgeoportal.lib.authentication import create_authentication

        request = DummyRequest(
            headers={"Authorization": "Basic " + base64.b64encode("__test_user:__test_user").replace("\n", "")}
        )
        request.path_info_peek = lambda: "main"
        request.registry.validate_user = default_user_validator
        request._get_authentication_policy = lambda: create_authentication(
            {"authtkt_cookie_name": "__test", "authtkt_secret": "123"}
        )
        add_user_property(request)

        self.assertEqual(request.user.username, u"__test_user")
开发者ID:,项目名称:,代码行数:18,代码来源:

示例3: test_request_right_auth

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import _get_authentication_policy [as 别名]
    def test_request_right_auth(self):
        from pyramid.testing import DummyRequest
        from c2cgeoportal import get_user_from_request
        from c2cgeoportal import default_user_validator
        from c2cgeoportal.lib.authentication import create_authentication

        request = DummyRequest(headers={
            'Authorization': 'Basic ' + base64.b64encode('__test_user:__test_user').replace('\n', '')
        })
        request.registry.validate_user = default_user_validator
        request._get_authentication_policy = lambda: create_authentication({
            "authtkt_cookie_name": "__test",
            "authtkt_secret": "123",
        })
        request.set_property(
            get_user_from_request, name='user', reify=True
        )

        self.assertEqual(request.user.username, u'__test_user')
开发者ID:kailIII,项目名称:c2cgeoportal,代码行数:21,代码来源:test_request_property.py


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