mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +01:00
SaslTestCase: Use tearDown() method instead of finally: blocks
It's much cleaner
This commit is contained in:
parent
f8dd8d7642
commit
81a5133c14
@ -1496,14 +1496,17 @@ class SaslTestCase(SupyTestCase, CapNegMixin):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
conf.supybot.networks.test.sasl.username.setValue('')
|
||||||
|
conf.supybot.networks.test.sasl.password.setValue('')
|
||||||
|
conf.supybot.networks.test.certfile.setValue('')
|
||||||
|
|
||||||
def testPlain(self):
|
def testPlain(self):
|
||||||
try:
|
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
||||||
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
||||||
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
|
||||||
self.irc = irclib.Irc('test')
|
self.irc = irclib.Irc('test')
|
||||||
finally:
|
|
||||||
conf.supybot.networks.test.sasl.username.setValue('')
|
|
||||||
conf.supybot.networks.test.sasl.password.setValue('')
|
|
||||||
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
||||||
self.irc.sasl_next_mechanisms = ['scram-sha-256', 'plain']
|
self.irc.sasl_next_mechanisms = ['scram-sha-256', 'plain']
|
||||||
|
|
||||||
@ -1531,15 +1534,12 @@ class SaslTestCase(SupyTestCase, CapNegMixin):
|
|||||||
self.endCapNegociation()
|
self.endCapNegociation()
|
||||||
|
|
||||||
def testExternalFallbackToPlain(self):
|
def testExternalFallbackToPlain(self):
|
||||||
try:
|
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
||||||
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
||||||
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
conf.supybot.networks.test.certfile.setValue('foo')
|
||||||
conf.supybot.networks.test.certfile.setValue('foo')
|
|
||||||
self.irc = irclib.Irc('test')
|
self.irc = irclib.Irc('test')
|
||||||
finally:
|
|
||||||
conf.supybot.networks.test.sasl.username.setValue('')
|
|
||||||
conf.supybot.networks.test.sasl.password.setValue('')
|
|
||||||
conf.supybot.networks.test.certfile.setValue('')
|
|
||||||
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
||||||
self.irc.sasl_next_mechanisms = ['external', 'plain']
|
self.irc.sasl_next_mechanisms = ['external', 'plain']
|
||||||
|
|
||||||
@ -1567,15 +1567,12 @@ class SaslTestCase(SupyTestCase, CapNegMixin):
|
|||||||
self.endCapNegociation()
|
self.endCapNegociation()
|
||||||
|
|
||||||
def testFilter(self):
|
def testFilter(self):
|
||||||
try:
|
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
||||||
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
||||||
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
conf.supybot.networks.test.certfile.setValue('foo')
|
||||||
conf.supybot.networks.test.certfile.setValue('foo')
|
|
||||||
self.irc = irclib.Irc('test')
|
self.irc = irclib.Irc('test')
|
||||||
finally:
|
|
||||||
conf.supybot.networks.test.sasl.username.setValue('')
|
|
||||||
conf.supybot.networks.test.sasl.password.setValue('')
|
|
||||||
conf.supybot.networks.test.certfile.setValue('')
|
|
||||||
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
||||||
self.irc.sasl_next_mechanisms = ['external', 'plain']
|
self.irc.sasl_next_mechanisms = ['external', 'plain']
|
||||||
|
|
||||||
@ -1597,13 +1594,11 @@ class SaslTestCase(SupyTestCase, CapNegMixin):
|
|||||||
self.endCapNegociation()
|
self.endCapNegociation()
|
||||||
|
|
||||||
def testReauthenticate(self):
|
def testReauthenticate(self):
|
||||||
try:
|
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
||||||
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
||||||
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
|
||||||
self.irc = irclib.Irc('test')
|
self.irc = irclib.Irc('test')
|
||||||
finally:
|
|
||||||
conf.supybot.networks.test.sasl.username.setValue('')
|
|
||||||
conf.supybot.networks.test.sasl.password.setValue('')
|
|
||||||
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
self.assertEqual(self.irc.sasl_current_mechanism, None)
|
||||||
self.irc.sasl_next_mechanisms = ['plain']
|
self.irc.sasl_next_mechanisms = ['plain']
|
||||||
|
|
||||||
@ -1622,16 +1617,12 @@ class SaslTestCase(SupyTestCase, CapNegMixin):
|
|||||||
self.irc.takeMsg() # None. But even if it was CAP REQ sasl, it would be ok
|
self.irc.takeMsg() # None. But even if it was CAP REQ sasl, it would be ok
|
||||||
self.assertEqual(self.irc.takeMsg(), None)
|
self.assertEqual(self.irc.takeMsg(), None)
|
||||||
|
|
||||||
try:
|
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
||||||
conf.supybot.networks.test.sasl.username.setValue('jilles')
|
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
||||||
conf.supybot.networks.test.sasl.password.setValue('sesame')
|
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||||
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
args=('*', 'DEL', 'sasl')))
|
||||||
args=('*', 'DEL', 'sasl')))
|
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||||
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
args=('*', 'NEW', 'sasl=PLAIN')))
|
||||||
args=('*', 'NEW', 'sasl=PLAIN')))
|
|
||||||
finally:
|
|
||||||
conf.supybot.networks.test.sasl.username.setValue('')
|
|
||||||
conf.supybot.networks.test.sasl.password.setValue('')
|
|
||||||
|
|
||||||
m = self.irc.takeMsg()
|
m = self.irc.takeMsg()
|
||||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||||
|
Loading…
Reference in New Issue
Block a user