mirror of
https://github.com/progval/irctest.git
synced 2025-04-08 00:09:46 +00:00
secret channel test (#135)
* silent.py tests for channels with mode +s appearing in LIST only when the user is connected to that channel * Added assertions for exact content of lines with command RPL_LIST and checks for exact number of RPL_LIST replies * fix linter errors * only validate the first two parameters of RPL_LIST * rename to secret channel test, add citation * ignore ngircd pseudo-channel * attempt to fix charybdis/solanum and ircu issues * review fixes Co-authored-by: William Rehwinkel <willrehwinkel@gmail.com>
This commit is contained in:
committed by
GitHub
parent
da005d7d24
commit
7e112359a2
@ -12,6 +12,9 @@ serverinfo {{
|
|||||||
|
|
||||||
general {{
|
general {{
|
||||||
throttle_count = 100; # We need to connect lots of clients quickly
|
throttle_count = 100; # We need to connect lots of clients quickly
|
||||||
|
# disable throttling for LIST and similar:
|
||||||
|
pace_wait_simple = 0 second;
|
||||||
|
pace_wait = 0 second;
|
||||||
sasl_service = "SaslServ";
|
sasl_service = "SaslServ";
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
55
irctest/server_tests/chmodes/secret.py
Normal file
55
irctest/server_tests/chmodes/secret.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
from irctest import cases
|
||||||
|
from irctest.numerics import RPL_LIST
|
||||||
|
|
||||||
|
|
||||||
|
class SecretChannelTestCase(cases.BaseServerTestCase):
|
||||||
|
@cases.mark_specifications("RFC1459", "Modern")
|
||||||
|
def testSecretChannelListCommand(self):
|
||||||
|
"""
|
||||||
|
<https://datatracker.ietf.org/doc/html/rfc1459#section-4.2.6>
|
||||||
|
|
||||||
|
"Likewise, secret channels are not listed
|
||||||
|
at all unless the client is a member of the channel in question."
|
||||||
|
|
||||||
|
<https://modern.ircdocs.horse/#secret-channel-mode>
|
||||||
|
"A channel that is set to secret will not show up in responses to
|
||||||
|
the LIST or NAMES command unless the client sending the command is
|
||||||
|
joined to the channel."
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_listed_channels(replies):
|
||||||
|
channels = set()
|
||||||
|
for reply in replies:
|
||||||
|
# skip pseudo-channels (&SERVER, &NOTICES) listed by ngircd
|
||||||
|
# and ircu:
|
||||||
|
if reply.command == RPL_LIST and reply.params[1].startswith("#"):
|
||||||
|
channels.add(reply.params[1])
|
||||||
|
return channels
|
||||||
|
|
||||||
|
# test that a silent channel is shown in list if the user is in the channel.
|
||||||
|
self.connectClient("first", name="first")
|
||||||
|
self.joinChannel("first", "#gen")
|
||||||
|
self.getMessages("first")
|
||||||
|
self.sendLine("first", "MODE #gen +s")
|
||||||
|
# run command LIST
|
||||||
|
self.sendLine("first", "LIST")
|
||||||
|
replies = self.getMessages("first")
|
||||||
|
self.assertEqual(get_listed_channels(replies), {"#gen"})
|
||||||
|
|
||||||
|
# test that another client would not see the secret
|
||||||
|
# channel.
|
||||||
|
self.connectClient("second", name="second")
|
||||||
|
self.getMessages("second")
|
||||||
|
self.sendLine("second", "LIST")
|
||||||
|
replies = self.getMessages("second")
|
||||||
|
# RPL_LIST 322 should NOT be present this time.
|
||||||
|
self.assertEqual(get_listed_channels(replies), set())
|
||||||
|
|
||||||
|
# Second client will join the secret channel
|
||||||
|
# and call command LIST. The channel SHOULD
|
||||||
|
# appear this time.
|
||||||
|
self.joinChannel("second", "#gen")
|
||||||
|
self.sendLine("second", "LIST")
|
||||||
|
replies = self.getMessages("second")
|
||||||
|
# Should be only one line with command RPL_LIST
|
||||||
|
self.assertEqual(get_listed_channels(replies), {"#gen"})
|
@ -15,8 +15,8 @@ class ListTestCase(cases.BaseServerTestCase):
|
|||||||
if m.command == "321":
|
if m.command == "321":
|
||||||
# skip RPL_LISTSTART
|
# skip RPL_LISTSTART
|
||||||
m = self.getMessage(2)
|
m = self.getMessage(2)
|
||||||
while m.command == "322" and m.params[1] == "&SERVER":
|
# skip local pseudo-channels listed by ngircd and ircu
|
||||||
# ngircd adds this pseudo-channel
|
while m.command == "322" and m.params[1].startswith("&"):
|
||||||
m = self.getMessage(2)
|
m = self.getMessage(2)
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
m.command,
|
m.command,
|
||||||
@ -58,8 +58,8 @@ class ListTestCase(cases.BaseServerTestCase):
|
|||||||
"nor 323 (RPL_LISTEND) but: {msg}",
|
"nor 323 (RPL_LISTEND) but: {msg}",
|
||||||
)
|
)
|
||||||
m = self.getMessage(2)
|
m = self.getMessage(2)
|
||||||
while m.command == "322" and m.params[1] == "&SERVER":
|
# skip local pseudo-channels listed by ngircd and ircu
|
||||||
# ngircd adds this pseudo-channel
|
while m.command == "322" and m.params[1].startswith("&"):
|
||||||
m = self.getMessage(2)
|
m = self.getMessage(2)
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
m.command,
|
m.command,
|
||||||
|
Reference in New Issue
Block a user