oidc authn: include a status code in httmock responses
This commit is contained in:
parent
43769fb2a7
commit
0e923ba857
|
@ -209,6 +209,7 @@ def oidc_provider_mock(oidc_provider, oidc_provider_jwkset, code, extra_id_token
|
|||
'headers': {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
'status_code': 200,
|
||||
}
|
||||
else:
|
||||
return {
|
||||
|
@ -216,7 +217,7 @@ def oidc_provider_mock(oidc_provider, oidc_provider_jwkset, code, extra_id_token
|
|||
'headers': {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
'status': 400,
|
||||
'status_code': 400,
|
||||
}
|
||||
|
||||
@urlmatch(netloc=userinfo_endpoint.netloc, path=userinfo_endpoint.path)
|
||||
|
@ -235,13 +236,16 @@ def oidc_provider_mock(oidc_provider, oidc_provider_jwkset, code, extra_id_token
|
|||
'headers': {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
'status_code': 200,
|
||||
}
|
||||
|
||||
@urlmatch(netloc=token_revocation_endpoint.netloc, path=token_revocation_endpoint.path)
|
||||
def token_revocation_endpoint_mock(url, request):
|
||||
query = urlparse.parse_qs(request.body)
|
||||
assert 'token' in query
|
||||
return {}
|
||||
return {
|
||||
'status_code': 200,
|
||||
}
|
||||
return HTTMock(token_endpoint_mock, user_info_endpoint_mock, token_revocation_endpoint_mock)
|
||||
|
||||
|
||||
|
@ -295,7 +299,7 @@ def test_sso(app, caplog, code, oidc_provider, oidc_provider_jwkset, login_url,
|
|||
User = get_user_model()
|
||||
assert User.objects.count() == 0
|
||||
|
||||
with utils.check_log(caplog, 'invalid token endpoint response'):
|
||||
with utils.check_log(caplog, 'failed to contact the token_endpoint'):
|
||||
with oidc_provider_mock(oidc_provider, oidc_provider_jwkset, code):
|
||||
response = app.get(login_callback_url, params={'code': 'yyyy', 'state': query['state']})
|
||||
with utils.check_log(caplog, 'invalid id_token %r'):
|
||||
|
|
Loading…
Reference in New Issue