From be3dae35584de16e8f4c8c8faa39681048bd922b Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 19 Jul 2024 16:41:46 +0200 Subject: [PATCH] Add test the bot won't account-extban itself --- plugins/Channel/test.py | 24 ++++++++++++++++++++++++ src/test.py | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/Channel/test.py b/plugins/Channel/test.py index 48f3efe51..bcfc52786 100644 --- a/plugins/Channel/test.py +++ b/plugins/Channel/test.py @@ -189,6 +189,30 @@ class ChannelTestCase(ChannelPluginTestCase): 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='foobar!user@host.domain.tld')) + 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 = 'something!else@somehwere.else' self.irc.nick = 'something' diff --git a/src/test.py b/src/test.py index 08e43ba07..5fa48028b 100644 --- a/src/test.py +++ b/src/test.py @@ -318,7 +318,8 @@ class PluginTestCase(SupyTestCase): 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):