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


Python RegistrationResponse.to_dict方法代码示例

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


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

示例1: test_registered_redirect_uri_with_query_component

# 需要导入模块: from oic.oic.message import RegistrationResponse [as 别名]
# 或者: from oic.oic.message.RegistrationResponse import to_dict [as 别名]
    def test_registered_redirect_uri_with_query_component(self):
        provider2 = Provider("FOOP", {}, {}, None, None, None, None, "")

        rr = RegistrationRequest(operation="register",
                                 redirect_uris=["http://example.org/cb?foo=bar"],
                                 response_types=["code"])

        registration_req = rr.to_json()
        resp = provider2.registration_endpoint(request=registration_req)

        regresp = RegistrationResponse().from_json(resp.message)

        print regresp.to_dict()

        faulty = [
            "http://example.org/cb",
            "http://example.org/cb/foo",
            "http://example.org/cb?got=you",
            "http://example.org/cb?foo=you"
            "http://example.org/cb?foo=bar&got=you",
            "http://example.org/cb?foo=you&foo=bar"
        ]
        correct = [
            "http://example.org/cb?foo=bar",
        ]

        cid = regresp["client_id"]

        for ruri in faulty:
            areq = AuthorizationRequest(redirect_uri=ruri,
                                        client_id=cid,
                                        scope="openid",
                                        response_type="code")

            print areq
            try:
                provider2._verify_redirect_uri(areq)
            except RedirectURIError:
                pass

        for ruri in correct:
            areq = AuthorizationRequest(redirect_uri=ruri,
                                        client_id=cid, scope="openid",
                                        response_type="code")

            resp = provider2._verify_redirect_uri(areq)
            print resp
            assert resp is None
开发者ID:dallerbarn,项目名称:pyoidc,代码行数:50,代码来源:test_oic_provider.py

示例2: test_registered_redirect_uri_with_query_component

# 需要导入模块: from oic.oic.message import RegistrationResponse [as 别名]
# 或者: from oic.oic.message.RegistrationResponse import to_dict [as 别名]
def test_registered_redirect_uri_with_query_component():
    provider2 = Provider("FOOP", {}, {}, None, None)
    environ = {}

    rr = RegistrationRequest(operation="register",
                             redirect_uris=["http://example.org/cb?foo=bar"])

    registration_req = rr.to_urlencoded()
    resp = provider2.registration_endpoint(environ, start_response,
                                    query=registration_req)

    regresp = RegistrationResponse().from_json(resp[0])

    print regresp.to_dict()

    faulty = [
        "http://example.org/cb",
        "http://example.org/cb/foo",
        "http://example.org/cb?got=you",
        "http://example.org/cb?foo=you"
    ]
    correct = [
        "http://example.org/cb?foo=bar",
        "http://example.org/cb?foo=bar&got=you",
        "http://example.org/cb?foo=bar&foo=you"
    ]

    for ruri in faulty:
        areq = AuthorizationRequest(redirect_uri=ruri,
                                    client_id=regresp["client_id"],
                                    scope="openid",
                                    response_type="code")

        print areq
        assert provider2._verify_redirect_uri(areq) != None


    for ruri in correct:
        areq = AuthorizationRequest(redirect_uri= ruri,
                                    client_id=regresp["client_id"])

        resp = provider2._verify_redirect_uri(areq)
        print resp
        assert resp == None
开发者ID:asheidan,项目名称:pyoidc,代码行数:46,代码来源:test_oic_provider.py

示例3: test_read_registration

# 需要导入模块: from oic.oic.message import RegistrationResponse [as 别名]
# 或者: from oic.oic.message.RegistrationResponse import to_dict [as 别名]
    def test_read_registration(self):
        rr = RegistrationRequest(
            operation="register", redirect_uris=["http://example.org/new"], response_types=["code"]
        )
        registration_req = rr.to_json()
        resp = self.provider.registration_endpoint(request=registration_req)
        regresp = RegistrationResponse().from_json(resp.message)

        authn = " ".join(["Bearer", regresp["registration_access_token"]])
        query = "=".join(["client_id", regresp["client_id"]])
        resp = self.provider.read_registration(authn, query)

        assert json.loads(resp.message) == regresp.to_dict()
开发者ID:htobenothing,项目名称:pyoidc,代码行数:15,代码来源:test_oic_provider.py

示例4: KeyBundle

# 需要导入模块: from oic.oic.message import RegistrationResponse [as 别名]
# 或者: from oic.oic.message.RegistrationResponse import to_dict [as 别名]
        # Add the key to the keyjar
        if client_secret:
            _kc = KeyBundle([{"kty": "oct", "key": client_secret,
                              "use": "ver"},
                             {"kty": "oct", "key": client_secret,
                              "use": "sig"}])
            try:
                _keyjar[client_id].append(_kc)
            except KeyError:
                _keyjar[client_id] = [_kc]

        self.cdb[client_id] = _cinfo
        _log_info("Client info: %s" % _cinfo)

        logger.debug("registration_response: %s" % response.to_dict())

        return Response(response.to_json(), content="application/json",
                        headers=[("Cache-Control", "no-store")])

    def registration_endpoint(self, request, authn=None, **kwargs):
        return self.l_registration_endpoint(request, authn, **kwargs)

    def read_registration(self, authn, request, **kwargs):
        """
        Read all information this server has on a client.
        Authorization is done by using the access token that was return as
        part of the client registration result.

        :param authn: The Authorization HTTP header
        :param request: The query part of the URL
开发者ID:wayward710,项目名称:pyoidc,代码行数:32,代码来源:provider.py


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