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


Python ErrorResponse.to_urlencoded方法代码示例

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


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

示例1: test_omit

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import to_urlencoded [as 别名]
    def test_omit(self):
        err = ErrorResponse(error="invalid_request",
                            error_description="Something was missing",
                            error_uri="http://example.com/error_message.html")

        ue_str = err.to_urlencoded()
        del err["error_uri"]
        ueo_str = err.to_urlencoded()

        assert ue_str != ueo_str
        assert "error_message" not in ueo_str
        assert "error_message" in ue_str
开发者ID:Omosofe,项目名称:pyoidc,代码行数:14,代码来源:test_oauth2_message.py

示例2: test_parse_access_token_response

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import to_urlencoded [as 别名]
def test_parse_access_token_response():
    client = Client()

    at = AccessTokenResponse(access_token="SlAV32hkKG", token_type="Bearer",
                             refresh_token="8xLOxBtZp8", expires_in=3600)

    atj = at.to_json()

    ATR = AccessTokenResponse
    atr = client.parse_response(ATR, info=atj)

    assert _eq(atr.keys(), ['access_token', 'token_type', 'expires_in',
                            'refresh_token'])

    uec = at.to_urlencoded()
    raises(ValueError, 'client.parse_response(ATR, info=uec)')

    uatr = client.parse_response(ATR, info=uec, sformat="urlencoded")
    assert _eq(uatr.keys(), ['access_token', 'token_type', 'expires_in',
                             'refresh_token'])

    huec = "%s?%s" % ("https://example.com/token", uec)

    uatr = client.parse_response(ATR, info=huec, sformat="urlencoded")
    assert _eq(uatr.keys(), ['access_token', 'token_type', 'expires_in',
                             'refresh_token'])

    err = ErrorResponse(error="invalid_request",
                        error_description="Something was missing",
                        error_uri="http://example.com/error_message.html")

    jerr = err.to_json()
    uerr = err.to_urlencoded()

    _ = client.parse_response(ATR, info=jerr)
    _ = client.parse_response(ATR, info=uerr, sformat="urlencoded")

    raises(Exception,
           'client.parse_response(ATR, info=jerr, sformat="urlencoded")')

    raises(Exception, "client.parse_response(ATR, info=uerr)")

    raises(Exception,
           'client.parse_response(ATR, info=jerr, sformat="focus")')
开发者ID:dash-dash,项目名称:pyoidc,代码行数:46,代码来源:test_oic.py

示例3: test_parse_error_resp

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import to_urlencoded [as 别名]
    def test_parse_error_resp(self):
        err = ErrorResponse(error="invalid_request",
                            error_description="Something was missing",
                            error_uri="http://example.com/error_message.html")
        jerr = err.to_json()
        uerr = err.to_urlencoded()

        _ = self.client.parse_response(AccessTokenResponse, info=jerr)
        _ = self.client.parse_response(AccessTokenResponse, info=uerr,
                                       sformat="urlencoded")

        with pytest.raises(ResponseError):
            self.client.parse_response(AccessTokenResponse, info=jerr, sformat="urlencoded")

        with pytest.raises(ValueError):
            self.client.parse_response(AccessTokenResponse, info=uerr)

        with pytest.raises(FormatError):
            self.client.parse_response(AccessTokenResponse, info=jerr, sformat="focus")
开发者ID:Omosofe,项目名称:pyoidc,代码行数:21,代码来源:test_oauth2.py

示例4: test_missing_required

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import to_urlencoded [as 别名]
    def test_missing_required(self):
        err = ErrorResponse()
        assert "error" not in err

        with pytest.raises(MissingRequiredAttribute):
            err.to_urlencoded()
开发者ID:Omosofe,项目名称:pyoidc,代码行数:8,代码来源:test_oauth2_message.py


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