fix: rebase onto main, add IRC wire handlers and integration tests for Tier 3 commands
Some checks failed
check / check (push) Failing after 2m10s
Some checks failed
check / check (push) Failing after 2m10s
Rebase onto main to resolve conflicts from module path rename (sneak.berlin/go/neoirc) and integration test addition. - Update import paths in utility.go to new module path - Add IRC wire protocol handlers for VERSION, ADMIN, INFO, TIME, KILL, and WALLOPS to ircserver/commands.go - Register all 6 new commands in the IRC command dispatch map - Implement proper user MODE +w/-w support for WALLOPS - Add WALLOPS relay delivery in relay.go - Add integration tests for all 7 Tier 3 commands: USERHOST, VERSION, ADMIN, INFO, TIME, KILL, WALLOPS - Add newTestEnvWithOper helper for oper-dependent tests
This commit is contained in:
@@ -760,6 +760,288 @@ func TestIntegrationTwoClients(t *testing.T) {
|
||||
)
|
||||
}
|
||||
|
||||
// ── Tier 3 Utility Command Integration Tests ──────────
|
||||
|
||||
// TestIntegrationUserhost verifies the USERHOST command
|
||||
// returns user@host info for connected nicks.
|
||||
func TestIntegrationUserhost(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnv(t)
|
||||
|
||||
alice := env.dial(t)
|
||||
alice.register("alice")
|
||||
|
||||
bob := env.dial(t)
|
||||
bob.register("bob")
|
||||
|
||||
// Query single nick.
|
||||
alice.send("USERHOST bob")
|
||||
|
||||
aliceReply := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 302 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceReply, " 302 ",
|
||||
"RPL_USERHOST",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, "bob",
|
||||
"USERHOST contains queried nick",
|
||||
)
|
||||
|
||||
// Query multiple nicks.
|
||||
bob.send("USERHOST alice bob")
|
||||
|
||||
bobReply := bob.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 302 ")
|
||||
})
|
||||
assertContains(
|
||||
t, bobReply, " 302 ",
|
||||
"RPL_USERHOST multi-nick",
|
||||
)
|
||||
assertContains(
|
||||
t, bobReply, "alice",
|
||||
"USERHOST multi contains alice",
|
||||
)
|
||||
assertContains(
|
||||
t, bobReply, "bob",
|
||||
"USERHOST multi contains bob",
|
||||
)
|
||||
}
|
||||
|
||||
// TestIntegrationVersion verifies the VERSION command
|
||||
// returns the server version string.
|
||||
func TestIntegrationVersion(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnv(t)
|
||||
|
||||
alice := env.dial(t)
|
||||
alice.register("alice")
|
||||
|
||||
alice.send("VERSION")
|
||||
|
||||
aliceReply := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 351 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceReply, " 351 ",
|
||||
"RPL_VERSION",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, "neoirc",
|
||||
"VERSION reply contains server name",
|
||||
)
|
||||
}
|
||||
|
||||
// TestIntegrationAdmin verifies the ADMIN command returns
|
||||
// server admin info (256–259 numerics).
|
||||
func TestIntegrationAdmin(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnv(t)
|
||||
|
||||
alice := env.dial(t)
|
||||
alice.register("alice")
|
||||
|
||||
alice.send("ADMIN")
|
||||
|
||||
aliceReply := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 259 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceReply, " 256 ",
|
||||
"RPL_ADMINME",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, " 257 ",
|
||||
"RPL_ADMINLOC1",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, " 258 ",
|
||||
"RPL_ADMINLOC2",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, " 259 ",
|
||||
"RPL_ADMINEMAIL",
|
||||
)
|
||||
}
|
||||
|
||||
// TestIntegrationInfo verifies the INFO command returns
|
||||
// server information (371/374 numerics).
|
||||
func TestIntegrationInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnv(t)
|
||||
|
||||
alice := env.dial(t)
|
||||
alice.register("alice")
|
||||
|
||||
alice.send("INFO")
|
||||
|
||||
aliceReply := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 374 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceReply, " 371 ",
|
||||
"RPL_INFO",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, " 374 ",
|
||||
"RPL_ENDOFINFO",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, "neoirc",
|
||||
"INFO reply mentions server name",
|
||||
)
|
||||
}
|
||||
|
||||
// TestIntegrationTime verifies the TIME command returns
|
||||
// the server time (391 numeric).
|
||||
func TestIntegrationTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnv(t)
|
||||
|
||||
alice := env.dial(t)
|
||||
alice.register("alice")
|
||||
|
||||
alice.send("TIME")
|
||||
|
||||
aliceReply := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 391 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceReply, " 391 ",
|
||||
"RPL_TIME",
|
||||
)
|
||||
assertContains(
|
||||
t, aliceReply, "test.irc",
|
||||
"TIME reply includes server name",
|
||||
)
|
||||
}
|
||||
|
||||
// TestIntegrationKill verifies the KILL command: oper can
|
||||
// kill a user, non-oper cannot.
|
||||
func TestIntegrationKill(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnvWithOper(t)
|
||||
|
||||
alice := env.dial(t)
|
||||
alice.register("alice")
|
||||
|
||||
bob := env.dial(t)
|
||||
bob.register("bob")
|
||||
|
||||
// Both join a channel so KILL's QUIT is visible.
|
||||
alice.joinAndDrain("#killtest")
|
||||
bob.joinAndDrain("#killtest")
|
||||
|
||||
// Drain alice's view of bob's join.
|
||||
alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, "JOIN") &&
|
||||
strings.Contains(l, "bob")
|
||||
})
|
||||
|
||||
// Non-oper KILL should fail.
|
||||
alice.send("KILL bob :nope")
|
||||
|
||||
aliceKillFail := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 481 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceKillFail, " 481 ",
|
||||
"ERR_NOPRIVILEGES for non-oper KILL",
|
||||
)
|
||||
|
||||
// alice becomes oper.
|
||||
alice.send("OPER testoper testpass")
|
||||
alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 381 ")
|
||||
})
|
||||
|
||||
// Oper KILL should succeed.
|
||||
alice.send("KILL bob :bad behavior")
|
||||
|
||||
// alice should see bob's QUIT relay.
|
||||
aliceSeesQuit := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, "QUIT") &&
|
||||
strings.Contains(l, "bob")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceSeesQuit, "Killed",
|
||||
"KILL reason in QUIT message",
|
||||
)
|
||||
|
||||
// KILL nonexistent nick.
|
||||
alice.send("KILL nobody123 :gone")
|
||||
|
||||
aliceNoSuch := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 401 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceNoSuch, " 401 ",
|
||||
"ERR_NOSUCHNICK for KILL missing target",
|
||||
)
|
||||
}
|
||||
|
||||
// TestIntegrationWallops verifies the WALLOPS command:
|
||||
// oper can broadcast to +w users.
|
||||
func TestIntegrationWallops(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnvWithOper(t)
|
||||
|
||||
alice := env.dial(t)
|
||||
alice.register("alice")
|
||||
|
||||
bob := env.dial(t)
|
||||
bob.register("bob")
|
||||
|
||||
// Non-oper WALLOPS should fail.
|
||||
alice.send("WALLOPS :test broadcast")
|
||||
|
||||
aliceWallopsFail := alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 481 ")
|
||||
})
|
||||
assertContains(
|
||||
t, aliceWallopsFail, " 481 ",
|
||||
"ERR_NOPRIVILEGES for non-oper WALLOPS",
|
||||
)
|
||||
|
||||
// alice becomes oper.
|
||||
alice.send("OPER testoper testpass")
|
||||
alice.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 381 ")
|
||||
})
|
||||
|
||||
// bob sets +w to receive wallops.
|
||||
bob.send("MODE bob +w")
|
||||
bob.readUntil(func(l string) bool {
|
||||
return strings.Contains(l, " 221 ")
|
||||
})
|
||||
|
||||
// alice sends WALLOPS.
|
||||
alice.send("WALLOPS :important announcement")
|
||||
|
||||
// bob (who has +w) should receive it.
|
||||
bobWallops := bob.readUntil(func(l string) bool {
|
||||
return strings.Contains(
|
||||
l, "important announcement",
|
||||
)
|
||||
})
|
||||
assertContains(
|
||||
t, bobWallops, "important announcement",
|
||||
"bob receives WALLOPS message",
|
||||
)
|
||||
assertContains(
|
||||
t, bobWallops, "WALLOPS",
|
||||
"message is WALLOPS command",
|
||||
)
|
||||
}
|
||||
|
||||
// TestIntegrationModeSecret tests +s (secret) channel
|
||||
// mode — verifies that +s can be set and the mode is
|
||||
// reflected in MODE queries.
|
||||
|
||||
Reference in New Issue
Block a user