From ee6c56d84bdd3467795f97f1da2d697ad4999fbd Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 12 Feb 2024 23:29:23 -0500 Subject: [PATCH] basic 005 parameter validation test (#255) * basic 005 parameter validation test The overall order of the registration burst is covered by ConnectionRegistrationTestCase.testConnectionRegistration and doesn't need to be checked here. * Update irctest/server_tests/isupport.py Co-authored-by: Val Lorentz --------- Co-authored-by: Val Lorentz --- irctest/server_tests/isupport.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/irctest/server_tests/isupport.py b/irctest/server_tests/isupport.py index ae0ac18..1848098 100644 --- a/irctest/server_tests/isupport.py +++ b/irctest/server_tests/isupport.py @@ -9,6 +9,38 @@ from irctest import cases, runner class IsupportTestCase(cases.BaseServerTestCase): + @cases.mark_specifications("Modern") + @cases.mark_isupport("PREFIX") + def testParameters(self): + """https://modern.ircdocs.horse/#rplisupport-005""" + + # + # "Upon successful completion of the registration process, + # the server MUST send, in this order: + # [...] + # 5. at least one RPL_ISUPPORT (005) numeric to the client." + welcome_005s = [ + msg for msg in self.connectClient("foo") if msg.command == "005" + ] + self.assertGreaterEqual(len(welcome_005s), 1) + for msg in welcome_005s: + # first parameter is the client's nickname; + # last parameter is a human-readable trailing, typically + # "are supported by this server" + self.assertGreaterEqual(len(msg.params), 3) + self.assertEqual(msg.params[0], "foo") + # "As the maximum number of message parameters to any reply is 15, + # the maximum number of RPL_ISUPPORT tokens that can be advertised + # is 13." + self.assertLessEqual(len(msg.params), 15) + for param in msg.params[1:-1]: + self.validateIsupportParam(param) + + def validateIsupportParam(self, param): + if not param.isascii(): + raise ValueError("Invalid non-ASCII 005 parameter", param) + # TODO add more validation + @cases.mark_specifications("Modern") @cases.mark_isupport("PREFIX") def testPrefix(self):