-
Notifications
You must be signed in to change notification settings - Fork 13
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
test that CAP LS 301 responses are only one line #205
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
progval
reviewed
May 31, 2023
irctest/server_tests/cap.py
Outdated
Comment on lines
246
to
272
@cases.mark_specifications("IRCv3") | ||
def testNoMultiline301Response(self): | ||
""" | ||
Current version: "If the client supports CAP version 302, the server MAY send | ||
multiple lines in response to CAP LS and CAP LIST." This should be read as | ||
disallowing multiline responses to pre-302 clients. | ||
-- <https://ircv3.net/specs/extensions/capability-negotiation#multiline-replies-to-cap-ls-and-cap-list> | ||
""" # noqa | ||
self.check301ResponsePreRegistration("bar") | ||
self.check301ResponsePreRegistration("qux", "CAP LS 301") | ||
self.check301ResponsePostRegistration("baz") | ||
self.check301ResponsePostRegistration("bat", "CAP LS 301") | ||
|
||
def check301ResponsePreRegistration(self, nick, cap_ls="CAP LS"): | ||
self.addClient(nick) | ||
self.sendLine(nick, cap_ls) | ||
self.sendLine(nick, "NICK " + nick) | ||
self.sendLine(nick, "USER u s e r") | ||
self.sendLine(nick, "CAP END") | ||
responses = [msg for msg in self.skipToWelcome(nick) if msg.command == "CAP"] | ||
self.assertLessEqual(len(responses), 1, responses) | ||
|
||
def check301ResponsePostRegistration(self, nick, cap_ls="CAP LS"): | ||
self.connectClient(nick, name=nick) | ||
self.sendLine(nick, cap_ls) | ||
responses = [msg for msg in self.getMessages(nick) if msg.command == "CAP"] | ||
self.assertLessEqual(len(responses), 1, responses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
@cases.mark_specifications("IRCv3") | |
def testNoMultiline301Response(self): | |
""" | |
Current version: "If the client supports CAP version 302, the server MAY send | |
multiple lines in response to CAP LS and CAP LIST." This should be read as | |
disallowing multiline responses to pre-302 clients. | |
-- <https://ircv3.net/specs/extensions/capability-negotiation#multiline-replies-to-cap-ls-and-cap-list> | |
""" # noqa | |
self.check301ResponsePreRegistration("bar") | |
self.check301ResponsePreRegistration("qux", "CAP LS 301") | |
self.check301ResponsePostRegistration("baz") | |
self.check301ResponsePostRegistration("bat", "CAP LS 301") | |
def check301ResponsePreRegistration(self, nick, cap_ls="CAP LS"): | |
self.addClient(nick) | |
self.sendLine(nick, cap_ls) | |
self.sendLine(nick, "NICK " + nick) | |
self.sendLine(nick, "USER u s e r") | |
self.sendLine(nick, "CAP END") | |
responses = [msg for msg in self.skipToWelcome(nick) if msg.command == "CAP"] | |
self.assertLessEqual(len(responses), 1, responses) | |
def check301ResponsePostRegistration(self, nick, cap_ls="CAP LS"): | |
self.connectClient(nick, name=nick) | |
self.sendLine(nick, cap_ls) | |
responses = [msg for msg in self.getMessages(nick) if msg.command == "CAP"] | |
self.assertLessEqual(len(responses), 1, responses) | |
@cases.mark_specifications("IRCv3") | |
def testNoMultiline301Response(self): | |
""" | |
Current version: "If the client supports CAP version 302, the server MAY send | |
multiple lines in response to CAP LS and CAP LIST." This should be read as | |
disallowing multiline responses to pre-302 clients. | |
-- <https://ircv3.net/specs/extensions/capability-negotiation#multiline-replies-to-cap-ls-and-cap-list> | |
""" # noqa | |
self.check301ResponsePreRegistration("bar", "CAP LS") | |
self.check301ResponsePreRegistration("qux", "CAP LS 301") | |
self.check301ResponsePostRegistration("baz", "CAP LS") | |
self.check301ResponsePostRegistration("bat", "CAP LS 301") | |
def check301ResponsePreRegistration(self, nick, cap_ls): | |
self.addClient(nick) | |
self.sendLine(nick, cap_ls) | |
self.sendLine(nick, "NICK " + nick) | |
self.sendLine(nick, "USER u s e r") | |
self.sendLine(nick, "CAP END") | |
responses = [msg for msg in self.skipToWelcome(nick) if msg.command == "CAP"] | |
self.assertLessEqual(len(responses), 1, responses) | |
def check301ResponsePostRegistration(self, nick, cap_ls): | |
self.connectClient(nick, name=nick) | |
self.sendLine(nick, cap_ls) | |
responses = [msg for msg in self.getMessages(nick) if msg.command == "CAP"] | |
self.assertLessEqual(len(responses), 1, responses) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Can confirm that all four of these assertions are currently broken in Ergo's master; the proximate cause is ergochat/ergo#2065 , the root cause is, well, Ergo's willingness to emit an incorrect response.