Add Unraid and Gotify notifications

This commit is contained in:
Mikei386
2026-06-14 13:50:02 +02:00
parent b7fe6ac86f
commit 1af23831f4
15 changed files with 232 additions and 44 deletions
+20
View File
@@ -15,6 +15,26 @@ func TestValidateConfig(t *testing.T) {
}
}
func TestNormalizeConfigReplacesNtfyAndAddsUnraid(t *testing.T) {
c := DefaultConfig()
c.Notifications = []NotificationTarget{{SchemaVersion: 1, ID: "old-ntfy", Name: "ntfy", Type: "ntfy", Enabled: true}}
c = NormalizeConfig(c)
if len(c.Notifications) != 1 || c.Notifications[0].Type != "unraid" || !c.Notifications[0].Enabled {
t.Fatalf("notifications = %#v", c.Notifications)
}
}
func TestValidateGotifyNotification(t *testing.T) {
target := NotificationTarget{SchemaVersion: 1, ID: "gotify", Name: "Gotify", Type: "gotify", Enabled: true, URL: "https://gotify.example.test", TokenRef: "gotify-token", Events: []string{"failed"}}
if err := ValidateNotification(target); err != nil {
t.Fatal(err)
}
target.URL = "javascript:alert(1)"
if err := ValidateNotification(target); err == nil {
t.Fatal("unsafe Gotify URL accepted")
}
}
func TestRepositoryIsolation(t *testing.T) {
c := DefaultConfig()
c.Jobs = []Job{{SchemaVersion: 1, ID: "job", Name: "Broken", Type: JobFlash, RepositoryID: "missing", Consistency: Consistency{Mode: "live"}, Compression: "auto"}}