From eb46c3972327a2a25e386b10f3a2745355aa1e06 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 24 Dec 2015 01:12:50 +0100 Subject: [PATCH] Add tests for IRCv3.1 CAP LS/LIST. --- .../test_connection_registration.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/irctest/server_tests/test_connection_registration.py b/irctest/server_tests/test_connection_registration.py index 765ee32..a719768 100644 --- a/irctest/server_tests/test_connection_registration.py +++ b/irctest/server_tests/test_connection_registration.py @@ -108,3 +108,37 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase): self.assertNotEqual((m1.command, m2.command), ('001', '001'), 'Two concurrently registering requesting the same nickname ' 'both got 001.') + + @cases.SpecificationSelector.requiredBySpecification('IRCv3.1', 'IRCv3.2') + def testIrc301CapLs(self): + """IRCv3.1: “The LS subcommand is used to list the capabilities + supported by the server. The client should send an LS subcommand with + no other arguments to solicit a list of all capabilities.” + -- + + IRCv3.2: “Servers MUST NOT send messages described by this document if + the client only supports version 3.1.” + -- + """ + self.addClient() + self.sendLine(1, 'CAP LS') + m = self.getRegistrationMessage(1) + self.assertNotEqual(m.params[2], '*', m, + fail_msg='Server replied with multi-line CAP LS to a ' + '“CAP LS” (ie. IRCv3.1) request: {msg}') + self.assertFalse(any('=' in cap for cap in m.params[2].split()), + 'Server replied with a name-value capability in ' + 'CAP LS reply as a response to “CAP LS” (ie. IRCv3.1) ' + 'request: {}'.format(m)) + + @cases.SpecificationSelector.requiredBySpecification('IRCv3.1') + def testEmptyCapList(self): + """“If no capabilities are active, an empty parameter must be sent.” + -- + """ + self.addClient() + self.sendLine(1, 'CAP LIST') + m = self.getRegistrationMessage(1) + self.assertMessageEqual(m, command='CAP', params=['*', 'LIST', ''], + fail_msg='Sending “CAP LIST” as first message got a reply ' + 'that is not “CAP * LIST :”: {msg}')