Skip to content

Commit

Permalink
add pagerduty test
Browse files Browse the repository at this point in the history
  • Loading branch information
caWhite committed Mar 3, 2021
1 parent 50898b5 commit 81612db
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions outputs/pagerduty_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package outputs

import (
"encoding/json"
"github.com/PagerDuty/go-pagerduty"
"github.com/falcosecurity/falcosidekick/types"
"github.com/stretchr/testify/require"
"testing"
)

func TestPagerdutyPayload(t *testing.T) {
var falcoTestInput = `{"output":"This is a test from falcosidekick","priority":"Debug","rule":"Test rule","time":"2001-01-01T01:10:00Z","output_fields": {"proc.name":"falcosidekick", "proc.tty": 1234}}`

var excpectedOutput = pagerduty.V2Event{
RoutingKey: "",
Action: "trigger",
Payload: &pagerduty.V2Payload{
Summary: "This is a test from falcosidekick",
Source: "falco",
Severity: "critical",
Timestamp: "2001-01-01T01:10:00Z",
Component: "",
Group: "",
Class: "",
Details: map[string]interface{}{
"proc.name": "falcosidekick",
"proc.tty": float64(1234),
},
},
}

var f types.FalcoPayload
json.Unmarshal([]byte(falcoTestInput), &f)

event := createPagerdutyEvent(f, types.PagerdutyConfig{})

require.Equal(t, excpectedOutput, event)
}

0 comments on commit 81612db

Please sign in to comment.