fc7dbb0ac0
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>
51 lines
2.9 KiB
Go
51 lines
2.9 KiB
Go
package pipeline
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestNotifyPolicyParsing(t *testing.T) {
|
|
for _, test := range []struct {
|
|
text string
|
|
valid bool
|
|
}{
|
|
{"on=success\ndestination=anime", true}, {"on=failure\ndestination=anime\nartifacts=files", true}, {"on=success,failure\ndestination=anime\nartifacts=markdown,files", true},
|
|
{"on=success\nopen=reports/*.md", true}, {"on=success\nopen=/secret", false}, {"on=success\nopen=../secret", false}, {"on=success\nopen=.secret", false}, {"on=success\nopen=[", false},
|
|
{"on=success\nlink=standup-link.txt", true}, {"on=success\nlink=links/*.txt\nopen=reports/*.md", true}, {"on=success\nlink=/secret", false}, {"on=success\nlink=../secret", false}, {"on=success\nlink=.secret", false}, {"on=success\nlink=a//b", false}, {"on=success\nlink=[", false}, {"on=success\nlink=a.txt\nlink=b.txt", false},
|
|
{"on=error\ndestination=anime", false}, {"on=success,success\ndestination=anime", false}, {"destination=anime", false}, {"on=success", true}, {"on=failure\nartifacts=markdown,files", true}, {"on=success\ndestination=../secret", false}, {"on=success\ndestination=anime\ntoken=secret", false}, {"on=success\ndestination=anime\nartifacts=*", false}, {"on=success\non=failure\ndestination=anime", false},
|
|
} {
|
|
source := strings.Replace(Template([]string{"one"}, true), "# stage one", "# stage one\n```notify\n"+test.text+"\n```", 1)
|
|
graph, err := Parse(source)
|
|
if (err == nil) != test.valid {
|
|
t.Fatalf("notify %q: %v", test.text, err)
|
|
}
|
|
if err == nil {
|
|
s := graph.Stages[0]
|
|
if s.Notify == nil {
|
|
t.Fatal("notify lost")
|
|
}
|
|
if s.Notify.Destination != "system" {
|
|
t.Fatal("notification is not system-wide", s.Notify)
|
|
}
|
|
if _, exists := StageDefinition(s).Blocks["notify"]; exists {
|
|
t.Fatal("common notify block passed to model validator")
|
|
}
|
|
}
|
|
}
|
|
source := strings.Replace(Template([]string{"one"}, true), "# stage one", "# stage one\n```notify\non=success\nlink=standup-link.txt\nopen=*.md\n```", 1)
|
|
// `pipelines validate` uses this report parser.
|
|
if graph, _, err := ParseDefinitionReport(source); err != nil || graph.Stages[0].Notify.Link != "standup-link.txt" || graph.Stages[0].Notify.Open != "*.md" {
|
|
t.Fatal("notify link not validated", err)
|
|
}
|
|
source = "# stage native\n```configs\ntype=ntfy\ndestination=anime\n```\n```notify\non=failure\ndestination=anime\n```\n```edges\nsuccess -> #success\nerror -> #failure\n```"
|
|
// ntfy stages were removed: an old definition is refused with what to use
|
|
// instead, by the parser and by `pipelines validate`'s report parser.
|
|
if _, err := Parse(source); err == nil || !strings.Contains(err.Error(), "ntfy stages were removed; notifications go to the Pipelines apps — use the stage notify hook") {
|
|
t.Fatal("type=ntfy stage not rejected with guidance:", err)
|
|
}
|
|
if _, _, err := ParseDefinitionReport(source); err == nil || !strings.Contains(err.Error(), "use the stage notify hook") {
|
|
t.Fatal("validate report accepted a type=ntfy stage:", err)
|
|
}
|
|
}
|