auth_fc: do not assert depending on dict elements' order
This commit is contained in:
parent
c6355659d9
commit
8d8e5d0984
|
@ -45,11 +45,6 @@ def path(url):
|
|||
return urlparse.urlparse(url).path
|
||||
|
||||
|
||||
def path_and_query(url):
|
||||
parsed = urlparse.urlparse(url)
|
||||
return parsed.path + '?' + parsed.query
|
||||
|
||||
|
||||
def get_links_from_mail(mail):
|
||||
'''Extract links from mail sent by Django'''
|
||||
return re.findall('https?://[^ \n]*', mail.body)
|
||||
|
@ -107,7 +102,11 @@ def test_login_simple(app, fc_settings, caplog, hooks, exp):
|
|||
assert parsed['client_id'] == 'xxx'
|
||||
assert parsed['client_secret'] == 'yyy'
|
||||
assert parsed['grant_type'] == 'authorization_code'
|
||||
assert callback in parsed['redirect_uri']
|
||||
parsed_redirect = urlparse.urlparse(parsed['redirect_uri'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_redirect.path == parsed_callback.path
|
||||
for cb_key, cb_value in urlparse.parse_qs(parsed_callback.query).items():
|
||||
urlparse.parse_qs(parsed_redirect.query)[cb_key] == cb_value
|
||||
id_token = {
|
||||
'sub': '1234',
|
||||
'aud': 'xxx',
|
||||
|
@ -188,7 +187,11 @@ def test_login_email_is_unique(app, fc_settings, caplog):
|
|||
assert parsed['client_id'] == 'xxx'
|
||||
assert parsed['client_secret'] == 'yyy'
|
||||
assert parsed['grant_type'] == 'authorization_code'
|
||||
assert callback in parsed['redirect_uri']
|
||||
parsed_redirect = urlparse.urlparse(parsed['redirect_uri'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_redirect.path == parsed_callback.path
|
||||
for cb_key, cb_value in urlparse.parse_qs(parsed_callback.query).items():
|
||||
urlparse.parse_qs(parsed_redirect.query)[cb_key] == cb_value
|
||||
id_token = {
|
||||
'sub': '1234',
|
||||
'aud': 'xxx',
|
||||
|
@ -255,7 +258,11 @@ def test_login_email_is_unique_and_already_linked(app, fc_settings, caplog):
|
|||
assert parsed['client_id'] == 'xxx'
|
||||
assert parsed['client_secret'] == 'yyy'
|
||||
assert parsed['grant_type'] == 'authorization_code'
|
||||
assert callback in parsed['redirect_uri']
|
||||
parsed_redirect = urlparse.urlparse(parsed['redirect_uri'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_redirect.path == parsed_callback.path
|
||||
for cb_key, cb_value in urlparse.parse_qs(parsed_callback.query).items():
|
||||
urlparse.parse_qs(parsed_redirect.query)[cb_key] == cb_value
|
||||
id_token = {
|
||||
'sub': SUB,
|
||||
'aud': 'xxx',
|
||||
|
@ -339,7 +346,11 @@ def test_registration1(app, fc_settings, caplog, hooks):
|
|||
assert parsed['client_id'] == 'xxx'
|
||||
assert parsed['client_secret'] == 'yyy'
|
||||
assert parsed['grant_type'] == 'authorization_code'
|
||||
assert callback in parsed['redirect_uri']
|
||||
parsed_redirect = urlparse.urlparse(parsed['redirect_uri'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_redirect.path == parsed_callback.path
|
||||
for cb_key, cb_value in urlparse.parse_qs(parsed_callback.query).items():
|
||||
urlparse.parse_qs(parsed_redirect.query)[cb_key] == cb_value
|
||||
id_token = {
|
||||
'sub': '1234',
|
||||
'aud': 'xxx',
|
||||
|
@ -376,7 +387,11 @@ def test_registration1(app, fc_settings, caplog, hooks):
|
|||
assert hooks.calls['event'][0]['kwargs']['service'] == 'portail'
|
||||
# we must be connected
|
||||
assert app.session['_auth_user_id']
|
||||
assert path_and_query(response['Location']) == path_and_query(callback)
|
||||
parsed_location = urlparse.urlparse(response['Location'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_location.path == parsed_callback.path
|
||||
assert (urlparse.parse_qs(parsed_location.query) ==
|
||||
urlparse.parse_qs(parsed_callback.query))
|
||||
response = response.follow()
|
||||
location = response['Location']
|
||||
state = check_authorization_url(location)
|
||||
|
@ -421,7 +436,11 @@ def test_registration2(app, fc_settings, caplog, hooks):
|
|||
assert parsed['client_id'] == 'xxx'
|
||||
assert parsed['client_secret'] == 'yyy'
|
||||
assert parsed['grant_type'] == 'authorization_code'
|
||||
assert callback in parsed['redirect_uri']
|
||||
parsed_redirect = urlparse.urlparse(parsed['redirect_uri'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_redirect.path == parsed_callback.path
|
||||
for cb_key, cb_value in urlparse.parse_qs(parsed_callback.query).items():
|
||||
urlparse.parse_qs(parsed_redirect.query)[cb_key] == cb_value
|
||||
id_token = {
|
||||
'sub': '1234',
|
||||
'aud': 'xxx',
|
||||
|
@ -462,7 +481,11 @@ def test_registration2(app, fc_settings, caplog, hooks):
|
|||
callback = callback.replace('®istration=', '')
|
||||
callback = callback.replace('?registration=', '?')
|
||||
callback = callback.replace('?&', '?')
|
||||
assert path_and_query(response['Location']) == path_and_query(callback)
|
||||
parsed_location = urlparse.urlparse(response['Location'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_location.path == parsed_callback.path
|
||||
assert (urlparse.parse_qs(parsed_location.query) ==
|
||||
urlparse.parse_qs(parsed_callback.query))
|
||||
response = response.follow()
|
||||
location = response['Location']
|
||||
state = check_authorization_url(location)
|
||||
|
@ -507,7 +530,11 @@ def test_can_change_password(app, fc_settings, caplog, hooks):
|
|||
assert parsed['client_id'] == 'xxx'
|
||||
assert parsed['client_secret'] == 'yyy'
|
||||
assert parsed['grant_type'] == 'authorization_code'
|
||||
assert callback in parsed['redirect_uri']
|
||||
parsed_redirect = urlparse.urlparse(parsed['redirect_uri'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_redirect.path == parsed_callback.path
|
||||
for cb_key, cb_value in urlparse.parse_qs(parsed_callback.query).items():
|
||||
urlparse.parse_qs(parsed_redirect.query)[cb_key] == cb_value
|
||||
id_token = {
|
||||
'sub': '1234',
|
||||
'aud': 'xxx',
|
||||
|
@ -548,7 +575,11 @@ def test_can_change_password(app, fc_settings, caplog, hooks):
|
|||
callback = callback.replace('®istration=', '')
|
||||
callback = callback.replace('?registration=', '?')
|
||||
callback = callback.replace('?&', '?')
|
||||
assert path_and_query(response['Location']) == path_and_query(callback)
|
||||
parsed_location = urlparse.urlparse(response['Location'])
|
||||
parsed_callback = urlparse.urlparse(callback)
|
||||
assert parsed_location.path == parsed_callback.path
|
||||
assert (urlparse.parse_qs(parsed_location.query) ==
|
||||
urlparse.parse_qs(parsed_callback.query))
|
||||
response = response.follow()
|
||||
location = response['Location']
|
||||
state = check_authorization_url(location)
|
||||
|
|
Loading…
Reference in New Issue