mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-10 18:45:53 +00:00
24b2e40e92
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.
75 lines
1.7 KiB
Go
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)
|
|
}
|
|
}
|