tests: GET the login page before POST, to prevent cookies message (#42280)

This commit is contained in:
Benjamin Dauvergne 2020-05-05 19:14:15 +02:00
parent 1a0e3d0c17
commit 9fadcd5f9d
1 changed files with 7 additions and 0 deletions

View File

@ -120,6 +120,7 @@ class CasTests(Authentic2TestCase):
query = urlparse.parse_qs(location.split('?')[1])
next_url, next_url_query = query['next'][0].split('?')
next_url_query = urlparse.parse_qs(next_url_query)
response = client.get(location)
response = client.post(location, {'login-password-submit': '',
'username': self.LOGIN, 'password': self.PASSWORD}, follow=False)
response = client.get(response.url)
@ -136,6 +137,7 @@ class CasTests(Authentic2TestCase):
query = urlparse.parse_qs(location.split('?')[1])
next_url, next_url_query = query['next'][0].split('?')
next_url_query = urlparse.parse_qs(next_url_query)
response = client.get(location)
response = client.post(location, {'login-password-submit': '',
'username': self.LOGIN, 'password': self.PASSWORD}, follow=False)
response = client.get(response.url)
@ -162,6 +164,7 @@ class CasTests(Authentic2TestCase):
set([constants.SERVICE_PARAM, NONCE_FIELD_NAME]))
self.assertEqual(next_url_query[constants.SERVICE_PARAM], [self.URL])
self.assertEqual(next_url_query[NONCE_FIELD_NAME], [ticket.ticket_id])
response = self.client.get(location)
response = self.client.post(location, {'login-password-submit': '',
'username': self.LOGIN, 'password': self.PASSWORD}, follow=False)
self.assertIn(AUTHENTICATION_EVENTS_SESSION_KEY, self.client.session)
@ -207,6 +210,7 @@ class CasTests(Authentic2TestCase):
set([constants.SERVICE_PARAM, NONCE_FIELD_NAME]))
self.assertEqual(next_url_query[constants.SERVICE_PARAM], [self.URL])
self.assertEqual(next_url_query[NONCE_FIELD_NAME], [ticket.ticket_id])
response = self.client.get(location)
response = self.client.post(location, {'login-password-submit': '',
'username': self.LOGIN, 'password': self.PASSWORD}, follow=False)
self.assertIn(AUTHENTICATION_EVENTS_SESSION_KEY, self.client.session)
@ -258,6 +262,7 @@ class CasTests(Authentic2TestCase):
set([constants.SERVICE_PARAM, NONCE_FIELD_NAME]))
self.assertEqual(next_url_query[constants.SERVICE_PARAM], [self.URL])
self.assertEqual(next_url_query[NONCE_FIELD_NAME], [ticket.ticket_id])
response = self.client.get(location)
response = self.client.post(location, {'login-password-submit': '',
'username': self.LOGIN, 'password': self.PASSWORD}, follow=False)
self.assertIn(AUTHENTICATION_EVENTS_SESSION_KEY, self.client.session)
@ -307,6 +312,7 @@ class CasTests(Authentic2TestCase):
set([constants.SERVICE_PARAM, NONCE_FIELD_NAME]))
self.assertEqual(next_url_query[constants.SERVICE_PARAM], [self.URL])
self.assertEqual(next_url_query[NONCE_FIELD_NAME], [ticket.ticket_id])
response = self.client.get(location)
response = self.client.post(location, {'login-password-submit': '',
'username': self.LOGIN, 'password': self.PASSWORD}, follow=False)
self.assertIn(AUTHENTICATION_EVENTS_SESSION_KEY, self.client.session)
@ -359,6 +365,7 @@ class CasTests(Authentic2TestCase):
set([constants.SERVICE_PARAM, NONCE_FIELD_NAME]))
self.assertEqual(next_url_query[constants.SERVICE_PARAM], [self.URL])
self.assertEqual(next_url_query[NONCE_FIELD_NAME], [ticket.ticket_id])
response = self.client.get(location)
response = self.client.post(location, {'login-password-submit': '',
'username': self.LOGIN, 'password': self.PASSWORD}, follow=False)
self.assertIn(AUTHENTICATION_EVENTS_SESSION_KEY, self.client.session)