64 |
64 |
resp = app.get(url, params=params)
|
65 |
65 |
|
66 |
66 |
assert resp.status_code == 200
|
67 |
|
assert len(resp.forms[0]['document'].options) == 2
|
68 |
|
options = resp.forms[0]['document'].options
|
|
67 |
assert len(resp.form['document'].options) == 2
|
|
68 |
options = resp.form['document'].options
|
69 |
69 |
assert u'éléphant.txt' in options[1]
|
70 |
70 |
|
71 |
|
resp.forms[0]['document'].select(options[1][0])
|
72 |
|
resp = resp.forms[0].submit()
|
|
71 |
# select the second document 'éléphant.txt'
|
|
72 |
resp.form['document'].select(options[1][0])
|
|
73 |
resp = resp.form.submit()
|
|
74 |
# check that the authorization has been registered for the user document
|
73 |
75 |
assert len(OAuth2Authorize.objects.filter(user_document__user=john_doe)) == 1
|
74 |
76 |
auth = OAuth2Authorize.objects.filter(user_document__user=john_doe)[0]
|
75 |
77 |
assert resp.status_code == 302
|
76 |
|
assert 'code' in resp.location
|
77 |
|
assert auth.code in resp.location
|
78 |
|
assert 'state' in resp.location
|
79 |
|
assert 'achipeachope' in resp.location
|
|
78 |
query = urlparse.urlparse(resp.location).query
|
|
79 |
assert [auth.code] == urlparse.parse_qs(query)['code']
|
|
80 |
assert ['achipeachope'] == urlparse.parse_qs(query)['state']
|
80 |
81 |
|
81 |
82 |
params.pop('response_type')
|
82 |
83 |
params.pop('state')
|
... | ... | |
139 |
140 |
assert OAuth2TempFile.objects.count() == 2
|
140 |
141 |
assert UserDocument.objects.count() == 0
|
141 |
142 |
|
142 |
|
resp = resp.forms[0].submit()
|
|
143 |
resp = resp.form.submit()
|
143 |
144 |
assert resp.status_code == 302
|
144 |
145 |
assert resp.location == 'https://example.com'
|
145 |
146 |
|
... | ... | |
180 |
181 |
}
|
181 |
182 |
params['redirect_uri'] = 'https://example.com'
|
182 |
183 |
resp = app.get(url, params=params)
|
183 |
|
options = resp.forms[0]['document'].options
|
|
184 |
options = resp.form['document'].options
|
184 |
185 |
assert u'éléphant.txt' in options[1]
|
185 |
|
resp.forms[0]['document'].select(options[1][0])
|
186 |
|
resp = resp.forms[0].submit()
|
|
186 |
resp.form['document'].select(options[1][0])
|
|
187 |
resp = resp.form.submit()
|
187 |
188 |
auth = OAuth2Authorize.objects.filter(user_document__user=john_doe)[0]
|
188 |
189 |
params.pop('response_type')
|
189 |
190 |
params.pop('state')
|
190 |
|
-
|