Skip to content

Commit e9e37f5

Browse files
authored
basic test case for KILL (#302)
1 parent 2b6b666 commit e9e37f5

File tree

4 files changed

+70
-3
lines changed

4 files changed

+70
-3
lines changed

irctest/controllers/charybdis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class = "server";
6060
privs = oper:general, oper:privs, oper:testline, oper:kill, oper:operwall, oper:message,
6161
oper:routing, oper:kline, oper:unkline, oper:xline,
6262
oper:resv, oper:cmodes, oper:mass_notice, oper:wallops,
63-
oper:remoteban,
63+
oper:remoteban, oper:local_kill,
6464
usermode:servnotice, auspex:oper, auspex:hostname, auspex:umodes, auspex:cmodes,
6565
oper:admin, oper:die, oper:rehash, oper:spy, oper:grant;
6666
}};

irctest/controllers/inspircd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
<class
2121
name="ServerOperators"
22-
commands="WALLOPS GLOBOPS"
22+
commands="WALLOPS GLOBOPS KILL"
2323
privs="channels/auspex users/auspex channels/auspex servers/auspex"
2424
>
2525
<type

irctest/controllers/irc2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
I::{password_field}:::10::
2525
2626
# O:<TARGET Host NAME>:<Password>:<Nickname>:<Port>:<Class>:<Flags>:
27-
O:*:operpassword:operuser::::
27+
O:*:operpassword:operuser:::K:
2828
"""
2929

3030

irctest/server_tests/kill.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
The KILL command (`Modern <https://modern.ircdocs.horse/#kill-message>`__)
3+
"""
4+
5+
6+
from irctest import cases
7+
from irctest.numerics import ERR_NOPRIVILEGES, RPL_YOUREOPER
8+
9+
10+
class KillTestCase(cases.BaseServerTestCase):
11+
@cases.mark_specifications("Modern")
12+
@cases.xfailIfSoftware(["Sable"], "https://github.com/Libera-Chat/sable/issues/154")
13+
def testKill(self):
14+
self.connectClient("ircop", name="ircop")
15+
self.connectClient("alice", name="alice")
16+
self.connectClient("bob", name="bob")
17+
18+
self.sendLine("ircop", "OPER operuser operpassword")
19+
self.assertIn(
20+
RPL_YOUREOPER,
21+
[m.command for m in self.getMessages("ircop")],
22+
fail_msg="OPER failed",
23+
)
24+
25+
self.sendLine("alice", "KILL bob :some arbitrary reason")
26+
self.assertIn(
27+
ERR_NOPRIVILEGES,
28+
[m.command for m in self.getMessages("alice")],
29+
fail_msg="unprivileged KILL not rejected",
30+
)
31+
# bob is not killed
32+
self.getMessages("bob")
33+
34+
self.sendLine("alice", "KILL alice :some arbitrary reason")
35+
self.assertIn(
36+
ERR_NOPRIVILEGES,
37+
[m.command for m in self.getMessages("alice")],
38+
fail_msg="unprivileged KILL not rejected",
39+
)
40+
# alice is not killed
41+
self.getMessages("alice")
42+
43+
# privileged KILL should succeed
44+
self.sendLine("ircop", "KILL alice :some arbitrary reason")
45+
self.getMessages("ircop")
46+
self.assertDisconnected("alice")
47+
48+
self.sendLine("ircop", "KILL bob :some arbitrary reason")
49+
self.getMessages("ircop")
50+
self.assertDisconnected("bob")
51+
52+
@cases.mark_specifications("Ergo")
53+
def testKillOneArgument(self):
54+
self.connectClient("ircop", name="ircop")
55+
self.connectClient("alice", name="alice")
56+
57+
self.sendLine("ircop", "OPER operuser operpassword")
58+
self.assertIn(
59+
RPL_YOUREOPER,
60+
[m.command for m in self.getMessages("ircop")],
61+
fail_msg="OPER failed",
62+
)
63+
64+
# 1-argument kill command, accepted by Ergo and some implementations
65+
self.sendLine("ircop", "KILL alice")
66+
self.getMessages("ircop")
67+
self.assertDisconnected("alice")

0 commit comments

Comments
 (0)