Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afdesk committed Oct 29, 2024
1 parent 8f63570 commit 4bc5434
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/k8s/report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@ var (
},
}

orionDeployWithAnotherMisconfig = Resource{
Namespace: "default",
Kind: "Deploy",
Name: "orion",
Results: types.Results{
{
Misconfigurations: []types.DetectedMisconfiguration{
{
ID: "ID201",
Status: types.MisconfStatusFailure,
Severity: "HIGH",
},
},
},
},
}

deployOrionWithBothVulnsAndMisconfigs = Resource{
Namespace: "default",
Kind: "Deploy",
Expand Down Expand Up @@ -311,6 +328,10 @@ var (
)

func TestReport_consolidate(t *testing.T) {
concatenatedResource := orionDeployWithAnotherMisconfig
concatenatedResource.Results[0].Misconfigurations = append(concatenatedResource.Results[0].Misconfigurations,
deployOrionWithMisconfigs.Results[0].Misconfigurations...)

tests := []struct {
name string
report Report
Expand Down Expand Up @@ -358,6 +379,18 @@ func TestReport_consolidate(t *testing.T) {
"default/cronjob/hello": cronjobHelloWithVulns,
},
},
{
name: "report with misconfigs in image and pod",
report: Report{
Resources: []Resource{
deployOrionWithMisconfigs,
orionDeployWithAnotherMisconfig,
},
},
expectedFindings: map[string]Resource{
"default/deploy/orion": concatenatedResource,
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 4bc5434

Please sign in to comment.