mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 07:19:54 +00:00
Merge pull request #3 from DanielOaks/allow-skipping
Support skipping unsupported SASL mechanisms
This commit is contained in:
@ -15,7 +15,14 @@ IRX9cyi2wdYg9mUUYyh9GKdBCYHGUJAiCA==
|
||||
-----END EC PRIVATE KEY-----
|
||||
"""
|
||||
|
||||
class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
class SaslMechanismCheck:
|
||||
def checkMechanismSupport(self, mechanism):
|
||||
if mechanism in self.controller.supported_sasl_mechanisms:
|
||||
return
|
||||
self.skipTest('SASL Mechanism not supported: {}'.format(mechanism))
|
||||
|
||||
class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
|
||||
SaslMechanismCheck):
|
||||
def testPlain(self):
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.plain],
|
||||
@ -23,6 +30,7 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
password='sesame',
|
||||
)
|
||||
m = self.negotiateCapabilities(['sasl'], auth=auth)
|
||||
self.checkMechanismSupport('PLAIN')
|
||||
self.assertEqual(m, Message([], None, 'AUTHENTICATE', ['PLAIN']))
|
||||
self.sendLine('AUTHENTICATE +')
|
||||
m = self.getMessage()
|
||||
@ -40,6 +48,7 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
password='sesame',
|
||||
)
|
||||
m = self.negotiateCapabilities(['sasl=EXTERNAL'], auth=auth)
|
||||
self.checkMechanismSupport('PLAIN')
|
||||
self.assertEqual(self.acked_capabilities, {'sasl'})
|
||||
if m == Message([], None, 'CAP', ['END']):
|
||||
# IRCv3.2-style
|
||||
@ -59,6 +68,7 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
authstring = base64.b64encode(b'\x00'.join(
|
||||
[b'foo', b'foo', b'bar'*200])).decode()
|
||||
m = self.negotiateCapabilities(['sasl'], auth=auth)
|
||||
self.checkMechanismSupport('PLAIN')
|
||||
self.assertEqual(m, Message([], None, 'AUTHENTICATE', ['PLAIN']))
|
||||
self.sendLine('AUTHENTICATE +')
|
||||
m = self.getMessage()
|
||||
@ -85,6 +95,7 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
authstring = base64.b64encode(b'\x00'.join(
|
||||
[b'foo', b'foo', b'quux'*148])).decode()
|
||||
m = self.negotiateCapabilities(['sasl'], auth=auth)
|
||||
self.checkMechanismSupport('PLAIN')
|
||||
self.assertEqual(m, Message([], None, 'AUTHENTICATE', ['PLAIN']))
|
||||
self.sendLine('AUTHENTICATE +')
|
||||
m = self.getMessage()
|
||||
@ -108,6 +119,7 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
ecdsa_key=ECDSA_KEY,
|
||||
)
|
||||
m = self.negotiateCapabilities(['sasl'], auth=auth)
|
||||
self.checkMechanismSupport('ECDSA-NIST256P-CHALLENGE')
|
||||
self.assertEqual(m, Message([], None, 'AUTHENTICATE', ['ECDSA-NIST256P-CHALLENGE']))
|
||||
self.sendLine('AUTHENTICATE +')
|
||||
m = self.getMessage()
|
||||
@ -128,7 +140,8 @@ class SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
m = self.negotiateCapabilities(['sasl'], False)
|
||||
self.assertEqual(m, Message([], None, 'CAP', ['END']))
|
||||
|
||||
class Irc302SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
|
||||
class Irc302SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper,
|
||||
SaslMechanismCheck):
|
||||
def testPlainNotAvailable(self):
|
||||
auth = authentication.Authentication(
|
||||
mechanisms=[authentication.Mechanisms.plain],
|
||||
@ -136,5 +149,6 @@ class Irc302SaslTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper
|
||||
password='sesame',
|
||||
)
|
||||
m = self.negotiateCapabilities(['sasl=EXTERNAL'], auth=auth)
|
||||
self.checkMechanismSupport('PLAIN')
|
||||
self.assertEqual(self.acked_capabilities, {'sasl'})
|
||||
self.assertEqual(m, Message([], None, 'CAP', ['END']))
|
||||
|
@ -23,6 +23,8 @@ class LimnoriaController(BaseClientController, DirectoryBasedController):
|
||||
pass
|
||||
with self.open_file('conf/users.conf'):
|
||||
pass
|
||||
self.supported_sasl_mechanisms = [
|
||||
'PLAIN', 'ECDSA-NIST256P-CHALLENGE', 'EXTERNAL']
|
||||
|
||||
def run(self, hostname, port, auth):
|
||||
# Runs a client with the config given as arguments
|
||||
|
@ -22,6 +22,7 @@ class SopelController(BaseClientController):
|
||||
super().__init__()
|
||||
self.filename = next(tempfile._get_candidate_names()) + '.cfg'
|
||||
self.proc = None
|
||||
self.supported_sasl_mechanisms = ['PLAIN']
|
||||
def kill(self):
|
||||
if self.proc:
|
||||
self.proc.kill()
|
||||
|
Reference in New Issue
Block a user