aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-06-20 14:15:34 +0200
committerGravatar kwzrd <[email protected]>2020-06-20 14:18:06 +0200
commitf240a970c6b97d201959d25a79a8babafed1c2b1 (patch)
treed34696bfd6b34ef0d71e635328262d64c2132754 /tests
parentIncidents: de-clyde archive webhook username (diff)
Incidents tests: assert webhook username is de-clyded
See: a8b4e394d9da57287cd9497cd9bb0a97fa467e84
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/moderation/test_incidents.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/bot/cogs/moderation/test_incidents.py b/tests/bot/cogs/moderation/test_incidents.py
index 9f0553216..2fc9180cf 100644
--- a/tests/bot/cogs/moderation/test_incidents.py
+++ b/tests/bot/cogs/moderation/test_incidents.py
@@ -319,6 +319,25 @@ class TestArchive(TestIncidents):
# Finally check that the method returned True
self.assertTrue(archive_return)
+ async def test_archive_clyde_username(self):
+ """
+ The archive webhook username is cleansed using `sub_clyde`.
+
+ Discord will reject any webhook with "clyde" in the username field, as it impersonates
+ the official Clyde bot. Since we do not control what the username will be (the incident
+ author name is used), we must ensure the name is cleansed, otherwise the relay may fail.
+
+ This test assumes the username is passed as a kwarg. If this test fails, please review
+ whether the passed argument is being retrieved correctly.
+ """
+ webhook = MockAsyncWebhook()
+ self.cog_instance.bot.fetch_webhook = AsyncMock(return_value=webhook)
+
+ message_from_clyde = MockMessage(author=MockUser(name="clyde the great"))
+ await self.cog_instance.archive(message_from_clyde, MagicMock(incidents.Signal))
+
+ self.assertNotIn("clyde", webhook.send.call_args.kwargs["username"])
+
class TestMakeConfirmationTask(TestIncidents):
"""