mirror of https://github.com/zulip/zulip.git
auth: Add email_data option to github_oauth2_test.
Removes email_not_verified option. That option was used to assign email_data a different set of emails for a test. Instead of that, this refactor allows to specify the email_data itself in the function which calls github_oauth2_test. Flags like email_not_verified are generally used in one test. This is a preparatory refactor for choose email screen which may have introduced multiple flags otherwise.
This commit is contained in:
parent
79e590f50f
commit
c1d1378125
|
@ -431,7 +431,7 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
|||
*, subdomain: Optional[str]=None,
|
||||
mobile_flow_otp: Optional[str]=None,
|
||||
is_signup: Optional[str]=None,
|
||||
email_not_verified: bool=False,
|
||||
email_data: Optional[List[Dict[str, Any]]]=None,
|
||||
next: str='') -> HttpResponse:
|
||||
url = "/accounts/login/social/github"
|
||||
params = {}
|
||||
|
@ -470,13 +470,8 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
|||
'access_token': 'foobar',
|
||||
'token_type': 'bearer'
|
||||
}
|
||||
if email_not_verified:
|
||||
email_data = [
|
||||
dict(email=account_data_dict["email"],
|
||||
verified=False,
|
||||
primary=True),
|
||||
]
|
||||
else:
|
||||
|
||||
if not email_data:
|
||||
# Keeping a verified email before the primary email makes sure
|
||||
# get_verified_emails puts the primary email at the start of the
|
||||
# email list returned as social_associate_user_helper assumes the
|
||||
|
@ -560,10 +555,15 @@ class GitHubAuthBackendTest(ZulipTestCase):
|
|||
|
||||
def test_github_oauth2_email_not_verified(self) -> None:
|
||||
account_data_dict = dict(email=self.email, name=self.name)
|
||||
email_data = [
|
||||
dict(email=account_data_dict["email"],
|
||||
verified=False,
|
||||
primary=True),
|
||||
]
|
||||
with mock.patch('logging.warning') as mock_warning:
|
||||
result = self.github_oauth2_test(account_data_dict,
|
||||
subdomain='zulip',
|
||||
email_not_verified=True)
|
||||
email_data=email_data)
|
||||
self.assertEqual(result.status_code, 302)
|
||||
self.assertEqual(result.url, "/login/")
|
||||
mock_warning.assert_called_once_with("Social auth (GitHub) failed "
|
||||
|
|
Loading…
Reference in New Issue