From 7fe52bbb9edce231e1adea149d261057d8165cef Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Sat, 20 Jun 2020 13:55:12 +0200 Subject: [PATCH] tests: Clean up the subdomain argument to social_auth_test. subdomain=None didn't make much sense as a value, and wasn't actually in use anywhere, except one test where it was accidental. All tests specify the subdomain explicitly, so we should change the type to str, and make it an obligatory kwarg. --- zerver/tests/test_auth_backends.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index 92350d7432..5881f2bd05 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -722,7 +722,7 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase): def prepare_login_url_and_headers( self, - subdomain: Optional[str]=None, + subdomain: str, mobile_flow_otp: Optional[str]=None, desktop_flow_otp: Optional[str]=None, is_signup: bool=False, @@ -738,13 +738,12 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase): params = {} headers = {} - if subdomain is not None: - if subdomain == '': - # "testserver" may trip up some libraries' URL validation, - # so let's use the equivalent www. version. - headers['HTTP_HOST'] = 'www.testserver' - else: - headers['HTTP_HOST'] = subdomain + ".testserver" + if subdomain == '': + # "testserver" may trip up some libraries' URL validation, + # so let's use the equivalent www. version. + headers['HTTP_HOST'] = 'www.testserver' + else: + headers['HTTP_HOST'] = subdomain + ".testserver" if mobile_flow_otp is not None: params['mobile_flow_otp'] = mobile_flow_otp headers['HTTP_USER_AGENT'] = "ZulipAndroid" @@ -778,7 +777,7 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase): }) def social_auth_test(self, account_data_dict: Dict[str, str], - *, subdomain: Optional[str]=None, + *, subdomain: str, mobile_flow_otp: Optional[str]=None, desktop_flow_otp: Optional[str]=None, is_signup: bool=False, @@ -1456,7 +1455,7 @@ class SAMLAuthBackendTest(SocialAuthBase): # We have to define our own social_auth_test as the flow of SAML authentication # is different from the other social backends. def social_auth_test(self, account_data_dict: Dict[str, str], - *, subdomain: Optional[str]=None, + *, subdomain: str, mobile_flow_otp: Optional[str]=None, desktop_flow_otp: Optional[str]=None, is_signup: bool=False, @@ -2161,7 +2160,7 @@ class AppleAuthBackendNativeFlowTest(AppleAuthMixin, SocialAuthBase): def prepare_login_url_and_headers( self, - subdomain: Optional[str]=None, + subdomain: str, mobile_flow_otp: Optional[str]=None, desktop_flow_otp: Optional[str]=None, is_signup: bool=False, @@ -2193,7 +2192,7 @@ class AppleAuthBackendNativeFlowTest(AppleAuthMixin, SocialAuthBase): return url, headers def social_auth_test(self, account_data_dict: Dict[str, str], - *, subdomain: Optional[str]=None, + *, subdomain: str, mobile_flow_otp: Optional[str]=None, desktop_flow_otp: Optional[str]=None, is_signup: bool=False, @@ -2625,6 +2624,7 @@ class GitHubAuthBackendTest(SocialAuthBase): result = self.social_auth_test(account_data_dict, email_data=email_data, is_signup=True, + subdomain='zulip', expect_choose_email_screen=True, next='/user_uploads/image') data = load_subdomain_token(result)