Add tests for error cases of WHOWAS. (#139)

This commit is contained in:
Val Lorentz 2022-03-19 22:12:25 +01:00 committed by GitHub
parent b63ead9546
commit f606c075f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 0 deletions

View File

@ -29,6 +29,7 @@ BAHAMUT_SELECTORS := \
# AccountTagTestCase.testInvite fails because https://github.com/solanum-ircd/solanum/issues/166
# testKickDefaultComment fails because it uses the nick of the kickee rather than the kicker.
# testWhoisNumerics[oper] fails because charybdis uses RPL_WHOISSPECIAL instead of RPL_WHOISOPERATOR
# testWhowasNoSuchNick fails because of a typo (solved in https://github.com/solanum-ircd/solanum/commit/08b7b6bd7e60a760ad47b58cbe8075b45d66166f)
CHARYBDIS_SELECTORS := \
not Ergo \
and not deprecated \
@ -37,6 +38,7 @@ CHARYBDIS_SELECTORS := \
and not testKickDefaultComment \
and not (AccountTagTestCase and testInvite) \
and not (testWhoisNumerics and oper) \
and not testWhowasNoSuchNick \
$(EXTRA_SELECTORS)
# testInfoNosuchserver does not apply to Ergo: Ergo ignores the optional <target> argument

View File

@ -1,6 +1,8 @@
from irctest import cases
from irctest.exceptions import ConnectionClosed
from irctest.numerics import (
ERR_NONICKNAMEGIVEN,
ERR_WASNOSUCHNICK,
RPL_ENDOFWHOWAS,
RPL_WHOISACTUALLY,
RPL_WHOISSERVER,
@ -202,3 +204,64 @@ class WhowasTestCase(cases.BaseServerTestCase):
-- https://datatracker.ietf.org/doc/html/rfc2812#section-3.6.3
"""
self._testWhowasMultiple(second_result=True, whowas_command="WHOWAS *ck2")
@cases.mark_specifications("RFC1459", "RFC2812", deprecated=True)
def testWhowasNoParam(self):
"""
https://datatracker.ietf.org/doc/html/rfc1459#section-4.5.3
https://datatracker.ietf.org/doc/html/rfc2812#section-3.6.3
and:
"At the end of all reply batches, there must be RPL_ENDOFWHOWAS
(even if there was only one reply and it was an error)."
-- https://datatracker.ietf.org/doc/html/rfc1459#page-50
-- https://datatracker.ietf.org/doc/html/rfc2812#page-45
"""
# But no one seems to follow this. Most implementations use ERR_NEEDMOREPARAMS
# instead of ERR_NONICKNAMEGIVEN; and I couldn't find any that returns
# RPL_ENDOFWHOWAS either way.
self.connectClient("nick1")
self.sendLine(1, "WHOWAS")
self.assertMessageMatch(
self.getMessage(1),
command=ERR_NONICKNAMEGIVEN,
params=["nick1", ANYSTR],
)
self.assertMessageMatch(
self.getMessage(1),
command=RPL_ENDOFWHOWAS,
params=["nick1", "nick2", ANYSTR],
)
@cases.mark_specifications("RFC1459", "RFC2812")
def testWhowasNoSuchNick(self):
"""
https://datatracker.ietf.org/doc/html/rfc1459#section-4.5.3
https://datatracker.ietf.org/doc/html/rfc2812#section-3.6.3
and:
"At the end of all reply batches, there must be RPL_ENDOFWHOWAS
(even if there was only one reply and it was an error)."
-- https://datatracker.ietf.org/doc/html/rfc1459#page-50
-- https://datatracker.ietf.org/doc/html/rfc2812#page-45
"""
self.connectClient("nick1")
self.sendLine(1, "WHOWAS nick2")
self.assertMessageMatch(
self.getMessage(1),
command=ERR_WASNOSUCHNICK,
params=["nick1", "nick2", ANYSTR],
)
self.assertMessageMatch(
self.getMessage(1),
command=RPL_ENDOFWHOWAS,
params=["nick1", "nick2", ANYSTR],
)