mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 07:19:54 +00:00
Add tests for extended-join.
This commit is contained in:
@ -308,15 +308,23 @@ class BaseServerTestCase(_IrcTestCase):
|
||||
m = self.getMessage(client, synchronize=False)
|
||||
if m.command == '001':
|
||||
return m
|
||||
def connectClient(self, nick, name=None, capabilities=None):
|
||||
def connectClient(self, nick, name=None, capabilities=None,
|
||||
skip_if_cap_nak=False):
|
||||
client = self.addClient(name)
|
||||
if capabilities is not None:
|
||||
self.sendLine(client, 'CAP REQ :{}'.format(' '.join(capabilities)))
|
||||
m = self.getRegistrationMessage(client)
|
||||
self.assertMessageEqual(m, command='CAP',
|
||||
fail_msg='Expected CAP ACK, got: {msg}')
|
||||
self.assertEqual(m.params[1], 'ACK', m,
|
||||
fail_msg='Expected CAP ACK, got: {msg}')
|
||||
try:
|
||||
self.assertMessageEqual(m, command='CAP',
|
||||
fail_msg='Expected CAP ACK, got: {msg}')
|
||||
self.assertEqual(m.params[1], 'ACK', m,
|
||||
fail_msg='Expected CAP ACK, got: {msg}')
|
||||
except AssertionError:
|
||||
if skip_if_cap_nak:
|
||||
raise runner.NotImplementedByController(
|
||||
', '.join(capabilities))
|
||||
else:
|
||||
raise
|
||||
self.sendLine(client, 'CAP END')
|
||||
self.sendLine(client, 'NICK {}'.format(nick))
|
||||
self.sendLine(client, 'USER username * * :Realname')
|
||||
|
@ -21,7 +21,7 @@ class AccountTagTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
m = self.getMessage(2, filter_pred=lambda m:m.command != 'NOTICE')
|
||||
self.assertMessageEqual(m, command='900',
|
||||
fail_msg='Did not send 900 after correct SASL authentication.')
|
||||
self.sendLine(2, 'USER f * * :*')
|
||||
self.sendLine(2, 'USER f * * :Realname')
|
||||
self.sendLine(2, 'NICK {}'.format(nick))
|
||||
self.sendLine(2, 'CAP END')
|
||||
self.skipToWelcome(2)
|
||||
@ -29,10 +29,8 @@ class AccountTagTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testPrivmsg(self):
|
||||
try:
|
||||
self.connectClient('foo', capabilities=['account-tag'])
|
||||
except AssertionError:
|
||||
raise NotImplementedByController('account-tag')
|
||||
self.connectClient('foo', capabilities=['account-tag'],
|
||||
skip_if_cap_nak=True)
|
||||
self.getMessages(1)
|
||||
self.controller.registerUser(self, 'jilles', 'sesame')
|
||||
self.connectRegisteredClient('bar')
|
||||
@ -54,10 +52,8 @@ class AccountTagTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testMonitor(self):
|
||||
try:
|
||||
self.connectClient('foo', capabilities=['account-tag'])
|
||||
except AssertionError:
|
||||
raise NotImplementedByController('account-tag')
|
||||
self.connectClient('foo', capabilities=['account-tag'],
|
||||
skip_if_cap_nak=True)
|
||||
if 'MONITOR' not in self.server_support:
|
||||
raise NotImplementedByController('MONITOR')
|
||||
self.sendLine(1, 'MONITOR + bar')
|
||||
|
58
irctest/server_tests/test_extended_join.py
Normal file
58
irctest/server_tests/test_extended_join.py
Normal file
@ -0,0 +1,58 @@
|
||||
"""
|
||||
<http://ircv3.net/specs/extensions/extended-join-3.1.html>
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
from irctest.irc_utils.message_parser import Message
|
||||
|
||||
class MetadataTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
def connectRegisteredClient(self, nick):
|
||||
self.addClient()
|
||||
self.sendLine(2, 'CAP LS 302')
|
||||
capabilities = self.getCapLs(2)
|
||||
assert 'sasl' in capabilities
|
||||
self.sendLine(2, 'AUTHENTICATE PLAIN')
|
||||
m = self.getMessage(2, filter_pred=lambda m:m.command != 'NOTICE')
|
||||
self.assertMessageEqual(m, command='AUTHENTICATE', params=['+'],
|
||||
fail_msg='Sent “AUTHENTICATE PLAIN”, server should have '
|
||||
'replied with “AUTHENTICATE +”, but instead sent: {msg}')
|
||||
self.sendLine(2, 'AUTHENTICATE amlsbGVzAGppbGxlcwBzZXNhbWU=')
|
||||
m = self.getMessage(2, filter_pred=lambda m:m.command != 'NOTICE')
|
||||
self.assertMessageEqual(m, command='900',
|
||||
fail_msg='Did not send 900 after correct SASL authentication.')
|
||||
self.sendLine(2, 'USER f * * :Realname')
|
||||
self.sendLine(2, 'NICK {}'.format(nick))
|
||||
self.sendLine(2, 'CAP END')
|
||||
self.skipToWelcome(2)
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('IRCv3.1')
|
||||
def testNotLoggedIn(self):
|
||||
self.connectClient('foo', capabilities=['extended-join'],
|
||||
skip_if_cap_nak=True)
|
||||
self.sendLine(1, 'JOIN #chan')
|
||||
self.getMessages(1)
|
||||
self.connectClient('bar')
|
||||
self.sendLine(2, 'JOIN #chan')
|
||||
m = self.getMessage(1)
|
||||
self.assertMessageEqual(m, command='JOIN',
|
||||
params=['#chan', '*', 'Realname'],
|
||||
fail_msg='Expected “JOIN #chan * :Realname” after '
|
||||
'unregistered user joined, got: {msg}')
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('IRCv3.1')
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testNotLoggedIn(self):
|
||||
self.connectClient('foo', capabilities=['extended-join'],
|
||||
skip_if_cap_nak=True)
|
||||
self.sendLine(1, 'JOIN #chan')
|
||||
self.getMessages(1)
|
||||
|
||||
self.controller.registerUser(self, 'jilles', 'sesame')
|
||||
self.connectRegisteredClient('bar')
|
||||
|
||||
self.sendLine(2, 'JOIN #chan')
|
||||
m = self.getMessage(1)
|
||||
self.assertMessageEqual(m, command='JOIN',
|
||||
params=['#chan', 'jilles', 'Realname'],
|
||||
fail_msg='Expected “JOIN #chan * :Realname” after '
|
||||
'nick “bar” logged in as “jilles” joined, got: {msg}')
|
Reference in New Issue
Block a user