From d86a5dfb5b38a9a71feffea07aad296406ba1161 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 2 Sep 2023 12:17:50 +0200 Subject: [PATCH] avoid implicit cap-notify + switch from server-time to multi-prefix as it's better supported + ignore Unreal --- irctest/server_tests/cap.py | 96 ++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 34 deletions(-) diff --git a/irctest/server_tests/cap.py b/irctest/server_tests/cap.py index 05892897..41d46435 100644 --- a/irctest/server_tests/cap.py +++ b/irctest/server_tests/cap.py @@ -20,7 +20,7 @@ def testInvalidCapSubcommand(self): m = self.getRegistrationMessage(1) self.assertTrue( self.messageDiffers(m, command="PONG", params=[ANYSTR, "test123"]), - "Sending “CAP NOTACOMMAND” as first message got no reply" + "Sending “CAP NOTACOMMAND” as first message got no reply", ) self.assertMessageMatch( m, @@ -56,18 +56,24 @@ def testNoReq(self): ) @cases.mark_specifications("IRCv3") + @cases.xfailIfSoftware( + ["UnrealIRCd"], + "UnrealIRCd sends a trailing space on CAP ACK: https://github.com/unrealircd/unrealircd/pull/148", + ) def testReqOne(self): """Tests requesting a single capability""" self.addClient(1) - self.sendLine(1, "CAP LS 302") + self.sendLine(1, "CAP LS") self.getCapLs(1) self.sendLine(1, "USER foo foo foo :foo") self.sendLine(1, "NICK foo") - self.sendLine(1, "CAP REQ :server-time") + self.sendLine(1, "CAP REQ :multi-prefix") m = self.getRegistrationMessage(1) self.assertMessageMatch( - m, command="CAP", params=[ANYSTR, "ACK", "server-time"], - fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}." + m, + command="CAP", + params=[ANYSTR, "ACK", "multi-prefix"], + fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}.", ) self.sendLine(1, "CAP LIST") @@ -75,8 +81,8 @@ def testReqOne(self): self.assertMessageMatch( m, command="CAP", - params=[ANYSTR, "LIST", "server-time"], - fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}." + params=[ANYSTR, "LIST", "multi-prefix"], + fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}.", ) self.sendLine(1, "CAP END") @@ -86,18 +92,24 @@ def testReqOne(self): ) @cases.mark_specifications("IRCv3") + @cases.xfailIfSoftware( + ["UnrealIRCd"], + "UnrealIRCd sends a trailing space on CAP ACK: https://github.com/unrealircd/unrealircd/pull/148", + ) def testReqTwo(self): """Tests requesting two capabilities at once""" self.addClient(1) - self.sendLine(1, "CAP LS 302") + self.sendLine(1, "CAP LS") self.getCapLs(1) self.sendLine(1, "USER foo foo foo :foo") self.sendLine(1, "NICK foo") - self.sendLine(1, "CAP REQ :server-time userhost-in-names") + self.sendLine(1, "CAP REQ :multi-prefix userhost-in-names") m = self.getRegistrationMessage(1) self.assertMessageMatch( - m, command="CAP", params=[ANYSTR, "ACK", "server-time userhost-in-names"], - fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}." + m, + command="CAP", + params=[ANYSTR, "ACK", "multi-prefix userhost-in-names"], + fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}.", ) self.sendLine(1, "CAP LIST") @@ -105,8 +117,8 @@ def testReqTwo(self): self.assertMessageMatch( m, command="CAP", - params=[ANYSTR, "LIST", "server-time userhost-in-names"], - fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}." + params=[ANYSTR, "LIST", "multi-prefix userhost-in-names"], + fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}.", ) self.sendLine(1, "CAP END") @@ -116,26 +128,34 @@ def testReqTwo(self): ) @cases.mark_specifications("IRCv3") + @cases.xfailIfSoftware( + ["UnrealIRCd"], + "UnrealIRCd sends a trailing space on CAP ACK: https://github.com/unrealircd/unrealircd/pull/148", + ) def testReqOneThenOne(self): """Tests requesting two capabilities in different messages""" self.addClient(1) - self.sendLine(1, "CAP LS 302") + self.sendLine(1, "CAP LS") self.getCapLs(1) self.sendLine(1, "USER foo foo foo :foo") self.sendLine(1, "NICK foo") - self.sendLine(1, "CAP REQ :server-time") + self.sendLine(1, "CAP REQ :multi-prefix") m = self.getRegistrationMessage(1) self.assertMessageMatch( - m, command="CAP", params=[ANYSTR, "ACK", "server-time"], - fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}." + m, + command="CAP", + params=[ANYSTR, "ACK", "multi-prefix"], + fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}.", ) self.sendLine(1, "CAP REQ :userhost-in-names") m = self.getRegistrationMessage(1) self.assertMessageMatch( - m, command="CAP", params=[ANYSTR, "ACK", "userhost-in-names"], - fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}." + m, + command="CAP", + params=[ANYSTR, "ACK", "userhost-in-names"], + fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}.", ) self.sendLine(1, "CAP LIST") @@ -143,8 +163,8 @@ def testReqOneThenOne(self): self.assertMessageMatch( m, command="CAP", - params=[ANYSTR, "LIST", "server-time userhost-in-names"], - fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}." + params=[ANYSTR, "LIST", "multi-prefix userhost-in-names"], + fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}.", ) self.sendLine(1, "CAP END") @@ -154,19 +174,25 @@ def testReqOneThenOne(self): ) @cases.mark_specifications("IRCv3") + @cases.xfailIfSoftware( + ["UnrealIRCd"], + "UnrealIRCd sends a trailing space on CAP ACK: https://github.com/unrealircd/unrealircd/pull/148", + ) def testReqPostRegistration(self): """Tests requesting more capabilities after CAP END""" self.addClient(1) - self.sendLine(1, "CAP LS 302") + self.sendLine(1, "CAP LS") self.getCapLs(1) self.sendLine(1, "USER foo foo foo :foo") self.sendLine(1, "NICK foo") - self.sendLine(1, "CAP REQ :server-time") + self.sendLine(1, "CAP REQ :multi-prefix") m = self.getRegistrationMessage(1) self.assertMessageMatch( - m, command="CAP", params=[ANYSTR, "ACK", "server-time"], - fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}." + m, + command="CAP", + params=[ANYSTR, "ACK", "multi-prefix"], + fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}.", ) self.sendLine(1, "CAP LIST") @@ -174,8 +200,8 @@ def testReqPostRegistration(self): self.assertMessageMatch( m, command="CAP", - params=[ANYSTR, "LIST", "server-time"], - fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}." + params=[ANYSTR, "LIST", "multi-prefix"], + fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}.", ) self.sendLine(1, "CAP END") @@ -189,8 +215,10 @@ def testReqPostRegistration(self): self.sendLine(1, "CAP REQ :userhost-in-names") m = self.getRegistrationMessage(1) self.assertMessageMatch( - m, command="CAP", params=[ANYSTR, "ACK", "userhost-in-names"], - fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}." + m, + command="CAP", + params=[ANYSTR, "ACK", "userhost-in-names"], + fail_msg="Expected CAP ACK after sending CAP REQ, got {msg}.", ) self.sendLine(1, "CAP LIST") @@ -198,8 +226,8 @@ def testReqPostRegistration(self): self.assertMessageMatch( m, command="CAP", - params=[ANYSTR, "LIST", "server-time userhost-in-names"], - fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}." + params=[ANYSTR, "LIST", "multi-prefix userhost-in-names"], + fail_msg="Expected CAP LIST after sending CAP LIST, got {msg}.", ) @cases.mark_specifications("IRCv3") @@ -309,7 +337,7 @@ def testNakWhole(self): def testCapRemovalByClient(self): """Test CAP LIST and removal of caps via CAP REQ :-tagname.""" cap1 = "echo-message" - cap2 = "server-time" + cap2 = "multi-prefix" self.addClient(1) self.connectClient("sender") self.sendLine(1, "CAP LS 302") @@ -340,7 +368,7 @@ def testCapRemovalByClient(self): m = self.getMessage(1) self.assertIn("time", m.tags, m) - # remove the server-time cap + # remove the multi-prefix cap self.sendLine(1, f"CAP REQ :-{cap2}") m = self.getMessage(1) # Must be either ACK or NAK @@ -350,7 +378,7 @@ def testCapRemovalByClient(self): ) raise ImplementationChoice(f"Does not support CAP REQ -{cap2}") - # server-time should be disabled + # multi-prefix should be disabled self.sendLine(1, "CAP LIST") messages = self.getMessages(1) cap_list = [m for m in messages if m.command == "CAP"][0]