本文整理汇总了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
示例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")')
示例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")
示例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()