From d074721603133f8bbc41b713fc67de6e1f8acfd8 Mon Sep 17 00:00:00 2001 From: James Vega Date: Fri, 14 Oct 2005 12:57:21 +0000 Subject: [PATCH] plugins/User: Make sure we raise the error in User.unregister so allowUnregistration is obeyed. --- plugins/User/plugin.py | 3 ++- plugins/User/test.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/User/plugin.py b/plugins/User/plugin.py index 2500b94d6..45c0fd180 100644 --- a/plugins/User/plugin.py +++ b/plugins/User/plugin.py @@ -135,7 +135,8 @@ class User(callbacks.Plugin): self.log.warning('%s tried to unregister user %s.', msg.prefix, user.name) irc.error('This command has been disabled. You\'ll have to ' - 'ask the owner of this bot to unregister your user.') + 'ask the owner of this bot to unregister your user.', + Raise=True) if isOwner or user.checkPassword(password): ircdb.users.delUser(user.id) irc.replySuccess() diff --git a/plugins/User/test.py b/plugins/User/test.py index a46dd44e9..10169422d 100644 --- a/plugins/User/test.py +++ b/plugins/User/test.py @@ -54,7 +54,7 @@ class UserTestCase(PluginTestCase): self.assertNotError('hostmask remove foo %s' % self.prefix1) self.assertNotError('identify foo bar') self.assertRegexp('hostmask list', 'no registered hostmasks') - + def testHostmask(self): self.assertResponse('hostmask', self.prefix) @@ -67,9 +67,23 @@ class UserTestCase(PluginTestCase): self.assertNotError('register foo bar') self.assertError('register foo baz') self.failUnless(ircdb.users.getUserId('foo')) + self.assertError('unregister foo') self.assertNotError('unregister foo bar') self.assertRaises(KeyError, ircdb.users.getUserId, 'foo') + def testDisallowedUnregistration(self): + self.prefix = self.prefix1 + self.assertNotError('register foo bar') + orig = conf.supybot.databases.users.allowUnregistration() + conf.supybot.databases.users.allowUnregistration.setValue(False) + try: + self.assertError('unregister foo') + m = self.irc.takeMsg() + self.failIf(m is not None, m) + self.failUnless(ircdb.users.getUserId('foo')) + finally: + conf.supybot.databases.users.allowUnregistration.setValue(orig) + def testList(self): self.prefix = self.prefix1 self.assertNotError('register foo bar')