Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

apple auth: Change logger to zulip.auth.apple from root logger.

palash485d740fe89e
diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py
index 3966c7d182a..f0d62699353 100644
--- a/zerver/tests/test_auth_backends.py
+++ b/zerver/tests/test_auth_backends.py
@@ -2310,24 +2310,24 @@ class AppleAuthBackendNativeFlowTest(AppleAuthMixin, SocialAuthBase):
result = self.client_get(url, **headers)
self.assertEqual(result.status_code, 302)
- with self.assertLogs(level='INFO') as info_log:
+ with self.assertLogs(self.logger_string, level='INFO') as info_log:
# Start Apple auth with mobile_flow_otp param. It should get saved into the session
# on SOCIAL_AUTH_SUBDOMAIN.
initiate_auth(mobile_flow_otp)
self.assertEqual(self.client.session['mobile_flow_otp'], mobile_flow_otp)
self.assertEqual(info_log.output, [
- 'INFO:root:/complete/apple/: Authentication failed: Token validation failed'
+ self.logger_output("/complete/apple/: Authentication failed: Token validation failed", "info")
])
- with self.assertLogs(level='INFO') as info_log:
+ with self.assertLogs(self.logger_string, level='INFO') as info_log:
# Make a request without mobile_flow_otp param and verify the field doesn't persist
# in the session from the previous request.
initiate_auth()
self.assertEqual(self.client.session.get('mobile_flow_otp'), None)
self.assertEqual(info_log.output, [
- 'INFO:root:/complete/apple/: Authentication failed: Token validation failed'
+ self.logger_output("/complete/apple/: Authentication failed: Token validation failed", "info")
])
def test_id_token_with_invalid_aud_sent(self) -> None:
@@ -2337,9 +2337,12 @@ class AppleAuthBackendNativeFlowTest(AppleAuthMixin, SocialAuthBase):
id_token=self.generate_id_token(account_data_dict, audience='com.different.app'),
)
- with self.apple_jwk_url_mock(), self.assertLogs(level='INFO') as m:
+ with self.apple_jwk_url_mock(), self.assertLogs(self.logger_string, level='INFO') as m:
result = self.client_get(url, **headers)
- self.assertEqual(m.output, ["INFO:root:/complete/apple/: {}".format("Authentication failed: Token validation failed")])
+
+ self.assertEqual(m.output, [
+ self.logger_output("/complete/apple/: Authentication failed: Token validation failed", "info")
+ ])
return result
def test_social_auth_desktop_success(self) -> None:
diff --git a/zproject/backends.py b/zproject/backends.py
index 8ee19e16a75..e87926e7197 100644
--- a/zproject/backends.py
+++ b/zproject/backends.py
@@ -1673,7 +1673,7 @@ class AppleAuthBackend(SocialAuthMixin, AppleIdAuth):
# though AuthFailed would have been more correct.
#
# We have an open PR to python-social-auth to clean this up.
- logging.info("/complete/apple/: %s", str(e))
+ self.logger.info("/complete/apple/: %s", str(e))
return None
@external_auth_method