channel key tests

This commit is contained in:
Shivaram Lingamneni
2020-05-18 03:56:36 -04:00
parent b208baaa11
commit 53f5ef711e
2 changed files with 32 additions and 1 deletions

View File

@ -163,6 +163,7 @@ ERR_CANNOTSENDRP = "573"
RPL_WHOISSECURE = "671"
RPL_YOURLANGUAGESARE = "687"
RPL_WHOISLANGUAGE = "690"
ERR_INVALIDMODEPARAM = "696"
RPL_HELPSTART = "704"
RPL_HELPTXT = "705"
RPL_ENDOFHELP = "706"

View File

@ -7,7 +7,7 @@ from irctest import cases
from irctest import client_mock
from irctest import runner
from irctest.irc_utils import ambiguities
from irctest.numerics import RPL_NOTOPIC, RPL_NAMREPLY, RPL_INVITING, ERR_NOSUCHCHANNEL, ERR_NOTONCHANNEL, ERR_CHANOPRIVSNEEDED, ERR_NOSUCHNICK, ERR_INVITEONLYCHAN, ERR_CANNOTSENDTOCHAN
from irctest.numerics import RPL_NOTOPIC, RPL_NAMREPLY, RPL_INVITING, ERR_NOSUCHCHANNEL, ERR_NOTONCHANNEL, ERR_CHANOPRIVSNEEDED, ERR_NOSUCHNICK, ERR_INVITEONLYCHAN, ERR_CANNOTSENDTOCHAN, ERR_BADCHANNELKEY, ERR_INVALIDMODEPARAM, ERR_UNKNOWNERROR
class JoinTestCase(cases.BaseServerTestCase):
@cases.SpecificationSelector.requiredBySpecification('RFC1459', 'RFC2812',
@ -674,3 +674,33 @@ class NoCTCPTestCase(cases.BaseServerTestCase):
self.assertMessageEqual(ms[0], command=ERR_CANNOTSENDTOCHAN)
ms = self.getMessages(2)
self.assertEqual(ms, [])
class KeyTestCase(cases.BaseServerTestCase):
@cases.SpecificationSelector.requiredBySpecification('RFC2812')
def testKeyNormal(self):
self.connectClient('bar')
self.joinChannel(1, '#chan')
self.sendLine(1, 'MODE #chan +k beer')
self.getMessages(1)
self.connectClient('qux')
self.getMessages(2)
self.sendLine(2, 'JOIN #chan')
reply = self.getMessages(2)
self.assertNotIn('JOIN', {msg.command for msg in reply})
self.assertIn(ERR_BADCHANNELKEY, {msg.command for msg in reply})
self.sendLine(2, 'JOIN #chan beer')
reply = self.getMessages(2)
self.assertMessageEqual(reply[0], command='JOIN', params=['#chan'])
@cases.SpecificationSelector.requiredBySpecification('Oragono')
def testKeyValidation(self):
# oragono issue #1021
self.connectClient('bar')
self.joinChannel(1, '#chan')
self.sendLine(1, 'MODE #chan +k :invalid channel passphrase')
reply = self.getMessages(1)
self.assertNotIn(ERR_UNKNOWNERROR, {msg.command for msg in reply})
self.assertIn(ERR_INVALIDMODEPARAM, {msg.command for msg in reply})