Share the ADMIN text and KILL reason, and test the review's gaps
check / check (push) Waiting to run

ADMIN's location and email lines come from service.AdminLines, and
KillUser applies the default reason, so both transports send the same
reply. The Disconnect test now allows a quarter of one write window,
so a Disconnect that writes before returning fails it. QueryUserMode
and UserhostReply are tested with a read that fails. The handler tests
again cover USERHOST for a nick with no session, MODE +o on your own
nick, and the status of a successful KILL. handleMode's comment says
what it does.

Model: opus-5-5
This commit is contained in:
2026-10-08 03:01:13 +00:00
parent a7faabb68f
commit c0eef92d23
8 changed files with 70 additions and 18 deletions
+3 -2
View File
@@ -1951,8 +1951,9 @@ func (hdlr *Handlers) handleQuit(
http.StatusOK)
}
// handleMode handles the MODE command for channels and
// users. Currently supports query-only (no mode changes).
// handleMode handles the MODE command: a target that starts
// with # is a channel, handled by handleChannelMode, and any
// other target a nick, handled by handleUserMode.
func (hdlr *Handlers) handleMode(
writer http.ResponseWriter,
request *http.Request,
+5 -7
View File
@@ -106,22 +106,20 @@ func (hdlr *Handlers) handleAdmin(
) {
ctx := request.Context()
srvName := hdlr.serverName()
location1, location2, email := hdlr.svc.AdminLines(srvName)
hdlr.enqueueNumeric(
ctx, clientID, irc.RplAdminMe, nick,
[]string{srvName}, "Administrative info",
)
hdlr.enqueueNumeric(
ctx, clientID, irc.RplAdminLoc1, nick, nil,
"neoirc server",
ctx, clientID, irc.RplAdminLoc1, nick, nil, location1,
)
hdlr.enqueueNumeric(
ctx, clientID, irc.RplAdminLoc2, nick, nil,
"IRC over HTTP",
ctx, clientID, irc.RplAdminLoc2, nick, nil, location2,
)
hdlr.enqueueNumeric(
ctx, clientID, irc.RplAdminEmail, nick, nil,
"admin@"+srvName,
ctx, clientID, irc.RplAdminEmail, nick, nil, email,
)
hdlr.broker.Notify(sessionID)
hdlr.respondJSON(writer, request,
@@ -199,7 +197,7 @@ func (hdlr *Handlers) handleKill(
return
}
reason := "KILLed"
reason := ""
if len(lines) > 1 {
reason = lines[1]
}
+13 -2
View File
@@ -90,6 +90,16 @@ func TestUserhost(t *testing.T) {
t.Errorf("expected alice and bob, got %q", body)
}
msgs, lastID = sendAndPoll(tserver, token, lastID, map[string]any{
commandKey: irc.CmdUserhost,
bodyKey: []string{"ghost"},
})
body = numericBody(t, msgs, "302")
if body != "" {
t.Errorf("expected an empty reply for ghost, got %q", body)
}
msgs, _ = sendAndPoll(tserver, token, lastID, map[string]any{
commandKey: irc.CmdUserhost,
})
@@ -187,8 +197,8 @@ func TestKill(t *testing.T) {
commandKey: irc.CmdKill,
bodyKey: []string{"victim", "go away"},
})
if status != http.StatusOK {
t.Fatalf("expected 200, got %d: %v", status, result)
if status != http.StatusOK || result[statusKey] != "ok" {
t.Fatalf("expected 200 and status ok, got %d: %v", status, result)
}
msgs, _ = tserver.pollMessages(observerToken, observerLastID)
@@ -283,6 +293,7 @@ func TestUserMode(t *testing.T) {
{nick, "", "221", "+w"},
{strings.ToUpper(nick), "-w", "221", "+"},
{nick, "+z", "501", ""},
{nick, "+o", "501", ""},
{other, "", "502", ""},
{other, "-w", "502", ""},
} {