diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index 1a77c6e1b9..ce6354c0d1 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -1474,13 +1474,13 @@ class SAMLAuthBackendTest(SocialAuthBase): result = self.client_get('/login/saml/') self.assertEqual(result.status_code, 302) self.assertEqual('/login/', result.url) - m.assert_called_with("/login/saml/ : Bad idp param.") + m.assert_called_with("/login/saml/ : Bad idp param: KeyError: 'idp'.") with mock.patch('zproject.backends.logging.info') as m: result = self.client_get('/login/saml/?idp=bad_idp') self.assertEqual(result.status_code, 302) self.assertEqual('/login/', result.url) - m.assert_called_with("/login/saml/ : Bad idp param.") + m.assert_called_with("/login/saml/ : Bad idp param: KeyError: 'bad_idp'.") def test_social_auth_invalid_email(self) -> None: """ diff --git a/zproject/backends.py b/zproject/backends.py index 771a21f980..fec47b1c19 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -1392,10 +1392,10 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth): try: idp_name = self.strategy.request_data()['idp'] auth = self._create_saml_auth(idp=self.get_idp(idp_name)) - except KeyError: + except KeyError as e: # If the above raise KeyError, it means invalid or no idp was specified, # we should log that and redirect to the login page. - logging.info("/login/saml/ : Bad idp param.") + logging.info("/login/saml/ : Bad idp param: KeyError: {}.".format(e)) return reverse('zerver.views.auth.login_page', kwargs = {'template_name': 'zerver/login.html'})