mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
GoogleOAuthTest: Include the /accounts/login/google/ step in tests.
This makes our Google auth tests a bit more faithful, in that they now follow the full Oauth flow, rather than skipping the first step.
This commit is contained in:
@@ -662,14 +662,21 @@ class ResponseMock(object):
|
|||||||
class GoogleOAuthTest(ZulipTestCase):
|
class GoogleOAuthTest(ZulipTestCase):
|
||||||
def google_oauth2_test(self, token_response, account_response, subdomain=None):
|
def google_oauth2_test(self, token_response, account_response, subdomain=None):
|
||||||
# type: (ResponseMock, ResponseMock, Optional[str]) -> HttpResponse
|
# type: (ResponseMock, ResponseMock, Optional[str]) -> HttpResponse
|
||||||
url = "/accounts/login/google/send/"
|
url = "/accounts/login/google/"
|
||||||
params = {}
|
params = {}
|
||||||
|
headers = {}
|
||||||
if subdomain is not None:
|
if subdomain is not None:
|
||||||
params['subdomain'] = subdomain
|
headers['HTTP_HOST'] = subdomain + ".testserver"
|
||||||
if len(params) > 0:
|
if len(params) > 0:
|
||||||
url += "?%s" % (urllib.parse.urlencode(params))
|
url += "?%s" % (urllib.parse.urlencode(params))
|
||||||
|
|
||||||
result = self.client_get(url)
|
result = self.client_get(url, **headers)
|
||||||
|
self.assertEqual(result.status_code, 302)
|
||||||
|
if '/accounts/login/google/send/' not in result.url:
|
||||||
|
return result
|
||||||
|
|
||||||
|
# Now do the /google/send/ request
|
||||||
|
result = self.client_get(result.url)
|
||||||
self.assertEqual(result.status_code, 302)
|
self.assertEqual(result.status_code, 302)
|
||||||
if 'google' not in result.url:
|
if 'google' not in result.url:
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user