Skip to content

Commit

Permalink
SaslTestCase: Change config instead of messing with irc.sasl_next_mec…
Browse files Browse the repository at this point in the history
…hanisms

Changing the internal state will break in the next commit, which
reorganizes SASL state initialization
  • Loading branch information
progval committed Sep 5, 2023
1 parent eb31ed3 commit 5de3b6c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions test/test_irclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,21 +1494,25 @@ def testBatchInterleaved(self):

class SaslTestCase(SupyTestCase, CapNegMixin):
def setUp(self):
pass
self._default_mechanisms = conf.supybot.networks.test.sasl.mechanisms()

def tearDown(self):
conf.supybot.networks.test.sasl.mechanisms.setValue(self._default_mechanisms)
conf.supybot.networks.test.sasl.username.setValue('')
conf.supybot.networks.test.sasl.password.setValue('')
conf.supybot.networks.test.certfile.setValue('')

def testPlain(self):
conf.supybot.networks.test.sasl.username.setValue('jilles')
conf.supybot.networks.test.sasl.password.setValue('sesame')
conf.supybot.networks.test.sasl.mechanisms.setValue(
['scram-sha-256', 'plain'])

self.irc = irclib.Irc('test')

self.assertEqual(self.irc.sasl_current_mechanism, None)
self.irc.sasl_next_mechanisms = ['scram-sha-256', 'plain']
self.assertEqual(self.irc.sasl_next_mechanisms,
['scram-sha-256', 'plain'])

self.startCapNegociation()

Expand Down Expand Up @@ -1537,11 +1541,14 @@ def testExternalFallbackToPlain(self):
conf.supybot.networks.test.sasl.username.setValue('jilles')
conf.supybot.networks.test.sasl.password.setValue('sesame')
conf.supybot.networks.test.certfile.setValue('foo')
conf.supybot.networks.test.sasl.mechanisms.setValue(
['external', 'plain'])

self.irc = irclib.Irc('test')

self.assertEqual(self.irc.sasl_current_mechanism, None)
self.irc.sasl_next_mechanisms = ['external', 'plain']
self.assertEqual(self.irc.sasl_next_mechanisms,
['external', 'plain'])

self.startCapNegociation()

Expand Down Expand Up @@ -1570,11 +1577,14 @@ def testFilter(self):
conf.supybot.networks.test.sasl.username.setValue('jilles')
conf.supybot.networks.test.sasl.password.setValue('sesame')
conf.supybot.networks.test.certfile.setValue('foo')
conf.supybot.networks.test.sasl.mechanisms.setValue(
['external', 'plain'])

self.irc = irclib.Irc('test')

self.assertEqual(self.irc.sasl_current_mechanism, None)
self.irc.sasl_next_mechanisms = ['external', 'plain']
self.assertEqual(self.irc.sasl_next_mechanisms,
['external', 'plain'])

self.startCapNegociation(caps='sasl=foo,plain,bar')

Expand All @@ -1596,11 +1606,14 @@ def testFilter(self):
def testReauthenticate(self):
conf.supybot.networks.test.sasl.username.setValue('jilles')
conf.supybot.networks.test.sasl.password.setValue('sesame')
conf.supybot.networks.test.sasl.mechanisms.setValue(
['external', 'plain'])

self.irc = irclib.Irc('test')

self.assertEqual(self.irc.sasl_current_mechanism, None)
self.irc.sasl_next_mechanisms = ['plain']
self.assertEqual(self.irc.sasl_next_mechanisms,
['plain'])

self.startCapNegociation(caps='')

Expand Down

0 comments on commit 5de3b6c

Please sign in to comment.