precise oauth2 protocol support testing
gitea/fargo/pipeline/head Build started... Details

This commit is contained in:
Paul Marillonnet 2019-05-17 16:38:22 +02:00
parent 8525b48ecb
commit b931103ced
1 changed files with 5 additions and 4 deletions

View File

@ -68,15 +68,16 @@ def test_get_document_oauth2(app, john_doe, oauth2_client, user_doc):
options = resp.form['document'].options
assert u'éléphant.txt' in options[1]
# 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')