diff --git a/irctest/server_tests/join.py b/irctest/server_tests/join.py index 91efaae..9ccdeb3 100644 --- a/irctest/server_tests/join.py +++ b/irctest/server_tests/join.py @@ -200,3 +200,78 @@ class JoinTestCase(cases.BaseServerTestCase): fail_msg="Expected 1 error when joining channels '#valid' and 'inv@lid', " "got {got}", ) + + @cases.mark_specifications("RFC1459", "RFC2812", "Modern") + def testJoinKey(self): + """Joins a single channel with a key""" + self.connectClient("chanop") + self.joinChannel(1, "#chan") + self.sendLine(1, "MODE #chan +k key") + self.getMessages(1) + + self.connectClient("joiner") + self.sendLine(2, "JOIN #chan key") + self.assertMessageMatch( + self.getMessage(2), + command="JOIN", + params=["#chan"], + ) + + @cases.mark_specifications("RFC1459", "RFC2812", "Modern") + def testJoinKeys(self): + """Joins two channels, both with keys""" + self.connectClient("chanop") + if self.targmax.get("JOIN", "1000") == "1": + raise runner.OptionalExtensionNotSupported("Multi-target JOIN") + self.joinChannel(1, "#chan1") + self.sendLine(1, "MODE #chan1 +k key1") + self.getMessages(1) + self.joinChannel(1, "#chan2") + self.sendLine(1, "MODE #chan2 +k key2") + self.getMessages(1) + + self.connectClient("joiner") + self.sendLine(2, "JOIN #chan1,#chan2 key1,key2") + self.assertMessageMatch( + self.getMessage(2), + command="JOIN", + params=["#chan1"], + ) + self.assertMessageMatch( + [ + msg + for msg in self.getMessages(2) + if msg.command not in {RPL_NAMREPLY, RPL_ENDOFNAMES} + ][0], + command="JOIN", + params=["#chan2"], + ) + + @cases.mark_specifications("RFC1459", "RFC2812", "Modern") + def testJoinManySingleKey(self): + """Joins two channels, the first one has a key.""" + self.connectClient("chanop") + if self.targmax.get("JOIN", "1000") == "1": + raise runner.OptionalExtensionNotSupported("Multi-target JOIN") + self.joinChannel(1, "#chan1") + self.sendLine(1, "MODE #chan1 +k key1") + self.getMessages(1) + self.joinChannel(1, "#chan2") + self.getMessages(1) + + self.connectClient("joiner") + self.sendLine(2, "JOIN #chan1,#chan2 key1") + self.assertMessageMatch( + self.getMessage(2), + command="JOIN", + params=["#chan1"], + ) + self.assertMessageMatch( + [ + msg + for msg in self.getMessages(2) + if msg.command not in {RPL_NAMREPLY, RPL_ENDOFNAMES} + ][0], + command="JOIN", + params=["#chan2"], + )