minor corrections in oauth 2.0 protocol testing (#33217)
This commit is contained in:
parent
8c032bd55b
commit
3ff19a18a9
|
@ -79,19 +79,20 @@ def test_get_document_oauth2(app, john_doe, oauth2_client, user_doc):
|
|||
resp = app.get(url, params=params)
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert len(resp.forms[0]['document'].options) == 2
|
||||
options = resp.forms[0]['document'].options
|
||||
assert len(resp.form['document'].options) == 2
|
||||
options = resp.form['document'].options
|
||||
assert u'éléphant.txt' in options[1]
|
||||
|
||||
resp.forms[0]['document'].select(options[1][0])
|
||||
resp = resp.forms[0].submit()
|
||||
# select the second document 'éléphant.txt'
|
||||
resp.form['document'].select(options[1][0])
|
||||
resp = resp.form.submit()
|
||||
# check that the authorization has been registered for the user document
|
||||
assert len(OAuth2Authorize.objects.filter(user_document__user=john_doe)) == 1
|
||||
auth = OAuth2Authorize.objects.filter(user_document__user=john_doe)[0]
|
||||
assert resp.status_code == 302
|
||||
assert 'code' in resp.location
|
||||
assert auth.code in resp.location
|
||||
assert 'state' in resp.location
|
||||
assert 'achipeachope' in resp.location
|
||||
query = urlparse.urlparse(resp.location).query
|
||||
assert [auth.code] == urlparse.parse_qs(query)['code']
|
||||
assert ['achipeachope'] == urlparse.parse_qs(query)['state']
|
||||
|
||||
params.pop('response_type')
|
||||
params.pop('state')
|
||||
|
@ -154,7 +155,7 @@ def test_put_document(app, john_doe, oauth2_client):
|
|||
assert OAuth2TempFile.objects.count() == 2
|
||||
assert UserDocument.objects.count() == 0
|
||||
|
||||
resp = resp.forms[0].submit()
|
||||
resp = resp.form.submit()
|
||||
assert resp.status_code == 302
|
||||
assert resp.location == 'https://example.com'
|
||||
|
||||
|
@ -195,10 +196,10 @@ def test_idp_authentication(mocked_post, settings, app, oauth2_client, john_doe,
|
|||
}
|
||||
params['redirect_uri'] = 'https://example.com'
|
||||
resp = app.get(url, params=params)
|
||||
options = resp.forms[0]['document'].options
|
||||
options = resp.form['document'].options
|
||||
assert u'éléphant.txt' in options[1]
|
||||
resp.forms[0]['document'].select(options[1][0])
|
||||
resp = resp.forms[0].submit()
|
||||
resp.form['document'].select(options[1][0])
|
||||
resp = resp.form.submit()
|
||||
auth = OAuth2Authorize.objects.filter(user_document__user=john_doe)[0]
|
||||
params.pop('response_type')
|
||||
params.pop('state')
|
||||
|
|
Loading…
Reference in New Issue