diff --git a/irctest/cases.py b/irctest/cases.py index 2e2cefb..1c61dd7 100644 --- a/irctest/cases.py +++ b/irctest/cases.py @@ -577,7 +577,9 @@ class BaseServerTestCase( Returns the list of all messages received after registration, just like `skipToWelcome`.""" client = self.addClient(name, show_io=show_io) - if capabilities is not None and 0 < len(capabilities): + if capabilities: + self.sendLine(client, "CAP LS 302") + m = self.getRegistrationMessage(client) self.sendLine(client, "CAP REQ :{}".format(" ".join(capabilities))) m = self.getRegistrationMessage(client) try: @@ -592,12 +594,18 @@ class BaseServerTestCase( raise runner.CapabilityNotSupported(" or ".join(capabilities)) else: raise - self.sendLine(client, "CAP END") if password is not None: self.sendLine(client, "AUTHENTICATE PLAIN") + m = self.getRegistrationMessage(client) + self.assertMessageMatch(m, command="AUTHENTICATE", params=["+"]) self.sendLine(client, sasl_plain_blob(account or nick, password)) + m = self.getRegistrationMessage(client) + self.assertIn(m.command, ["900", "903"], str(m)) + self.sendLine(client, "NICK {}".format(nick)) self.sendLine(client, "USER %s * * :Realname" % (ident,)) + if capabilities: + self.sendLine(client, "CAP END") welcome = self.skipToWelcome(client) self.sendLine(client, "PING foo") diff --git a/irctest/server_tests/test_account_tag.py b/irctest/server_tests/test_account_tag.py index 321783a..0e28d84 100644 --- a/irctest/server_tests/test_account_tag.py +++ b/irctest/server_tests/test_account_tag.py @@ -11,8 +11,16 @@ class AccountTagTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): self.sendLine(2, "CAP LS 302") capabilities = self.getCapLs(2) assert "sasl" in capabilities + + self.sendLine(2, "USER f * * :Realname") + self.sendLine(2, "NICK {}".format(nick)) + self.sendLine(2, "CAP REQ :sasl") + self.getRegistrationMessage(2) + self.sendLine(2, "AUTHENTICATE PLAIN") - m = self.getMessage(2, filter_pred=lambda m: m.command != "NOTICE") + m = self.getMessage( + 2, filter_pred=lambda m: m.command != "NOTICE", synchronize=False + ) self.assertMessageMatch( m, command="AUTHENTICATE", @@ -21,7 +29,9 @@ class AccountTagTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): "replied with “AUTHENTICATE +”, but instead sent: {msg}", ) self.sendLine(2, "AUTHENTICATE amlsbGVzAGppbGxlcwBzZXNhbWU=") - m = self.getMessage(2, filter_pred=lambda m: m.command != "NOTICE") + m = self.getMessage( + 2, filter_pred=lambda m: m.command != "NOTICE", synchronize=False + ) self.assertMessageMatch( m, command="900", diff --git a/irctest/server_tests/test_user_commands.py b/irctest/server_tests/test_user_commands.py index c913aa4..adac1f7 100644 --- a/irctest/server_tests/test_user_commands.py +++ b/irctest/server_tests/test_user_commands.py @@ -121,7 +121,9 @@ class WhoisTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): """ self.controller.registerUser(self, "shivaram", "sesame") - self.connectClient("netcat", account="shivaram", password="sesame") + self.connectClient( + "netcat", account="shivaram", password="sesame", capabilities=["sasl"] + ) self.getMessages(1) self.connectClient("curious") @@ -129,7 +131,7 @@ class WhoisTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): messages = self.getMessages(2) # 330 RPL_WHOISACCOUNT whoisaccount = [message for message in messages if message.command == "330"] - self.assertEqual(len(whoisaccount), 1) + self.assertEqual(len(whoisaccount), 1, messages) params = whoisaccount[0].params # : self.assertEqual(len(params), 4)