Skip to content

Commit

Permalink
test no-CTCP mode
Browse files Browse the repository at this point in the history
  • Loading branch information
slingamn committed Oct 2, 2020
1 parent 616785e commit 0c069b7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions irctest/server_tests/test_user_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,32 @@ def testAway(self):
self.sendLine(2, "PRIVMSG bar :what's up")
replies = self.getMessages(2)
self.assertEqual(len(replies), 0)

class TestNoCTCPMode(cases.BaseServerTestCase):

@cases.SpecificationSelector.requiredBySpecification('Oragono')
def testNoCTCPMode(self):
self.connectClient('bar', 'bar')
self.connectClient('qux', 'qux')
# CTCP is not blocked by default:
self.sendLine('qux', 'PRIVMSG bar :\x01VERSION\x01')
self.getMessages('qux')
relay = [msg for msg in self.getMessages('bar') if msg.command == 'PRIVMSG'][0]
self.assertEqual(relay.params[-1], '\x01VERSION\x01')

# set the no-CTCP user mode on bar:
self.sendLine('bar', 'MODE bar +T')
replies = self.getMessages('bar')
umode_line = [msg for msg in replies if msg.command == 'MODE'][0]
self.assertMessageEqual(umode_line, command='MODE', params=['bar', '+T'])

# CTCP is now blocked:
self.sendLine('qux', 'PRIVMSG bar :\x01VERSION\x01')
self.getMessages('qux')
self.assertEqual(self.getMessages('bar'), [])

# normal PRIVMSG go through:
self.sendLine('qux', 'PRIVMSG bar :please just tell me your client version')
self.getMessages('qux')
relay = self.getMessages('bar')[0]
self.assertMessageEqual(relay, command='PRIVMSG', nick='qux', params=['bar', 'please just tell me your client version'])

0 comments on commit 0c069b7

Please sign in to comment.