Services: Reset configured passwords in tests

I didn't observe any error with the current set of tests but adding
another one that used "services password" caused oen of these tests
to fail.  Given that tests shouldn't leave traces in global state,
let's reset the configured passwords in finally blocks.
This commit is contained in:
David Macek 2021-04-24 20:33:40 +02:00 committed by Valentin Lorentz
parent 151fcf8caf
commit 8a4e8c2a37
1 changed files with 39 additions and 29 deletions

View File

@ -39,43 +39,53 @@ class ServicesTestCase(PluginTestCase):
}
def testPasswordAndIdentify(self):
self.assertNotError('services password foo bar')
self.assertError('services identify') # Don't have a password.
self.assertNotError('services password %s baz' % self.nick)
m = self.assertNotError('services identify')
self.assertTrue(m.args[0] == 'NickServ')
self.assertTrue(m.args[1].lower() == 'identify baz')
self.assertNotError('services password %s biff' % self.nick)
m = self.assertNotError('services identify')
self.assertTrue(m.args[0] == 'NickServ')
self.assertTrue(m.args[1].lower() == 'identify biff')
try:
self.assertNotError('services password foo bar')
self.assertError('services identify') # Don't have a password.
finally:
self.assertNotError('services password foo ""')
try:
self.assertNotError('services password %s baz' % self.nick)
m = self.assertNotError('services identify')
self.assertTrue(m.args[0] == 'NickServ')
self.assertTrue(m.args[1].lower() == 'identify baz')
self.assertNotError('services password %s biff' % self.nick)
m = self.assertNotError('services identify')
self.assertTrue(m.args[0] == 'NickServ')
self.assertTrue(m.args[1].lower() == 'identify biff')
finally:
self.assertNotError('services password %s ""' % self.nick)
def testPasswordConfig(self):
self.assertNotError('config plugins.Services.nicks ""')
self.assertNotError('config network plugins.Services.nicks ""')
self.assertNotError('services password %s bar' % self.nick)
try:
self.assertNotError('services password %s bar' % self.nick)
self.assertResponse(
'config plugins.Services.nicks',
'Global: ; test: %s' % self.nick)
self.assertResponse(
'config plugins.Services.nickserv.password.%s' % self.nick,
'Global: bar; test: bar')
self.assertResponse(
'config plugins.Services.nicks',
'Global: ; test: %s' % self.nick)
self.assertResponse(
'config plugins.Services.nickserv.password.%s' % self.nick,
'Global: bar; test: bar')
self.assertNotError(
'config network plugins.Services.nickserv.password.%s bar2'
% self.nick)
self.assertResponse(
'config plugins.Services.nickserv.password.%s' % self.nick,
'Global: bar; test: bar2')
self.assertResponse(
'config plugins.Services.nickserv.password.%s' % self.nick,
'Global: bar; test: bar2')
self.assertNotError(
'config network plugins.Services.nickserv.password.%s bar2'
% self.nick)
self.assertResponse(
'config plugins.Services.nickserv.password.%s' % self.nick,
'Global: bar; test: bar2')
self.assertResponse(
'config plugins.Services.nickserv.password.%s' % self.nick,
'Global: bar; test: bar2')
m = self.assertNotError('services identify')
self.assertTrue(m.args[0] == 'NickServ')
self.assertTrue(m.args[1].lower() == 'identify bar2')
m = self.assertNotError('services identify')
self.assertTrue(m.args[0] == 'NickServ')
self.assertTrue(m.args[1].lower() == 'identify bar2')
finally:
self.assertNotError('services password %s ""' % self.nick)
def testRegisterNoExperimentalExtensions(self):
self.assertRegexp(