mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 23:39:46 +00:00
Add quotes from specifications to test descriptions.
This commit is contained in:
@ -29,7 +29,10 @@ def main(args):
|
||||
_IrcTestCase.controllerClass = controller_class
|
||||
_IrcTestCase.show_io = args.show_io
|
||||
ts = module.discover()
|
||||
testRunner = OptionalityReportingTextTestRunner(verbosity=args.verbose)
|
||||
testRunner = OptionalityReportingTextTestRunner(
|
||||
verbosity=args.verbose,
|
||||
descriptions=True,
|
||||
)
|
||||
testLoader = unittest.loader.defaultTestLoader
|
||||
testRunner.run(ts)
|
||||
|
||||
|
@ -4,6 +4,8 @@ import unittest
|
||||
import functools
|
||||
import collections
|
||||
|
||||
import supybot.utils
|
||||
|
||||
from . import authentication
|
||||
from . import optional_extensions
|
||||
from .irc_utils import message_parser
|
||||
@ -18,6 +20,15 @@ class _IrcTestCase(unittest.TestCase):
|
||||
"""Base class for test cases."""
|
||||
controllerClass = None # Will be set by __main__.py
|
||||
|
||||
def shortDescription(self):
|
||||
method_doc = self._testMethodDoc
|
||||
if not method_doc:
|
||||
return ''
|
||||
return '\t'+supybot.utils.str.normalizeWhitespace(
|
||||
method_doc,
|
||||
removeNewline=False,
|
||||
).strip().replace('\n ', '\n\t')
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.controller = self.controllerClass()
|
||||
|
@ -3,8 +3,10 @@ from irctest.irc_utils.message_parser import Message
|
||||
|
||||
class CapTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
def testSendCap(self):
|
||||
"""Send CAP LS 302 and read the result."""
|
||||
self.readCapLs()
|
||||
|
||||
def testEmptyCapLs(self):
|
||||
"""Empty result to CAP LS. Client should send CAP END."""
|
||||
m = self.negotiateCapabilities([])
|
||||
self.assertEqual(m, Message([], None, 'CAP', ['END']))
|
||||
|
@ -19,7 +19,7 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
|
||||
cases.OptionalityHelper):
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testPlain(self):
|
||||
"""Test PLAIN authentication."""
|
||||
"""Test PLAIN authentication with correct username/password."""
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.plain],
|
||||
username='jilles',
|
||||
@ -38,8 +38,13 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
|
||||
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testPlainNotAvailable(self):
|
||||
"""Test the client handles gracefully servers that don't provide a
|
||||
mechanism it could use."""
|
||||
"""`sasl=EXTERNAL` is advertized, whereas the client is configured
|
||||
to use PLAIN.
|
||||
|
||||
A client implementing sasl-3.2 can give up authentication immediately.
|
||||
A client not implementing it will try authenticating, and will get
|
||||
a 904.
|
||||
"""
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.plain],
|
||||
username='jilles',
|
||||
@ -59,7 +64,9 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testPlainLarge(self):
|
||||
"""Test the client splits large AUTHENTICATE messages whose payload
|
||||
is not a multiple of 400."""
|
||||
is not a multiple of 400.
|
||||
<http://ircv3.net/specs/extensions/sasl-3.1.html#the-authenticate-command>
|
||||
"""
|
||||
# TODO: authzid is optional
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.plain],
|
||||
@ -88,7 +95,9 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testPlainLargeMultiple(self):
|
||||
"""Test the client splits large AUTHENTICATE messages whose payload
|
||||
is a multiple of 400."""
|
||||
is a multiple of 400.
|
||||
<http://ircv3.net/specs/extensions/sasl-3.1.html#the-authenticate-command>
|
||||
"""
|
||||
# TODO: authzid is optional
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.plain],
|
||||
@ -116,7 +125,8 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
|
||||
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('ECDSA-NIST256P-CHALLENGE')
|
||||
def testEcdsa(self):
|
||||
"""Test ECDSA authentication."""
|
||||
"""Test ECDSA authentication.
|
||||
"""
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.ecdsa_nist256p_challenge],
|
||||
username='jilles',
|
||||
@ -148,7 +158,8 @@ class Irc302SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testPlainNotAvailable(self):
|
||||
"""Test the client does not try to authenticate using a mechanism the
|
||||
server does not advertise."""
|
||||
server does not advertise.
|
||||
Actually, this is optional."""
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.plain],
|
||||
username='jilles',
|
||||
|
@ -4,7 +4,12 @@ from irctest.irc_utils.message_parser import Message
|
||||
class CapTestCase(cases.BaseServerTestCase):
|
||||
def testNoReq(self):
|
||||
"""Test the server handles gracefully clients which do not send
|
||||
REQs."""
|
||||
REQs.
|
||||
|
||||
“Clients that support capabilities but do not wish to enter
|
||||
negotiation SHOULD send CAP END upon connection to the server.”
|
||||
-- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-end-subcommand>
|
||||
"""
|
||||
self.addClient(1)
|
||||
self.sendLine(1, 'CAP LS 302')
|
||||
self.getCapLs(1)
|
||||
@ -16,7 +21,9 @@ class CapTestCase(cases.BaseServerTestCase):
|
||||
|
||||
def testReqUnavailable(self):
|
||||
"""Test the server handles gracefully clients which request
|
||||
capabilities that are not available"""
|
||||
capabilities that are not available.
|
||||
<http://ircv3.net/specs/core/capability-negotiation-3.1.html>
|
||||
"""
|
||||
self.addClient(1)
|
||||
self.sendLine(1, 'CAP LS 302')
|
||||
self.getCapLs(1)
|
||||
@ -31,8 +38,11 @@ class CapTestCase(cases.BaseServerTestCase):
|
||||
self.assertEqual(m.command, '001')
|
||||
|
||||
def testNakExactString(self):
|
||||
"""Make sure the server NAKs with *exactly* the string sent, as
|
||||
required by the spec <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-nak-subcommand>"""
|
||||
"""“The argument of the NAK subcommand MUST consist of at least the
|
||||
first 100 characters of the capability list in the REQ subcommand which
|
||||
triggered the NAK.”
|
||||
-- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-nak-subcommand>
|
||||
"""
|
||||
self.addClient(1)
|
||||
self.sendLine(1, 'CAP LS 302')
|
||||
self.getCapLs(1)
|
||||
@ -44,7 +54,10 @@ class CapTestCase(cases.BaseServerTestCase):
|
||||
subcommand='NAK', subparams=['foo bar baz qux quux'])
|
||||
|
||||
def testNakWhole(self):
|
||||
"""Makes sure the server NAKS all capabilities in a single REQ."""
|
||||
"""“The capability identifier set must be accepted as a whole, or
|
||||
rejected entirely.”
|
||||
-- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-req-subcommand>
|
||||
"""
|
||||
self.addClient(1)
|
||||
self.sendLine(1, 'CAP LS 302')
|
||||
self.assertIn('multi-prefix', self.getCapLs(1))
|
||||
|
@ -12,7 +12,7 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase):
|
||||
def testPassBeforeNickuser(self):
|
||||
"""“Currently this requires that user send a PASS command before
|
||||
sending the NICK/USER combination.”
|
||||
<https://tools.ietf.org/html/rfc2812#section-3.1.1>"""
|
||||
-- <https://tools.ietf.org/html/rfc2812#section-3.1.1>"""
|
||||
self.connectClient('foo')
|
||||
self.getMessages(1, synchronize=False)
|
||||
self.sendLine(1, 'PASS :foo')
|
||||
@ -21,7 +21,8 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase):
|
||||
|
||||
def testQuitDisconnects(self):
|
||||
"""“The server must close the connection to a client which sends a
|
||||
QUIT message.” <https://tools.ietf.org/html/rfc1459#section-4.1.3>
|
||||
QUIT message.”
|
||||
-- <https://tools.ietf.org/html/rfc1459#section-4.1.3>
|
||||
"""
|
||||
self.connectClient('foo')
|
||||
self.getMessages(1)
|
||||
@ -29,6 +30,9 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase):
|
||||
self.assertRaises(cases.ConnectionClosed, self.getMessages, 1)
|
||||
|
||||
def testNickCollision(self):
|
||||
"""A user connects and requests the same nickname as an already
|
||||
registered user.
|
||||
"""
|
||||
self.connectClient('foo')
|
||||
self.addClient()
|
||||
self.sendLine(2, 'NICK foo')
|
||||
@ -37,6 +41,7 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase):
|
||||
self.assertNotEqual(m.command, '001')
|
||||
|
||||
def testEarlyNickCollision(self):
|
||||
"""Two users register simultaneously with the same nick."""
|
||||
self.addClient()
|
||||
self.addClient()
|
||||
self.sendLine(1, 'NICK foo')
|
||||
|
@ -8,7 +8,7 @@ class RegistrationTestCase(cases.BaseServerTestCase):
|
||||
class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism('PLAIN')
|
||||
def testPlain(self):
|
||||
"""Test PLAIN authentication."""
|
||||
"""PLAIN authentication with correct username/password."""
|
||||
self.controller.registerUser(self, 'foo', 'sesame')
|
||||
self.controller.registerUser(self, 'jilles', 'sesame')
|
||||
self.controller.registerUser(self, 'bar', 'sesame')
|
||||
|
Reference in New Issue
Block a user