Files
pipelines/internal/server/status_test.go
T
alan fc7dbb0ac0 Remove ntfy: notifications go only through the app notification stream
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat
tool notify, auto-switch and schedule notices), the chat push outbox (its
table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*.
The app_notifications stream, subscribe/clear and kinds are unchanged.
Notification settings keep run_finished/chat_needs_you/chat_reply_finished;
ntfy_enabled is accepted and ignored and its stored row is never read.

Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to
the Pipelines apps — use the stage notify hook". The notify hook remains.

Installer: no ntfy build, accounts, config or supervisor child; manifest
gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an
old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log,
with a note in logs/install.log); uninstall cleans leftovers.

App: ntfy settings section replaced by "Notification events"; texts updated.
Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli,
author skill references updated; security review M1 marked resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:24:24 +00:00

78 lines
2.8 KiB
Go

package server
import (
"context"
"encoding/json"
"git.a-wan.net/alan/pipelines/internal/client"
"git.a-wan.net/alan/pipelines/internal/protocol"
"net/http/httptest"
"strings"
"testing"
"time"
)
func TestStatusRPCReportsServerWithoutNtfy(t *testing.T) {
srv := httptest.NewServer(Handler(context.Background()))
defer srv.Close()
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
c, err := client.Open(ctx, "ws"+strings.TrimPrefix(srv.URL, "http")+"/connect")
if err != nil {
t.Fatal(err)
}
defer c.Close()
response, err := c.Call(ctx, protocol.Message{Type: protocol.GetStatus})
if err != nil {
t.Fatal(err)
}
s := response.Status
if s == nil || s.Server.Health != "healthy" || len(s.Addresses) == 0 || s.Hostname == "" || s.Server.Port == "" || s.StartedAt == "" {
t.Fatal("incomplete status", s)
}
encoded, _ := json.Marshal(s)
for _, gone := range []string{`"ntfy"`, `"topic"`, `"ntfy_user"`} {
if strings.Contains(string(encoded), gone) {
t.Fatalf("status still reports %s: %s", gone, encoded)
}
}
if !strings.Contains(s.Server.URL, s.Server.Port) || !strings.Contains(s.Note, "not reachability checks") {
t.Fatal("ports or safety disclaimer missing", s)
}
}
// TestStatusReportsOpenCodeAttachment pins that get_status carries how chat is
// attached to OpenCode, so an endpoint that could not be attached shows as
// "fallback" instead of silently disappearing, and that the report never
// contains a credential.
func TestStatusReportsOpenCodeAttachment(t *testing.T) {
options := Options{OpenCodeStatus: protocol.ServiceStatus{Health: "fallback", URL: "http://127.0.0.1:49374"}}
srv := httptest.NewServer(HandlerWithOptions(context.Background(), options))
defer srv.Close()
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
c, err := client.Open(ctx, "ws"+strings.TrimPrefix(srv.URL, "http")+"/connect")
if err != nil {
t.Fatal(err)
}
defer c.Close()
response, err := c.Call(ctx, protocol.Message{Type: protocol.GetStatus})
if err != nil {
t.Fatal(err)
}
if response.Status == nil || response.Status.OpenCode.Health != "fallback" || response.Status.OpenCode.URL != "http://127.0.0.1:49374" {
t.Fatalf("opencode status not reported: %+v", response.Status)
}
encoded, _ := json.Marshal(response.Status)
if strings.Contains(string(encoded), "password") || strings.Contains(string(encoded), "token") {
t.Fatalf("status leaked a credential-shaped field: %s", encoded)
}
}
func TestStatusIPv6Candidates(t *testing.T) {
addresses := []protocol.NetworkAddress{{Interface: "test", IP: "::1"}, {Interface: "test", IP: "192.0.2.1"}}
urls := candidateURLs(addresses, "ws", "8080", "/connect")
if urls[0] != "ws://[::1]:8080/connect" || urls[1] != "ws://192.0.2.1:8080/connect" {
t.Fatal(urls)
}
}