|
| 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