Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testLineTooLong: Also check with an egregiously long line #286

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions irctest/server_tests/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
The PRIVMSG and NOTICE commands.
"""

import pytest

from irctest import cases
from irctest.numerics import ERR_INPUTTOOLONG
from irctest.patma import ANYSTR
Expand Down Expand Up @@ -123,26 +125,31 @@ def testNoticeNonexistentChannel(self):


class TagsTestCase(cases.BaseServerTestCase):
@pytest.mark.parametrize("tag_length", [4096, 10000])
@cases.mark_capabilities("message-tags")
@cases.xfailIf(
lambda self: bool(
lambda self, tag_length: bool(
self.controller.software_name == "UnrealIRCd"
and self.controller.software_version == 5
),
"UnrealIRCd <6.0.7 dropped messages with excessively large tags: "
"https://bugs.unrealircd.org/view.php?id=5947",
)
def testLineTooLong(self):
def testLineTooLong(self, tag_length):
self.connectClient("bar", capabilities=["message-tags"], skip_if_cap_nak=True)
self.connectClient(
"recver", capabilities=["message-tags"], skip_if_cap_nak=True
)
self.joinChannel(1, "#xyz")
monsterMessage = "@+clientOnlyTagExample=" + "a" * 4096 + " PRIVMSG #xyz hi!"

monsterMessage = (
"@+clientOnlyTagExample=" + "a" * tag_length + " PRIVMSG #xyz hi!"
)
self.sendLine(1, monsterMessage)
self.assertEqual(self.getMessages(2), [], "overflowing message was relayed")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this check should be done after self.getMessages(1) so it doesn't race.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replies = self.getMessages(1)
self.assertIn(ERR_INPUTTOOLONG, set(reply.command for reply in replies))
if len(replies) > 0:
self.assertIn(ERR_INPUTTOOLONG, set(reply.command for reply in replies))


class LengthLimitTestCase(cases.BaseServerTestCase):
Expand Down
Loading