-
Notifications
You must be signed in to change notification settings - Fork 1
/
secretactions_test.go
39 lines (36 loc) · 1.03 KB
/
secretactions_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package observek8sattributesprocessor
import (
"encoding/base64"
"fmt"
"testing"
corev1 "k8s.io/api/core/v1"
)
func TestSecretBodyActions(t *testing.T) {
for _, testCase := range []k8sEventProcessorTest{
{
name: "Redact secrets' values",
inLogs: resourceLogsFromSingleJsonEvent("./testdata/secretEvent.json"),
expectedResults: []queryWithResult{
// This checks that there are no values in "data" that are not "REDACTED"
{
location: LogLocationBody,
path: fmt.Sprintf("length(values(data)[?@ != '%s'])", base64.StdEncoding.EncodeToString([]byte(RedactedSecretValue))),
expResult: float64(0),
},
},
},
{
name: "Redact secrets' last configuration values",
inLogs: resourceLogsFromSingleJsonEvent("./testdata/secretEventPrevConfig.json"),
expectedResults: []queryWithResult{
{
location: LogLocationBody,
path: fmt.Sprintf("metadata.annotations.\"%s\"", corev1.LastAppliedConfigAnnotation),
expResult: nil,
},
},
},
} {
runTest(t, testCase)
}
}