@@ -47,14 +47,15 @@ def setUp(self):
4747 self .callback_data ["signature" ] = hmac_hexdigest (
4848 self .api_client .hmac_key , self .callback_data ["user" ]
4949 )
50+ self .url = reverse ("api-link:third-party-auth" , query = self .query )
5051
5152 def test_auth_ok (self ):
5253 self .client .force_login (self .user )
53- res = self .client .get (reverse ( "api-link:third-party-auth" , query = self .query ) )
54+ res = self .client .get (self .url )
5455 assert res .status_code == 200
5556 with mock .patch ("requests.post" , new_callable = mocked_post (ok = True )) as mocked :
5657 res = self .client .post (
57- reverse ( "api-link:third-party-auth" ) ,
58+ self . url ,
5859 data = {"cgu_accepted" : True , "is_username_valid" : True , ** self .query },
5960 )
6061 mocked .assert_called_once_with (
@@ -70,7 +71,7 @@ def test_callback_error(self):
7071 self .client .force_login (self .user )
7172 with mock .patch ("requests.post" , new_callable = mocked_post (ok = False )) as mocked :
7273 res = self .client .post (
73- reverse ( "api-link:third-party-auth" ) ,
74+ self . url ,
7475 data = {"cgu_accepted" : True , "is_username_valid" : True , ** self .query },
7576 )
7677 mocked .assert_called_once_with (
@@ -98,14 +99,17 @@ def test_wrong_signature(self):
9899 )
99100 ]
100101
102+ res = self .client .post (self .url , data = self .query )
103+ assert res .status_code == 200
104+
101105 def test_cgu_not_accepted (self ):
102106 self .client .force_login (self .user )
103- res = self .client .get (reverse ( "api-link:third-party-auth" , query = self .query ) )
107+ res = self .client .get (self .url )
104108 assert res .status_code == 200
105- res = self .client .post (reverse ( "api-link:third-party-auth" ) , data = self .query )
109+ res = self .client .post (self . url , data = self .query )
106110 assert res .status_code == 200 # no redirect means invalid form
107111 res = self .client .post (
108- reverse ( "api-link:third-party-auth" ) ,
112+ self . url ,
109113 data = {"cgu_accepted" : False , "is_username_valid" : False , ** self .query },
110114 )
111115 assert res .status_code == 200
@@ -132,3 +136,5 @@ def test_missing_parameter(self):
132136 message = "Les données fournies pour l'authentification sont incorrectes." ,
133137 )
134138 ]
139+ res = self .client .post (self .url , data = self .query )
140+ assert res .status_code == 200
0 commit comments