test_settings: Verify logs of domain mismatch in password change test.

Use assertLogs for verifying debug log produced due to LDAP domain
mismatch while changing password. This will avoid spam in test-backend
output.
This commit is contained in:
Mohit Gupta 2020-07-27 05:23:33 +05:30 committed by Tim Abbott
parent dbbacdd3d9
commit 1668c7395e
1 changed files with 5 additions and 1 deletions

View File

@ -285,7 +285,8 @@ class ChangeSettingsTest(ZulipTestCase):
self.assert_json_error(result, "Your Zulip password is managed in LDAP") self.assert_json_error(result, "Your Zulip password is managed in LDAP")
with self.settings(LDAP_APPEND_DOMAIN="example.com", with self.settings(LDAP_APPEND_DOMAIN="example.com",
AUTH_LDAP_USER_ATTR_MAP=ldap_user_attr_map): AUTH_LDAP_USER_ATTR_MAP=ldap_user_attr_map), \
self.assertLogs('zulip.ldap', 'DEBUG') as debug_log:
result = self.client_patch( result = self.client_patch(
"/json/settings", "/json/settings",
dict( dict(
@ -293,6 +294,9 @@ class ChangeSettingsTest(ZulipTestCase):
new_password="ignored", new_password="ignored",
)) ))
self.assert_json_success(result) self.assert_json_success(result)
self.assertEqual(debug_log.output, [
'DEBUG:zulip.ldap:ZulipLDAPAuthBackend: Email hamlet@zulip.com does not match LDAP domain example.com.'
])
with self.settings(LDAP_APPEND_DOMAIN=None, with self.settings(LDAP_APPEND_DOMAIN=None,
AUTH_LDAP_USER_ATTR_MAP=ldap_user_attr_map): AUTH_LDAP_USER_ATTR_MAP=ldap_user_attr_map):