From cc8b9748a7c02c607c05efe37e0ce9267466a825 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 27 Jun 2021 00:46:00 +0200 Subject: [PATCH] Always request the 'sasl' cap before using AUTHENTICATE It's required by InspIRCd. This commit also adds a check so we don't forget it when testing locally only with Ergo. --- irctest/cases.py | 2 ++ irctest/server_tests/test_bouncer.py | 4 +++- irctest/server_tests/test_chathistory.py | 17 ++++++++++++++++- irctest/server_tests/test_confusables.py | 4 +++- irctest/server_tests/test_znc_playback.py | 7 +++++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/irctest/cases.py b/irctest/cases.py index 1c61dd7..122600b 100644 --- a/irctest/cases.py +++ b/irctest/cases.py @@ -595,6 +595,8 @@ class BaseServerTestCase( else: raise if password is not None: + if "sasl" not in (capabilities or ()): + raise ValueError("Used 'password' option without sasl capbilitiy") self.sendLine(client, "AUTHENTICATE PLAIN") m = self.getRegistrationMessage(client) self.assertMessageMatch(m, command="AUTHENTICATE", params=["+"]) diff --git a/irctest/server_tests/test_bouncer.py b/irctest/server_tests/test_bouncer.py index 44cfdaa..1fcea23 100644 --- a/irctest/server_tests/test_bouncer.py +++ b/irctest/server_tests/test_bouncer.py @@ -11,7 +11,9 @@ class Bouncer(cases.BaseServerTestCase): self.controller.registerUser(self, "observer", "observerpassword") self.controller.registerUser(self, "testuser", "mypassword") - self.connectClient("observer", password="observerpassword") + self.connectClient( + "observer", password="observerpassword", capabilities=["sasl"] + ) self.joinChannel(1, "#chan") self.sendLine(1, "CAP REQ :message-tags server-time") self.getMessages(1) diff --git a/irctest/server_tests/test_chathistory.py b/irctest/server_tests/test_chathistory.py index bbf821e..e97566f 100644 --- a/irctest/server_tests/test_chathistory.py +++ b/irctest/server_tests/test_chathistory.py @@ -50,6 +50,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "labeled-response", "message-tags", "server-time", + "sasl", CHATHISTORY_CAP, EVENT_PLAYBACK_CAP, ], @@ -86,7 +87,13 @@ class ChathistoryTestCase(cases.BaseServerTestCase): self.connectClient( bar, name=bar, - capabilities=["batch", "labeled-response", "message-tags", "server-time"], + capabilities=[ + "batch", + "labeled-response", + "message-tags", + "sasl", + "server-time", + ], password=pw, ) self.getMessages(bar) @@ -153,6 +160,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, EVENT_PLAYBACK_CAP, ], @@ -187,6 +195,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, EVENT_PLAYBACK_CAP, ], @@ -200,6 +209,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, EVENT_PLAYBACK_CAP, ], @@ -292,6 +302,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, EVENT_PLAYBACK_CAP, ], @@ -498,6 +509,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, EVENT_PLAYBACK_CAP, ], @@ -511,6 +523,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, ], password="sesame2", @@ -592,6 +605,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, EVENT_PLAYBACK_CAP, ], @@ -605,6 +619,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase): "echo-message", "batch", "labeled-response", + "sasl", CHATHISTORY_CAP, ], password="sesame2", diff --git a/irctest/server_tests/test_confusables.py b/irctest/server_tests/test_confusables.py index 490d3f2..faacc23 100644 --- a/irctest/server_tests/test_confusables.py +++ b/irctest/server_tests/test_confusables.py @@ -24,7 +24,9 @@ class ConfusablesTestCase(cases.BaseServerTestCase): self.assertNotIn(RPL_WELCOME, commands) self.assertIn(ERR_NICKNAMEINUSE, commands) - self.connectClient("evan", name="evan", password="sesame") + self.connectClient( + "evan", name="evan", password="sesame", capabilities=["sasl"] + ) # should be able to switch to the confusable nick self.sendLine("evan", "NICK еvan") messages = self.getMessages("evan") diff --git a/irctest/server_tests/test_znc_playback.py b/irctest/server_tests/test_znc_playback.py index cd137e3..bf3420b 100644 --- a/irctest/server_tests/test_znc_playback.py +++ b/irctest/server_tests/test_znc_playback.py @@ -34,6 +34,7 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase): "message-tags", "server-time", "echo-message", + "sasl", ], password=pw, ) @@ -49,6 +50,7 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase): "message-tags", "server-time", "echo-message", + "sasl", ], ) self.joinChannel(qux, chname) @@ -83,6 +85,7 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase): "message-tags", "server-time", "echo-message", + "sasl", ], password=pw, ) @@ -102,6 +105,7 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase): "message-tags", "server-time", "echo-message", + "sasl", ], password=pw, ) @@ -125,6 +129,7 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase): "message-tags", "server-time", "echo-message", + "sasl", ], password=pw, ) @@ -160,6 +165,7 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase): "message-tags", "server-time", "echo-message", + "sasl", ], password=pw, ) @@ -185,6 +191,7 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase): "message-tags", "server-time", "echo-message", + "sasl", ], password=pw, )