Skip to content

Commit

Permalink
Add test the bot won't account-extban itself
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Jul 19, 2024
1 parent 917e301 commit be3dae3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions plugins/Channel/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,30 @@ def testIban(self):
self.assertBan('iban $a:nyuszika7h', '$a:nyuszika7h')
self.assertNotError('unban $a:nyuszika7h')

def testWontIbanItself(self):
self.irc.state.supported['ACCOUNTEXTBAN'] = 'a,account'
self.irc.state.supported['EXTBAN'] = '~,abc'

self.irc.feedMsg(ircmsgs.join(self.channel,
prefix='[email protected]'))
self.irc.feedMsg(ircmsgs.op(self.channel, self.irc.nick))

# not authenticated, falls back to hostname and notices the match
self.assertError('iban --account ' + self.nick)

self.irc.feedMsg(ircmsgs.IrcMsg(prefix=self.prefix, command='ACCOUNT',
args=['botaccount']))

# notices the matching account
self.assertError('iban --account ' + self.nick)

self.irc.feedMsg(ircmsgs.IrcMsg(prefix='othernick!otheruser@otherhost',
command='ACCOUNT',
args=['botaccount']))

# ditto
self.assertError('iban --account othernick')

def testKban(self):
self.irc.prefix = '[email protected]'
self.irc.nick = 'something'
Expand Down
3 changes: 2 additions & 1 deletion src/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def assertError(self, query, **kwargs):
raise TimeoutError(query)
if lastGetHelp not in m.args[1]:
self.assertTrue(m.args[1].startswith('Error:'),
'%r did not error: %s' % (query, m.args[1]))
'%r did not error: %s' %
(query, ' '.join(m.args[1:])))
return m

def assertSnarfError(self, query, **kwargs):
Expand Down

0 comments on commit be3dae3

Please sign in to comment.