Add Unraid and Gotify notifications
This commit is contained in:
@@ -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"}}
|
||||
|
||||
Reference in New Issue
Block a user