This commit is contained in:
Shivaram Lingamneni
2019-06-13 02:04:01 -04:00
parent a72c9a74c0
commit 3697ecbebf
2 changed files with 32 additions and 32 deletions

View File

@ -9,13 +9,13 @@ from irctest import cases
class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledPrivmsgResponsesToMultipleClients(self): def testLabeledPrivmsgResponsesToMultipleClients(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(2) self.getMessages(2)
self.connectClient('carl', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('carl', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(3) self.getMessages(3)
self.connectClient('alice', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('alice', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(4) self.getMessages(4)
self.sendLine(1, '@draft/label=12345 PRIVMSG bar,carl,alice :hi') self.sendLine(1, '@draft/label=12345 PRIVMSG bar,carl,alice :hi')
@ -36,9 +36,9 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledPrivmsgResponsesToClient(self): def testLabeledPrivmsgResponsesToClient(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(2) self.getMessages(2)
self.sendLine(1, '@draft/label=12345 PRIVMSG bar :hi') self.sendLine(1, '@draft/label=12345 PRIVMSG bar :hi')
@ -55,9 +55,9 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledPrivmsgResponsesToChannel(self): def testLabeledPrivmsgResponsesToChannel(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(2) self.getMessages(2)
# join channels # join channels
@ -82,7 +82,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledPrivmsgResponsesToSelf(self): def testLabeledPrivmsgResponsesToSelf(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.sendLine(1, '@draft/label=12345 PRIVMSG foo :hi') self.sendLine(1, '@draft/label=12345 PRIVMSG foo :hi')
@ -100,9 +100,9 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledNoticeResponsesToClient(self): def testLabeledNoticeResponsesToClient(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(2) self.getMessages(2)
self.sendLine(1, '@draft/label=12345 NOTICE bar :hi') self.sendLine(1, '@draft/label=12345 NOTICE bar :hi')
@ -119,9 +119,9 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledNoticeResponsesToChannel(self): def testLabeledNoticeResponsesToChannel(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(2) self.getMessages(2)
# join channels # join channels
@ -146,7 +146,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledNoticeResponsesToSelf(self): def testLabeledNoticeResponsesToSelf(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.sendLine(1, '@draft/label=12345 NOTICE foo :hi') self.sendLine(1, '@draft/label=12345 NOTICE foo :hi')
@ -164,9 +164,9 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledTagMsgResponsesToClient(self): def testLabeledTagMsgResponsesToClient(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response', 'message-tags'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2', 'message-tags'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response', 'message-tags'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2', 'message-tags'], skip_if_cap_nak=True)
self.getMessages(2) self.getMessages(2)
self.sendLine(1, '@draft/label=12345;+draft/reply=123;+draft/react=l😃l TAGMSG bar') self.sendLine(1, '@draft/label=12345;+draft/reply=123;+draft/react=l😃l TAGMSG bar')
@ -191,9 +191,9 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledTagMsgResponsesToChannel(self): def testLabeledTagMsgResponsesToChannel(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response', 'message-tags'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2', 'message-tags'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response', 'message-tags'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2', 'message-tags'], skip_if_cap_nak=True)
self.getMessages(2) self.getMessages(2)
# join channels # join channels
@ -218,7 +218,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testLabeledTagMsgResponsesToSelf(self): def testLabeledTagMsgResponsesToSelf(self):
self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response', 'message-tags'], skip_if_cap_nak=True) self.connectClient('foo', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2', 'message-tags'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.sendLine(1, '@draft/label=12345;+draft/reply=123;+draft/react=l😃l TAGMSG foo') self.sendLine(1, '@draft/label=12345;+draft/reply=123;+draft/react=l😃l TAGMSG foo')
@ -236,7 +236,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('IRCv3.2') @cases.SpecificationSelector.requiredBySpecification('IRCv3.2')
def testBatchedJoinMessages(self): def testBatchedJoinMessages(self):
self.connectClient('bar', capabilities=['batch', 'draft/labeled-response', 'message-tags', 'server-time'], skip_if_cap_nak=True) self.connectClient('bar', capabilities=['batch', 'draft/labeled-response-0.2', 'message-tags', 'server-time'], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)
self.sendLine(1, '@draft/label=12345 JOIN #xyz') self.sendLine(1, '@draft/label=12345 JOIN #xyz')
@ -253,7 +253,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
batch_id = batch_start.params[0][1:] batch_id = batch_start.params[0][1:]
# batch id MUST be alphanumerics and hyphens # batch id MUST be alphanumerics and hyphens
self.assertTrue(re.match(r'^[A-Za-z0-9\-]+$', batch_id) is not None, 'batch id must be alphanumerics and hyphens, got %r' % (batch_id,)) self.assertTrue(re.match(r'^[A-Za-z0-9\-]+$', batch_id) is not None, 'batch id must be alphanumerics and hyphens, got %r' % (batch_id,))
self.assertEqual(batch_start.params[1], 'draft/labeled-response') self.assertEqual(batch_start.params[1], 'draft/labeled-response-0.2')
self.assertEqual(batch_start.tags.get('draft/label'), '12345') self.assertEqual(batch_start.tags.get('draft/label'), '12345')
# valid BATCH end line # valid BATCH end line
@ -266,7 +266,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('Oragono') @cases.SpecificationSelector.requiredBySpecification('Oragono')
def testNoBatchForSingleMessage(self): def testNoBatchForSingleMessage(self):
self.connectClient('bar', capabilities=['batch', 'draft/labeled-response', 'message-tags', 'server-time']) self.connectClient('bar', capabilities=['batch', 'draft/labeled-response-0.2', 'message-tags', 'server-time'])
self.getMessages(1) self.getMessages(1)
self.sendLine(1, '@draft/label=98765 PING adhoctestline') self.sendLine(1, '@draft/label=98765 PING adhoctestline')
@ -280,14 +280,14 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
@cases.SpecificationSelector.requiredBySpecification('Oragono') @cases.SpecificationSelector.requiredBySpecification('Oragono')
def testEmptyBatchForNoResponse(self): def testEmptyBatchForNoResponse(self):
self.connectClient('bar', capabilities=['batch', 'draft/labeled-response', 'message-tags', 'server-time']) self.connectClient('bar', capabilities=['batch', 'draft/labeled-response-0.2', 'message-tags', 'server-time'])
self.getMessages(1) self.getMessages(1)
# PONG never receives a response # PONG never receives a response
self.sendLine(1, '@draft/label=98765 PONG adhoctestline') self.sendLine(1, '@draft/label=98765 PONG adhoctestline')
# "If no response is required, an empty batch MUST be sent." # "If no response is required, an empty batch MUST be sent."
# https://ircv3.net/specs/extensions/labeled-response.html # https://ircv3.net/specs/extensions/labeled-response-0.2.html
ms = self.getMessages(1) ms = self.getMessages(1)
self.assertEqual(len(ms), 2) self.assertEqual(len(ms), 2)
batch_start, batch_end = ms batch_start, batch_end = ms

View File

@ -12,17 +12,17 @@ class ResumeTestCase(cases.BaseServerTestCase):
@cases.SpecificationSelector.requiredBySpecification('Oragono') @cases.SpecificationSelector.requiredBySpecification('Oragono')
def testNoResumeByDefault(self): def testNoResumeByDefault(self):
self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response']) self.connectClient('bar', capabilities=['batch', 'echo-message', 'draft/labeled-response-0.2'])
ms = self.getMessages(1) ms = self.getMessages(1)
resume_messages = [m for m in ms if m.command == 'RESUME'] resume_messages = [m for m in ms if m.command == 'RESUME']
self.assertEqual(resume_messages, [], 'should not see RESUME messages unless explicitly negotiated') self.assertEqual(resume_messages, [], 'should not see RESUME messages unless explicitly negotiated')
@cases.SpecificationSelector.requiredBySpecification('Oragono') @cases.SpecificationSelector.requiredBySpecification('Oragono')
def testResume(self): def testResume(self):
self.connectClient('bar', capabilities=['batch', 'draft/labeled-response', 'server-time']) self.connectClient('bar', capabilities=['batch', 'draft/labeled-response-0.2', 'server-time'])
ms = self.getMessages(1) ms = self.getMessages(1)
welcome = self.connectClient('baz', capabilities=['batch', 'draft/labeled-response', 'server-time', 'draft/resume-0.5']) welcome = self.connectClient('baz', capabilities=['batch', 'draft/labeled-response-0.2', 'server-time', 'draft/resume-0.5'])
resume_messages = [m for m in welcome if m.command == 'RESUME'] resume_messages = [m for m in welcome if m.command == 'RESUME']
self.assertEqual(len(resume_messages), 1) self.assertEqual(len(resume_messages), 1)
self.assertEqual(resume_messages[0].params[0], 'TOKEN') self.assertEqual(resume_messages[0].params[0], 'TOKEN')
@ -46,7 +46,7 @@ class ResumeTestCase(cases.BaseServerTestCase):
bad_token = 'a' * len(token) bad_token = 'a' * len(token)
self.addClient() self.addClient()
self.sendLine(3, 'CAP LS') self.sendLine(3, 'CAP LS')
self.sendLine(3, 'CAP REQ :batch draft/labeled-response server-time draft/resume-0.5') self.sendLine(3, 'CAP REQ :batch draft/labeled-response-0.2 server-time draft/resume-0.5')
self.sendLine(3, 'NICK tempnick') self.sendLine(3, 'NICK tempnick')
self.sendLine(3, 'USER tempuser 0 * tempuser') self.sendLine(3, 'USER tempuser 0 * tempuser')
self.sendLine(3, ' '.join(('RESUME', bad_token, ANCIENT_TIMESTAMP))) self.sendLine(3, ' '.join(('RESUME', bad_token, ANCIENT_TIMESTAMP)))
@ -62,7 +62,7 @@ class ResumeTestCase(cases.BaseServerTestCase):
self.addClient() self.addClient()
self.sendLine(4, 'CAP LS') self.sendLine(4, 'CAP LS')
self.sendLine(4, 'CAP REQ :batch draft/labeled-response server-time draft/resume-0.5') self.sendLine(4, 'CAP REQ :batch draft/labeled-response-0.2 server-time draft/resume-0.5')
self.sendLine(4, 'NICK tempnick_') self.sendLine(4, 'NICK tempnick_')
self.sendLine(4, 'USER tempuser 0 * tempuser') self.sendLine(4, 'USER tempuser 0 * tempuser')
# resume with a timestamp in the distant past # resume with a timestamp in the distant past
@ -108,7 +108,7 @@ class ResumeTestCase(cases.BaseServerTestCase):
# test chain-resuming (resuming the resumed connection, using the new token) # test chain-resuming (resuming the resumed connection, using the new token)
self.addClient() self.addClient()
self.sendLine(5, 'CAP LS') self.sendLine(5, 'CAP LS')
self.sendLine(5, 'CAP REQ :batch draft/labeled-response server-time draft/resume-0.5') self.sendLine(5, 'CAP REQ :batch draft/labeled-response-0.2 server-time draft/resume-0.5')
self.sendLine(5, 'NICK tempnick_') self.sendLine(5, 'NICK tempnick_')
self.sendLine(5, 'USER tempuser 0 * tempuser') self.sendLine(5, 'USER tempuser 0 * tempuser')
self.sendLine(5, 'RESUME ' + new_token) self.sendLine(5, 'RESUME ' + new_token)
@ -126,11 +126,11 @@ class ResumeTestCase(cases.BaseServerTestCase):
@cases.SpecificationSelector.requiredBySpecification('Oragono') @cases.SpecificationSelector.requiredBySpecification('Oragono')
def testBRB(self): def testBRB(self):
self.connectClient('bar', capabilities=['batch', 'draft/labeled-response', 'message-tags', 'server-time', 'draft/resume-0.5']) self.connectClient('bar', capabilities=['batch', 'draft/labeled-response-0.2', 'message-tags', 'server-time', 'draft/resume-0.5'])
ms = self.getMessages(1) ms = self.getMessages(1)
self.joinChannel(1, '#xyz') self.joinChannel(1, '#xyz')
welcome = self.connectClient('baz', capabilities=['batch', 'draft/labeled-response', 'server-time', 'draft/resume-0.5']) welcome = self.connectClient('baz', capabilities=['batch', 'draft/labeled-response-0.2', 'server-time', 'draft/resume-0.5'])
resume_messages = [m for m in welcome if m.command == 'RESUME'] resume_messages = [m for m in welcome if m.command == 'RESUME']
self.assertEqual(len(resume_messages), 1) self.assertEqual(len(resume_messages), 1)
self.assertEqual(resume_messages[0].params[0], 'TOKEN') self.assertEqual(resume_messages[0].params[0], 'TOKEN')