Make all remaining tests not Oragono-specific when relevant.

This commit is contained in:
2021-02-27 17:34:37 +01:00
committed by Valentin Lorentz
parent 6b6b86415d
commit f7be6cf016
5 changed files with 47 additions and 39 deletions

View File

@ -460,6 +460,7 @@ class BaseServerTestCase(_IrcTestCase):
capabilities=None, capabilities=None,
skip_if_cap_nak=False, skip_if_cap_nak=False,
show_io=None, show_io=None,
account=None,
password=None, password=None,
ident="username", ident="username",
): ):
@ -482,7 +483,7 @@ class BaseServerTestCase(_IrcTestCase):
self.sendLine(client, "CAP END") self.sendLine(client, "CAP END")
if password is not None: if password is not None:
self.sendLine(client, "AUTHENTICATE PLAIN") self.sendLine(client, "AUTHENTICATE PLAIN")
self.sendLine(client, sasl_plain_blob(nick, password)) self.sendLine(client, sasl_plain_blob(account or nick, password))
self.sendLine(client, "NICK {}".format(nick)) self.sendLine(client, "NICK {}".format(nick))
self.sendLine(client, "USER %s * * :Realname" % (ident,)) self.sendLine(client, "USER %s * * :Realname" % (ident,))

View File

@ -1,4 +1,7 @@
""" """
This specification is a little hard to test because all labels are optional;
so there may be many false positives.
<https://ircv3.net/specs/extensions/labeled-response.html> <https://ircv3.net/specs/extensions/labeled-response.html>
""" """
@ -8,29 +11,36 @@ from irctest import cases
class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
@cases.mark_capabilities("batch", "echo-message", "labeled-response") def connectClient(self, nick, *, capabilities, **kwargs):
if self.controller.software_name == "InspIRCd":
# InspIRCd only sends labels if 'batch' is enabled
if "batch" not in capabilities:
capabilities.append("batch")
return super().connectClient(nick, capabilities=capabilities, **kwargs)
@cases.mark_capabilities("echo-message", "labeled-response")
def testLabeledPrivmsgResponsesToMultipleClients(self): def testLabeledPrivmsgResponsesToMultipleClients(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
self.connectClient( self.connectClient(
"bar", "bar",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(2) self.getMessages(2)
self.connectClient( self.connectClient(
"carl", "carl",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(3) self.getMessages(3)
self.connectClient( self.connectClient(
"alice", "alice",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(4) self.getMessages(4)
@ -96,13 +106,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledPrivmsgResponsesToClient(self): def testLabeledPrivmsgResponsesToClient(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
self.connectClient( self.connectClient(
"bar", "bar",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(2) self.getMessages(2)
@ -156,13 +166,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledPrivmsgResponsesToChannel(self): def testLabeledPrivmsgResponsesToChannel(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
self.connectClient( self.connectClient(
"bar", "bar",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(2) self.getMessages(2)
@ -224,7 +234,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledPrivmsgResponsesToSelf(self): def testLabeledPrivmsgResponsesToSelf(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
@ -267,13 +277,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledNoticeResponsesToClient(self): def testLabeledNoticeResponsesToClient(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
self.connectClient( self.connectClient(
"bar", "bar",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(2) self.getMessages(2)
@ -327,13 +337,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledNoticeResponsesToChannel(self): def testLabeledNoticeResponsesToChannel(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
self.connectClient( self.connectClient(
"bar", "bar",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(2) self.getMessages(2)
@ -395,7 +405,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledNoticeResponsesToSelf(self): def testLabeledNoticeResponsesToSelf(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response"], capabilities=["echo-message", "labeled-response"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
@ -436,13 +446,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledTagMsgResponsesToClient(self): def testLabeledTagMsgResponsesToClient(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response", "message-tags"], capabilities=["echo-message", "labeled-response", "message-tags"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
self.connectClient( self.connectClient(
"bar", "bar",
capabilities=["batch", "echo-message", "labeled-response", "message-tags"], capabilities=["echo-message", "labeled-response", "message-tags"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(2) self.getMessages(2)
@ -544,13 +554,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledTagMsgResponsesToChannel(self): def testLabeledTagMsgResponsesToChannel(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response", "message-tags"], capabilities=["echo-message", "labeled-response", "message-tags"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
self.connectClient( self.connectClient(
"bar", "bar",
capabilities=["batch", "echo-message", "labeled-response", "message-tags"], capabilities=["echo-message", "labeled-response", "message-tags"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(2) self.getMessages(2)
@ -610,7 +620,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
def testLabeledTagMsgResponsesToSelf(self): def testLabeledTagMsgResponsesToSelf(self):
self.connectClient( self.connectClient(
"foo", "foo",
capabilities=["batch", "echo-message", "labeled-response", "message-tags"], capabilities=["echo-message", "labeled-response", "message-tags"],
skip_if_cap_nak=True, skip_if_cap_nak=True,
) )
self.getMessages(1) self.getMessages(1)
@ -647,9 +657,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
).format(number_of_labels), ).format(number_of_labels),
) )
@cases.mark_capabilities( @cases.mark_capabilities("batch", "labeled-response", "message-tags", "server-time")
"echo-message", "labeled-response", "message-tags", "server-time"
)
def testBatchedJoinMessages(self): def testBatchedJoinMessages(self):
self.connectClient( self.connectClient(
"bar", "bar",
@ -689,11 +697,10 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
for message in m[1:-1]: for message in m[1:-1]:
self.assertEqual(message.tags.get("batch"), batch_id) self.assertEqual(message.tags.get("batch"), batch_id)
@cases.mark_specifications("Oragono") @cases.mark_capabilities("labeled-response")
def testNoBatchForSingleMessage(self): def testNoBatchForSingleMessage(self):
self.connectClient( self.connectClient(
"bar", "bar", capabilities=["labeled-response"], skip_if_cap_nak=True
capabilities=["batch", "labeled-response", "message-tags", "server-time"],
) )
self.getMessages(1) self.getMessages(1)
@ -708,11 +715,10 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
# check the label # check the label
self.assertEqual(m.tags.get("label"), "98765") self.assertEqual(m.tags.get("label"), "98765")
@cases.mark_specifications("Oragono") @cases.mark_capabilities("labeled-response")
def testEmptyBatchForNoResponse(self): def testEmptyBatchForNoResponse(self):
self.connectClient( self.connectClient(
"bar", "bar", capabilities=["labeled-response"], skip_if_cap_nak=True
capabilities=["batch", "labeled-response", "message-tags", "server-time"],
) )
self.getMessages(1) self.getMessages(1)

View File

@ -71,9 +71,9 @@ class NoticeTestCase(cases.BaseServerTestCase):
class TagsTestCase(cases.BaseServerTestCase): class TagsTestCase(cases.BaseServerTestCase):
@cases.mark_specifications("Oragono") @cases.mark_capabilities("message-tags")
def testLineTooLong(self): def testLineTooLong(self):
self.connectClient("bar") self.connectClient("bar", capabilities=["message-tags"], skip_if_cap_nak=True)
self.joinChannel(1, "#xyz") self.joinChannel(1, "#xyz")
monsterMessage = "@+clientOnlyTagExample=" + "a" * 4096 + " PRIVMSG #xyz hi!" monsterMessage = "@+clientOnlyTagExample=" + "a" * 4096 + " PRIVMSG #xyz hi!"
self.sendLine(1, monsterMessage) self.sendLine(1, monsterMessage)

View File

@ -5,6 +5,7 @@ class ReadqTestCase(cases.BaseServerTestCase):
"""Test responses to DoS attacks using long lines.""" """Test responses to DoS attacks using long lines."""
@cases.mark_specifications("Oragono") @cases.mark_specifications("Oragono")
@cases.mark_capabilities("message-tags")
def testReadqTags(self): def testReadqTags(self):
self.connectClient("mallory", name="mallory", capabilities=["message-tags"]) self.connectClient("mallory", name="mallory", capabilities=["message-tags"])
self.joinChannel("mallory", "#test") self.joinChannel("mallory", "#test")

View File

@ -13,7 +13,7 @@ from irctest.numerics import (
) )
class WhoisTestCase(cases.BaseServerTestCase): class WhoisTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
@cases.mark_specifications("RFC2812") @cases.mark_specifications("RFC2812")
def testWhoisUser(self): def testWhoisUser(self):
"""Test basic WHOIS behavior""" """Test basic WHOIS behavior"""
@ -40,8 +40,6 @@ class WhoisTestCase(cases.BaseServerTestCase):
) )
self.assertEqual(whois_user.params[5], realname) self.assertEqual(whois_user.params[5], realname)
class InvisibleTestCase(cases.BaseServerTestCase):
@cases.mark_specifications("Oragono") @cases.mark_specifications("Oragono")
def testInvisibleWhois(self): def testInvisibleWhois(self):
"""Test interaction between MODE +i and RPL_WHOISCHANNELS.""" """Test interaction between MODE +i and RPL_WHOISCHANNELS."""
@ -116,12 +114,14 @@ class InvisibleTestCase(cases.BaseServerTestCase):
"RPL_WHOISCHANNELS should be sent for a non-invisible nick", "RPL_WHOISCHANNELS should be sent for a non-invisible nick",
) )
@cases.mark_specifications("Oragono") @cases.OptionalityHelper.skipUnlessHasMechanism("PLAIN")
@cases.mark_specifications("ircdefs")
def testWhoisAccount(self): def testWhoisAccount(self):
"""Test numeric 330, RPL_WHOISACCOUNT.""" """Test numeric 330, RPL_WHOISACCOUNT.
<https://defs.ircdocs.horse/defs/numerics.html#rpl-whoisaccount-330>"""
self.controller.registerUser(self, "shivaram", "sesame") self.controller.registerUser(self, "shivaram", "sesame")
self.connectClient("netcat") self.connectClient("netcat", account="shivaram", password="sesame")
self.sendLine(1, "NS IDENTIFY shivaram sesame")
self.getMessages(1) self.getMessages(1)
self.connectClient("curious") self.connectClient("curious")