Files
pulse/internal/notifications/notifications_security_cli_test.go
T
rcourtman 24b2e40e92 Harden scanned request and storage boundaries
Harden CodeQL-scanned request, command, path, and frontend sinks across relay proxying, availability probes, connection probing, notification CLI execution, report storage, licensing persistence, preview bootstrapping, tooltip rendering, logging, and test identity generation.
2026-07-09 17:22:29 +01:00

75 lines
1.7 KiB
Go

package notifications
import (
"context"
"errors"
"testing"
)
func TestSendAppriseViaCLINoTargets(t *testing.T) {
nm := NewNotificationManager("")
defer nm.Stop()
err := nm.sendAppriseViaCLI(AppriseConfig{
CLIPath: "apprise",
TimeoutSeconds: 1,
}, "title", "body")
if err == nil {
t.Fatalf("expected error when no targets configured")
}
}
func TestSendAppriseViaCLIExecError(t *testing.T) {
nm := NewNotificationManager("")
defer nm.Stop()
nm.appriseExec = func(ctx context.Context, args []string) ([]byte, error) {
return []byte("boom"), errors.New("exec failed")
}
err := nm.sendAppriseViaCLI(AppriseConfig{
CLIPath: "apprise",
TimeoutSeconds: 1,
Targets: []string{"discord://token"},
}, "title", "body")
if err == nil {
t.Fatalf("expected exec error")
}
}
func TestSendAppriseViaCLISuccess(t *testing.T) {
nm := NewNotificationManager("")
defer nm.Stop()
nm.appriseExec = func(ctx context.Context, args []string) ([]byte, error) {
return []byte("ok"), nil
}
err := nm.sendAppriseViaCLI(AppriseConfig{
CLIPath: "apprise",
TimeoutSeconds: 1,
Targets: []string{"discord://token"},
}, "title", "body")
if err != nil {
t.Fatalf("expected success, got %v", err)
}
}
func TestSendAppriseViaCLISuccessNoOutput(t *testing.T) {
nm := NewNotificationManager("")
defer nm.Stop()
nm.appriseExec = func(ctx context.Context, args []string) ([]byte, error) {
return nil, nil
}
err := nm.sendAppriseViaCLI(AppriseConfig{
CLIPath: "apprise",
TimeoutSeconds: 1,
Targets: []string{"discord://token"},
}, "title", "body")
if err != nil {
t.Fatalf("expected success, got %v", err)
}
}