From 100b53fb180d4dc90ef005e24e2c74178a919630 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 5 Mar 2021 00:04:49 -0500 Subject: [PATCH] test for Oragono disallowing truncation --- irctest/controllers/oragono.py | 3 +++ irctest/server_tests/test_messages.py | 31 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/irctest/controllers/oragono.py b/irctest/controllers/oragono.py index 55a2280..bfac124 100644 --- a/irctest/controllers/oragono.py +++ b/irctest/controllers/oragono.py @@ -39,6 +39,9 @@ BASE_CONFIG = { }, "enforce-utf8": True, "relaymsg": {"enabled": True, "separators": "/", "available-to-chanops": True}, + "compatibility": { + "allow-truncation": False, + }, }, "accounts": { "authentication-enabled": True, diff --git a/irctest/server_tests/test_messages.py b/irctest/server_tests/test_messages.py index 702277e..dd5eff9 100644 --- a/irctest/server_tests/test_messages.py +++ b/irctest/server_tests/test_messages.py @@ -79,3 +79,34 @@ class TagsTestCase(cases.BaseServerTestCase): self.sendLine(1, monsterMessage) replies = self.getMessages(1) self.assertIn(ERR_INPUTTOOLONG, set(reply.command for reply in replies)) + + +class LengthLimitTestCase(cases.BaseServerTestCase): + @cases.mark_specifications("Oragono") + def testLineAtLimit(self): + self.connectClient("bar", name="bar") + self.getMessages("bar") + line = "PING " + ("x" * (512 - 7)) + # this line is exactly as the limit, after including \r\n: + self.assertEqual(len(line), 510) + # oragono should accept and process this message. the outgoing PONG + # will be truncated due to the addition of the server name as source + # and initial parameter; this is fine: + self.sendLine("bar", line) + result = self.getMessage("bar", synchronize=False) + self.assertMessageMatch(result, command="PONG") + self.assertIn("x" * 450, result.params[-1]) + + @cases.mark_specifications("Oragono") + def testLineBeyondLimit(self): + self.connectClient("bar", name="bar") + self.getMessages("bar") + line = "PING " + ("x" * (512 - 6)) + # this line is one over the limit after including \r\n: + self.assertEqual(len(line), 511) + # oragono should reject this message for exceeding the length limit: + self.sendLine("bar", line) + result = self.getMessage("bar", synchronize=False) + self.assertMessageMatch(result, command=ERR_INPUTTOOLONG) + # we should not be disconnected and should be able to join a channel + self.joinChannel("bar", "#test_channel")