mirror of
https://github.com/progval/irctest.git
synced 2025-04-04 22:39:50 +00:00
Add tests for LINKS (#147)
This commit is contained in:
@ -83,7 +83,7 @@ TEMPLATE_CONFIG = """
|
||||
|
||||
# Misc:
|
||||
<log method="file" type="*" level="debug" target="/tmp/ircd-{port}.log">
|
||||
<server name="My.Little.Server" description="testnet" id="000" network="testnet">
|
||||
<server name="My.Little.Server" description="test server" id="000" network="testnet">
|
||||
"""
|
||||
|
||||
TEMPLATE_SSL_CONFIG = """
|
||||
|
@ -10,7 +10,7 @@ from irctest.basecontrollers import (
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
# M:<Server NAME>:<YOUR Internet IP#>:<Geographic Location>:<Port>:<SID>:
|
||||
M:My.Little.Server:{hostname}:Somewhere:{port}:0042:
|
||||
M:My.Little.Server:{hostname}:test server:{port}:0042:
|
||||
|
||||
# A:<Your Name/Location>:<Your E-Mail Addr>:<other info>::<network name>:
|
||||
A:Organization, IRC dept.:Daemon <ircd@example.irc.org>:Client Server::IRCnet:
|
||||
|
@ -12,7 +12,7 @@ from irctest.irc_utils.junkdrawer import find_hostname_and_port
|
||||
TEMPLATE_CONFIG = """
|
||||
[Global]
|
||||
Name = My.Little.Server
|
||||
Info = ExampleNET Server
|
||||
Info = test server
|
||||
Bind = {hostname}
|
||||
Ports = {port}
|
||||
AdminInfo1 = Bob Smith
|
||||
|
@ -22,7 +22,7 @@ include "help/help.conf";
|
||||
|
||||
me {{
|
||||
name "My.Little.Server";
|
||||
info "ExampleNET Server";
|
||||
info "test server";
|
||||
sid "001";
|
||||
}}
|
||||
admin {{
|
||||
|
136
irctest/server_tests/links.py
Normal file
136
irctest/server_tests/links.py
Normal file
@ -0,0 +1,136 @@
|
||||
from irctest import cases, runner
|
||||
from irctest.numerics import ERR_UNKNOWNCOMMAND, RPL_ENDOFLINKS, RPL_LINKS
|
||||
from irctest.patma import ANYSTR, StrRe
|
||||
|
||||
|
||||
class LinksTestCase(cases.BaseServerTestCase):
|
||||
@cases.mark_specifications("RFC1459", "RFC2812", "Modern")
|
||||
def testLinksSingleServer(self):
|
||||
"""
|
||||
Only testing the parameter-less case.
|
||||
|
||||
https://datatracker.ietf.org/doc/html/rfc1459#section-4.3.3
|
||||
https://datatracker.ietf.org/doc/html/rfc2812#section-3.4.5
|
||||
https://github.com/ircdocs/modern-irc/pull/175
|
||||
|
||||
"
|
||||
364 RPL_LINKS
|
||||
"<mask> <server> :<hopcount> <server info>"
|
||||
365 RPL_ENDOFLINKS
|
||||
"<mask> :End of /LINKS list"
|
||||
|
||||
- In replying to the LINKS message, a server must send
|
||||
replies back using the RPL_LINKS numeric and mark the
|
||||
end of the list using an RPL_ENDOFLINKS reply.
|
||||
"
|
||||
-- https://datatracker.ietf.org/doc/html/rfc1459#page-51
|
||||
-- https://datatracker.ietf.org/doc/html/rfc2812#page-48
|
||||
|
||||
RPL_LINKS: "<client> * <server> :<hopcount> <server info>"
|
||||
RPL_ENDOFLINKS: "<client> * :End of /LINKS list"
|
||||
-- https://github.com/ircdocs/modern-irc/pull/175/files
|
||||
"""
|
||||
self.connectClient("nick")
|
||||
self.sendLine(1, "LINKS")
|
||||
messages = self.getMessages(1)
|
||||
if messages[0].command == ERR_UNKNOWNCOMMAND:
|
||||
raise runner.NotImplementedByController("LINKS")
|
||||
|
||||
# Ignore '/LINKS has been disabled' from ircu2
|
||||
messages = [m for m in messages if m.command != "NOTICE"]
|
||||
|
||||
self.assertMessageMatch(
|
||||
messages.pop(-1),
|
||||
command=RPL_ENDOFLINKS,
|
||||
params=["nick", "*", ANYSTR],
|
||||
)
|
||||
|
||||
if not messages:
|
||||
# This server probably redacts links
|
||||
return
|
||||
|
||||
self.assertMessageMatch(
|
||||
messages[0],
|
||||
command=RPL_LINKS,
|
||||
params=[
|
||||
"nick",
|
||||
"My.Little.Server",
|
||||
"My.Little.Server",
|
||||
StrRe("0 (0042 )?test server"),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@cases.mark_services
|
||||
class ServicesLinksTestCase(cases.BaseServerTestCase):
|
||||
# On every IRCd but Ergo, services are linked.
|
||||
# Ergo does not implement LINKS at all, so this test is skipped.
|
||||
@cases.mark_specifications("RFC1459", "RFC2812", "Modern")
|
||||
def testLinksWithServices(self):
|
||||
"""
|
||||
Only testing the parameter-less case.
|
||||
|
||||
https://datatracker.ietf.org/doc/html/rfc1459#section-4.3.3
|
||||
https://datatracker.ietf.org/doc/html/rfc2812#section-3.4.5
|
||||
|
||||
"
|
||||
364 RPL_LINKS
|
||||
"<mask> <server> :<hopcount> <server info>"
|
||||
365 RPL_ENDOFLINKS
|
||||
"<mask> :End of /LINKS list"
|
||||
|
||||
- In replying to the LINKS message, a server must send
|
||||
replies back using the RPL_LINKS numeric and mark the
|
||||
end of the list using an RPL_ENDOFLINKS reply.
|
||||
"
|
||||
-- https://datatracker.ietf.org/doc/html/rfc1459#page-51
|
||||
-- https://datatracker.ietf.org/doc/html/rfc2812#page-48
|
||||
|
||||
RPL_LINKS: "<client> * <server> :<hopcount> <server info>"
|
||||
RPL_ENDOFLINKS: "<client> * :End of /LINKS list"
|
||||
-- https://github.com/ircdocs/modern-irc/pull/175/files
|
||||
"""
|
||||
self.connectClient("nick")
|
||||
self.sendLine(1, "LINKS")
|
||||
messages = self.getMessages(1)
|
||||
|
||||
if messages[0].command == ERR_UNKNOWNCOMMAND:
|
||||
raise runner.NotImplementedByController("LINKS")
|
||||
|
||||
# Ignore '/LINKS has been disabled' from ircu2
|
||||
messages = [m for m in messages if m.command != "NOTICE"]
|
||||
|
||||
self.assertMessageMatch(
|
||||
messages.pop(-1),
|
||||
command=RPL_ENDOFLINKS,
|
||||
params=["nick", "*", ANYSTR],
|
||||
)
|
||||
|
||||
if not messages:
|
||||
# This server redacts links
|
||||
return
|
||||
|
||||
messages.sort(key=lambda m: m.params[-1])
|
||||
|
||||
self.assertMessageMatch(
|
||||
messages.pop(0),
|
||||
command=RPL_LINKS,
|
||||
params=[
|
||||
"nick",
|
||||
"My.Little.Server",
|
||||
"My.Little.Server",
|
||||
StrRe("0 (0042 )?test server"),
|
||||
],
|
||||
)
|
||||
self.assertMessageMatch(
|
||||
messages.pop(0),
|
||||
command=RPL_LINKS,
|
||||
params=[
|
||||
"nick",
|
||||
"services.example.org",
|
||||
"My.Little.Server",
|
||||
StrRe("1 .+"), # SID instead of description for Anope...
|
||||
],
|
||||
)
|
||||
|
||||
self.assertEqual(messages, [])
|
Reference in New Issue
Block a user