mirror of
https://github.com/progval/Limnoria.git
synced 2025-05-02 08:21:08 -05:00
User: Fix error handling when hostmasks overlap.
This commit is contained in:
parent
08c6238e14
commit
b3bed0d6f9
@ -356,6 +356,7 @@ class User(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
ircdb.users.setUser(user)
|
ircdb.users.setUser(user)
|
||||||
except ircdb.DuplicateHostmask:
|
except ircdb.DuplicateHostmask:
|
||||||
|
user.removeHostmask(hostmask)
|
||||||
irc.error(_('That hostmask is already registered.'),
|
irc.error(_('That hostmask is already registered.'),
|
||||||
Raise=True)
|
Raise=True)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
@ -38,8 +38,8 @@ import supybot.utils as utils
|
|||||||
|
|
||||||
class UserTestCase(PluginTestCase):
|
class UserTestCase(PluginTestCase):
|
||||||
plugins = ('User', 'Admin', 'Config')
|
plugins = ('User', 'Admin', 'Config')
|
||||||
prefix1 = 'somethingElse!user@host.tld'
|
prefix1 = 'somethingElse!user@host1.tld'
|
||||||
prefix2 = 'EvensomethingElse!user@host.tld'
|
prefix2 = 'EvensomethingElse!user@host2.tld'
|
||||||
|
|
||||||
def testHostmaskList(self):
|
def testHostmaskList(self):
|
||||||
self.assertError('hostmask list')
|
self.assertError('hostmask list')
|
||||||
@ -60,6 +60,21 @@ class UserTestCase(PluginTestCase):
|
|||||||
self.assertNotError('identify foo bar')
|
self.assertNotError('identify foo bar')
|
||||||
self.assertRegexp('hostmask list', 'no registered hostmasks')
|
self.assertRegexp('hostmask list', 'no registered hostmasks')
|
||||||
|
|
||||||
|
def testHostmaskOverlap(self):
|
||||||
|
self.assertNotError('register foo passwd', frm=self.prefix1)
|
||||||
|
self.assertNotError('register bar passwd', frm=self.prefix2)
|
||||||
|
self.assertResponse('whoami', 'foo', frm=self.prefix1)
|
||||||
|
self.assertResponse('whoami', 'bar', frm=self.prefix2)
|
||||||
|
self.assertNotError('hostmask add foo *!*@foobar/b',
|
||||||
|
frm=self.prefix1)
|
||||||
|
self.assertResponse('hostmask add bar *!*@foobar/*',
|
||||||
|
'Error: That hostmask is already registered.',
|
||||||
|
frm=self.prefix2)
|
||||||
|
self.assertRegexp('hostmask list foo', '\*!\*@foobar/b',
|
||||||
|
frm=self.prefix1)
|
||||||
|
self.assertNotRegexp('hostmask list bar', 'foobar',
|
||||||
|
frm=self.prefix2)
|
||||||
|
|
||||||
|
|
||||||
def testHostmask(self):
|
def testHostmask(self):
|
||||||
self.assertResponse('hostmask', self.prefix)
|
self.assertResponse('hostmask', self.prefix)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user