Skip to content

Commit c533495

Browse files
committed
feat(tests): add ACCOUNT U:line restriction test for PR #62
Add test_account_rejected_from_non_ulined_server which connects a second fake P10 server (notulined.test.net) that has a Connect block but no UWorld entry. Verifies that ACCOUNT from this server gets ERR_NOPRIVILEGES (481) and the user's account is not set. This covers the second half of PR #62: ms_account now requires CONF_UWORLD before accepting ACCOUNT messages.
1 parent 528f605 commit c533495

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

tests/docker/ircd-hub.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ Connect {
4646
class = "Server";
4747
};
4848

49+
Connect {
50+
name = "notulined.test.net";
51+
host = "10.55.0.1";
52+
password = "testpass";
53+
class = "Server";
54+
};
55+
4956
UWorld {
5057
oper = "services.test.net";
5158
};

tests/pr62_remote_x/test_fix.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,69 @@ async def test_remote_opmode_x_without_account(ircd_network, services):
204204
await client.disconnect()
205205

206206

207+
async def test_account_rejected_from_non_ulined_server(ircd_network):
208+
"""ACCOUNT from a non-U:lined server should be rejected with ERR_NOPRIVILEGES.
209+
210+
This is the second change in PR #62: ms_account now checks for a
211+
CONF_UWORLD entry before accepting ACCOUNT. A server without a
212+
UWorld block should get 481 back and the user's account should
213+
not be set.
214+
"""
215+
hub = ircd_network["hub"]
216+
217+
# Connect a non-U:lined fake server (has Connect block but no UWorld)
218+
rogue = P10Server(
219+
name="notulined.test.net",
220+
numeric=5,
221+
password="testpass",
222+
)
223+
await rogue.connect(hub["host"], hub["server_port"])
224+
await rogue.handshake()
225+
226+
# Connect a user to the hub
227+
user = IRCClient()
228+
await user.connect(hub["host"], hub["port"])
229+
await user.register("usr62d", "testuser", "Test User")
230+
231+
# Observer to check WHOIS
232+
observer = IRCClient()
233+
await observer.connect(hub["host"], hub["port"])
234+
await observer.register("obs62d", "testuser", "Test User")
235+
236+
try:
237+
numnick = await rogue.wait_for_user("usr62d")
238+
239+
# Non-U:lined server tries to set ACCOUNT
240+
await rogue.send_account(numnick, "HackedAcct")
241+
await asyncio.sleep(0.5)
242+
243+
# Drain messages from the rogue server — should see 481
244+
await rogue.drain_messages(timeout=1.0)
245+
got_denied = any("481" in line for line in rogue.received)
246+
247+
assert got_denied, (
248+
"Non-U:lined server did not get ERR_NOPRIVILEGES for ACCOUNT — "
249+
"the U:line restriction from PR #62 may not be applied"
250+
)
251+
252+
# Verify the user does NOT have an account set
253+
await observer.send("WHOIS usr62d")
254+
whois = await observer.collect_until("318", timeout=5.0)
255+
acct_replies = [m for m in whois if m.command == "330"]
256+
assert len(acct_replies) == 0, (
257+
f"User should NOT have an account from non-U:lined server: "
258+
f"{acct_replies[0].params if acct_replies else 'none'}"
259+
)
260+
finally:
261+
await rogue.disconnect()
262+
for client in (user, observer):
263+
try:
264+
await client.send("QUIT :cleanup")
265+
except Exception:
266+
pass
267+
await client.disconnect()
268+
269+
207270
async def test_remote_opmode_o_still_works(ircd_network, services):
208271
"""OPMODE +o from U:lined server should still work (regression test).
209272

0 commit comments

Comments
 (0)