mirror of
https://github.com/progval/irctest.git
synced 2025-04-05 14:59:49 +00:00
Make all remaining tests not Oragono-specific when relevant.
This commit is contained in:
@ -460,6 +460,7 @@ class BaseServerTestCase(_IrcTestCase):
|
||||
capabilities=None,
|
||||
skip_if_cap_nak=False,
|
||||
show_io=None,
|
||||
account=None,
|
||||
password=None,
|
||||
ident="username",
|
||||
):
|
||||
@ -482,7 +483,7 @@ class BaseServerTestCase(_IrcTestCase):
|
||||
self.sendLine(client, "CAP END")
|
||||
if password is not None:
|
||||
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, "USER %s * * :Realname" % (ident,))
|
||||
|
||||
|
@ -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>
|
||||
"""
|
||||
|
||||
@ -8,29 +11,36 @@ from irctest import cases
|
||||
|
||||
|
||||
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):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(2)
|
||||
self.connectClient(
|
||||
"carl",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(3)
|
||||
self.connectClient(
|
||||
"alice",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(4)
|
||||
@ -96,13 +106,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledPrivmsgResponsesToClient(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(2)
|
||||
@ -156,13 +166,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledPrivmsgResponsesToChannel(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(2)
|
||||
@ -224,7 +234,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledPrivmsgResponsesToSelf(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
@ -267,13 +277,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledNoticeResponsesToClient(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(2)
|
||||
@ -327,13 +337,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledNoticeResponsesToChannel(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(2)
|
||||
@ -395,7 +405,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledNoticeResponsesToSelf(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
capabilities=["echo-message", "labeled-response"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
@ -436,13 +446,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledTagMsgResponsesToClient(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response", "message-tags"],
|
||||
capabilities=["echo-message", "labeled-response", "message-tags"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response", "message-tags"],
|
||||
capabilities=["echo-message", "labeled-response", "message-tags"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(2)
|
||||
@ -544,13 +554,13 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledTagMsgResponsesToChannel(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response", "message-tags"],
|
||||
capabilities=["echo-message", "labeled-response", "message-tags"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response", "message-tags"],
|
||||
capabilities=["echo-message", "labeled-response", "message-tags"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(2)
|
||||
@ -610,7 +620,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
def testLabeledTagMsgResponsesToSelf(self):
|
||||
self.connectClient(
|
||||
"foo",
|
||||
capabilities=["batch", "echo-message", "labeled-response", "message-tags"],
|
||||
capabilities=["echo-message", "labeled-response", "message-tags"],
|
||||
skip_if_cap_nak=True,
|
||||
)
|
||||
self.getMessages(1)
|
||||
@ -647,9 +657,7 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
).format(number_of_labels),
|
||||
)
|
||||
|
||||
@cases.mark_capabilities(
|
||||
"echo-message", "labeled-response", "message-tags", "server-time"
|
||||
)
|
||||
@cases.mark_capabilities("batch", "labeled-response", "message-tags", "server-time")
|
||||
def testBatchedJoinMessages(self):
|
||||
self.connectClient(
|
||||
"bar",
|
||||
@ -689,11 +697,10 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
for message in m[1:-1]:
|
||||
self.assertEqual(message.tags.get("batch"), batch_id)
|
||||
|
||||
@cases.mark_specifications("Oragono")
|
||||
@cases.mark_capabilities("labeled-response")
|
||||
def testNoBatchForSingleMessage(self):
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "labeled-response", "message-tags", "server-time"],
|
||||
"bar", capabilities=["labeled-response"], skip_if_cap_nak=True
|
||||
)
|
||||
self.getMessages(1)
|
||||
|
||||
@ -708,11 +715,10 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
|
||||
# check the label
|
||||
self.assertEqual(m.tags.get("label"), "98765")
|
||||
|
||||
@cases.mark_specifications("Oragono")
|
||||
@cases.mark_capabilities("labeled-response")
|
||||
def testEmptyBatchForNoResponse(self):
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "labeled-response", "message-tags", "server-time"],
|
||||
"bar", capabilities=["labeled-response"], skip_if_cap_nak=True
|
||||
)
|
||||
self.getMessages(1)
|
||||
|
||||
|
@ -71,9 +71,9 @@ class NoticeTestCase(cases.BaseServerTestCase):
|
||||
|
||||
|
||||
class TagsTestCase(cases.BaseServerTestCase):
|
||||
@cases.mark_specifications("Oragono")
|
||||
@cases.mark_capabilities("message-tags")
|
||||
def testLineTooLong(self):
|
||||
self.connectClient("bar")
|
||||
self.connectClient("bar", capabilities=["message-tags"], skip_if_cap_nak=True)
|
||||
self.joinChannel(1, "#xyz")
|
||||
monsterMessage = "@+clientOnlyTagExample=" + "a" * 4096 + " PRIVMSG #xyz hi!"
|
||||
self.sendLine(1, monsterMessage)
|
||||
|
@ -5,6 +5,7 @@ class ReadqTestCase(cases.BaseServerTestCase):
|
||||
"""Test responses to DoS attacks using long lines."""
|
||||
|
||||
@cases.mark_specifications("Oragono")
|
||||
@cases.mark_capabilities("message-tags")
|
||||
def testReadqTags(self):
|
||||
self.connectClient("mallory", name="mallory", capabilities=["message-tags"])
|
||||
self.joinChannel("mallory", "#test")
|
||||
|
@ -13,7 +13,7 @@ from irctest.numerics import (
|
||||
)
|
||||
|
||||
|
||||
class WhoisTestCase(cases.BaseServerTestCase):
|
||||
class WhoisTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
@cases.mark_specifications("RFC2812")
|
||||
def testWhoisUser(self):
|
||||
"""Test basic WHOIS behavior"""
|
||||
@ -40,8 +40,6 @@ class WhoisTestCase(cases.BaseServerTestCase):
|
||||
)
|
||||
self.assertEqual(whois_user.params[5], realname)
|
||||
|
||||
|
||||
class InvisibleTestCase(cases.BaseServerTestCase):
|
||||
@cases.mark_specifications("Oragono")
|
||||
def testInvisibleWhois(self):
|
||||
"""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",
|
||||
)
|
||||
|
||||
@cases.mark_specifications("Oragono")
|
||||
@cases.OptionalityHelper.skipUnlessHasMechanism("PLAIN")
|
||||
@cases.mark_specifications("ircdefs")
|
||||
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.connectClient("netcat")
|
||||
self.sendLine(1, "NS IDENTIFY shivaram sesame")
|
||||
self.connectClient("netcat", account="shivaram", password="sesame")
|
||||
self.getMessages(1)
|
||||
|
||||
self.connectClient("curious")
|
||||
|
Reference in New Issue
Block a user