mirror of
https://github.com/progval/irctest.git
synced 2025-04-05 14:59:49 +00:00
add a test for MODE +i and RPL_WHOISCHANNELS
This commit is contained in:
60
irctest/server_tests/test_user_commands.py
Normal file
60
irctest/server_tests/test_user_commands.py
Normal file
@ -0,0 +1,60 @@
|
||||
"""
|
||||
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')
|
@ -8,6 +8,7 @@ class Specifications(enum.Enum):
|
||||
IRC301 = 'IRCv3.1'
|
||||
IRC302 = 'IRCv3.2'
|
||||
IRC302Deprecated = 'IRCv3.2-deprecated'
|
||||
Oragono = 'Oragono'
|
||||
|
||||
@classmethod
|
||||
def of_name(cls, name):
|
||||
|
Reference in New Issue
Block a user