mirror of https://github.com/progval/irctest.git
Merge pull request #12 from slingamn/whoismodes.1
add a test for MODE +i and RPL_WHOISCHANNELS
This commit is contained in:
commit
b42bb1ade1
|
@ -154,3 +154,6 @@ ENV/
|
||||||
|
|
||||||
# Rope project settings
|
# Rope project settings
|
||||||
.ropeproject
|
.ropeproject
|
||||||
|
|
||||||
|
# vim swapfiles
|
||||||
|
*.swp
|
||||||
|
|
|
@ -70,6 +70,11 @@ limits:
|
||||||
linelen:
|
linelen:
|
||||||
tags: 2048
|
tags: 2048
|
||||||
rest: 2048
|
rest: 2048
|
||||||
|
|
||||||
|
history:
|
||||||
|
enabled: true
|
||||||
|
channel-length: 128
|
||||||
|
client-length: 128
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class OragonoController(BaseServerController, DirectoryBasedController):
|
class OragonoController(BaseServerController, DirectoryBasedController):
|
||||||
|
|
|
@ -487,3 +487,35 @@ class testChannelCaseSensitivity(cases.BaseServerTestCase):
|
||||||
testRfcSimpleNotEquivalent = _testChannelsNotEquivalent('rfc1459', '#Foo', '#fooa')
|
testRfcSimpleNotEquivalent = _testChannelsNotEquivalent('rfc1459', '#Foo', '#fooa')
|
||||||
testRfcFancyEquivalent = _testChannelsEquivalent('rfc1459', '#F]|oo{', '#f}\\oo[')
|
testRfcFancyEquivalent = _testChannelsEquivalent('rfc1459', '#F]|oo{', '#f}\\oo[')
|
||||||
testRfcFancyNotEquivalent = _testChannelsEquivalent('rfc1459', '#F}o\\o[', '#f]o|o{')
|
testRfcFancyNotEquivalent = _testChannelsEquivalent('rfc1459', '#F}o\\o[', '#f]o|o{')
|
||||||
|
|
||||||
|
|
||||||
|
class InviteTestCase(cases.BaseServerTestCase):
|
||||||
|
|
||||||
|
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
|
||||||
|
def testInvites(self):
|
||||||
|
"""Test some basic functionality related to INVITE and the +i mode."""
|
||||||
|
self.connectClient('foo')
|
||||||
|
self.joinChannel(1, '#chan')
|
||||||
|
self.sendLine(1, 'MODE #chan +i')
|
||||||
|
self.getMessages(1)
|
||||||
|
self.sendLine(1, 'INVITE bar #chan')
|
||||||
|
m = self.getMessage(1)
|
||||||
|
self.assertEqual(m.command, '401') # ERR_NOSUCHNICK
|
||||||
|
|
||||||
|
self.connectClient('bar')
|
||||||
|
self.sendLine(2, 'JOIN #chan')
|
||||||
|
m = self.getMessage(2)
|
||||||
|
self.assertEqual(m.command, '473') # ERR_INVITEONLYCHAN
|
||||||
|
|
||||||
|
self.sendLine(1, 'INVITE bar #chan')
|
||||||
|
m = self.getMessage(1)
|
||||||
|
self.assertEqual(m.command, '341') # RPL_INVITING
|
||||||
|
# modern/ircv3 param order: inviter, invitee, channel
|
||||||
|
self.assertEqual(m.params, ['foo', 'bar', '#chan'])
|
||||||
|
m = self.getMessage(2)
|
||||||
|
self.assertEqual(m.command, 'INVITE')
|
||||||
|
self.assertTrue(m.prefix.startswith("foo")) # nickmask of inviter
|
||||||
|
self.assertEqual(m.params, ['bar', '#chan'])
|
||||||
|
|
||||||
|
# we were invited, so join should succeed now
|
||||||
|
self.joinChannel(2, '#chan')
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
"""
|
||||||
|
User commands as specified in Section 3.6 of RFC 2812:
|
||||||
|
<https://tools.ietf.org/html/rfc2812#section-3.6>
|
||||||
|
"""
|
||||||
|
|
||||||
|
from irctest import cases
|
||||||
|
|
||||||
|
RPL_WHOISCHANNELS = '319'
|
||||||
|
|
||||||
|
class InvisibleTestCase(cases.BaseServerTestCase):
|
||||||
|
|
||||||
|
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||||
|
def testInvisibleWhois(self):
|
||||||
|
"""Test interaction between MODE +i and RPL_WHOISCHANNELS."""
|
||||||
|
self.connectClient('userOne')
|
||||||
|
self.sendLine(1, 'JOIN #xyz')
|
||||||
|
|
||||||
|
self.connectClient('userTwo')
|
||||||
|
self.getMessages(2)
|
||||||
|
self.sendLine(2, 'WHOIS userOne')
|
||||||
|
commands = {m.command for m in self.getMessages(2)}
|
||||||
|
self.assertIn(RPL_WHOISCHANNELS, commands,
|
||||||
|
'RPL_WHOISCHANNELS should be sent for a non-invisible nick')
|
||||||
|
|
||||||
|
self.getMessages(1)
|
||||||
|
self.sendLine(1, 'MODE userOne +i')
|
||||||
|
message = self.getMessage(1)
|
||||||
|
self.assertEqual(message.command, 'MODE',
|
||||||
|
'Expected MODE reply, but received {}'.format(message.command))
|
||||||
|
self.assertEqual(message.params, ['userOne', '+i'],
|
||||||
|
'Expected user set +i, but received {}'.format(message.params))
|
||||||
|
|
||||||
|
self.getMessages(2)
|
||||||
|
self.sendLine(2, 'WHOIS userOne')
|
||||||
|
commands = {m.command for m in self.getMessages(2)}
|
||||||
|
self.assertNotIn(RPL_WHOISCHANNELS, commands,
|
||||||
|
'RPL_WHOISCHANNELS should not be sent for an invisible nick'
|
||||||
|
'unless the user is also a member of the channel')
|
||||||
|
|
||||||
|
self.sendLine(2, 'JOIN #xyz')
|
||||||
|
self.sendLine(2, 'WHOIS userOne')
|
||||||
|
commands = {m.command for m in self.getMessages(2)}
|
||||||
|
self.assertIn(RPL_WHOISCHANNELS, commands,
|
||||||
|
'RPL_WHOISCHANNELS should be sent for an invisible nick'
|
||||||
|
'if the user is also a member of the channel')
|
||||||
|
|
||||||
|
self.sendLine(2, 'PART #xyz')
|
||||||
|
self.getMessages(2)
|
||||||
|
self.getMessages(1)
|
||||||
|
self.sendLine(1, 'MODE userOne -i')
|
||||||
|
message = self.getMessage(1)
|
||||||
|
self.assertEqual(message.command, 'MODE',
|
||||||
|
'Expected MODE reply, but received {}'.format(message.command))
|
||||||
|
self.assertEqual(message.params, ['userOne', '-i'],
|
||||||
|
'Expected user set -i, but received {}'.format(message.params))
|
||||||
|
|
||||||
|
self.sendLine(2, 'WHOIS userOne')
|
||||||
|
commands = {m.command for m in self.getMessages(2)}
|
||||||
|
self.assertIn(RPL_WHOISCHANNELS, commands,
|
||||||
|
'RPL_WHOISCHANNELS should be sent for a non-invisible nick')
|
||||||
|
|
||||||
|
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||||
|
def testWhoisAccount(self):
|
||||||
|
"""Test numeric 330, RPL_WHOISACCOUNT."""
|
||||||
|
self.controller.registerUser(self, 'shivaram', 'sesame')
|
||||||
|
self.connectClient('netcat')
|
||||||
|
self.sendLine(1, 'NS IDENTIFY shivaram sesame')
|
||||||
|
self.getMessages(1)
|
||||||
|
|
||||||
|
self.connectClient('curious')
|
||||||
|
self.sendLine(2, 'WHOIS netcat')
|
||||||
|
messages = self.getMessages(2)
|
||||||
|
# 330 RPL_WHOISACCOUNT
|
||||||
|
whoisaccount = [message for message in messages if message.command == '330']
|
||||||
|
self.assertEqual(len(whoisaccount), 1)
|
||||||
|
params = whoisaccount[0].params
|
||||||
|
# <client> <nick> <authname> :<info>
|
||||||
|
self.assertEqual(len(params), 4)
|
||||||
|
self.assertEqual(params[:3], ['curious', 'netcat', 'shivaram'])
|
||||||
|
|
||||||
|
self.sendLine(1, 'WHOIS curious')
|
||||||
|
messages = self.getMessages(2)
|
||||||
|
whoisaccount = [message for message in messages if message.command == '330']
|
||||||
|
self.assertEqual(len(whoisaccount), 0)
|
|
@ -8,6 +8,7 @@ class Specifications(enum.Enum):
|
||||||
IRC301 = 'IRCv3.1'
|
IRC301 = 'IRCv3.1'
|
||||||
IRC302 = 'IRCv3.2'
|
IRC302 = 'IRCv3.2'
|
||||||
IRC302Deprecated = 'IRCv3.2-deprecated'
|
IRC302Deprecated = 'IRCv3.2-deprecated'
|
||||||
|
Oragono = 'Oragono'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def of_name(cls, name):
|
def of_name(cls, name):
|
||||||
|
|
Loading…
Reference in New Issue