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.

tests: Verify logs of incoming webhook profile api key validation.

Mohit Guptac7a68216cdc7
diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py
index 7e666b0ddd6..56f94c6d18b 100644
--- a/zerver/tests/test_decorators.py
+++ b/zerver/tests/test_decorators.py
@@ -1341,9 +1341,12 @@ class TestValidateApiKey(ZulipTestCase):
self._change_is_active_field(self.default_bot, True)
def test_validate_api_key_if_profile_is_incoming_webhook_and_is_webhook_is_unset(self) -> None:
- with self.assertRaises(JsonableError):
+ with self.assertRaises(JsonableError), self.assertLogs(level="WARNING") as root_warn_log:
api_key = get_api_key(self.webhook_bot)
validate_api_key(HostRequestMock(), self.webhook_bot.email, api_key)
+ self.assertEqual(root_warn_log.output, [
+ 'WARNING:root:User [email protected] (zulip) attempted to access API on wrong subdomain ()'
+ ])
def test_validate_api_key_if_profile_is_incoming_webhook_and_is_webhook_is_set(self) -> None:
api_key = get_api_key(self.webhook_bot)