Skip to content

Commit

Permalink
test: add functional tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Pivkin <[email protected]>
  • Loading branch information
nikpivkin authored and simar7 committed Aug 22, 2024
1 parent bd35a59 commit 570238e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
36 changes: 36 additions & 0 deletions test/rego/oracle_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package test

import (
"github.com/aquasecurity/trivy/pkg/iac/providers/oracle"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

var oracleTestCases = testCases{
"AVD-OCI-0001": {
{
name: "Compute instance public reservation pool",
input: state.State{Oracle: oracle.Oracle{Compute: oracle.Compute{
AddressReservations: []oracle.AddressReservation{
{
Metadata: trivyTypes.NewTestMetadata(),
Pool: trivyTypes.String("public-ippool", trivyTypes.NewTestMetadata()),
},
},
}}},
expected: true,
},
{
name: "Compute instance cloud reservation pool",
input: state.State{Oracle: oracle.Oracle{Compute: oracle.Compute{
AddressReservations: []oracle.AddressReservation{
{
Metadata: trivyTypes.NewTestMetadata(),
Pool: trivyTypes.String("cloud-ippool", trivyTypes.NewTestMetadata()),
},
},
}}},
expected: false,
},
},
}
8 changes: 5 additions & 3 deletions test/rego/rego_checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ func TestRegoChecks(t *testing.T) {
azureAuthorizationTestCases,
azureContainerTestCases,

googleDnsTestCases,
googleDnsTestCases,
googleKmsTestCases,
googleBigQueryTestCases,

githubTestCases,
githubTestCases,

nifcloudDnsTestCases,
nifcloudDnsTestCases,
nifcloudNetworkTestCases,
nifcloudSslCertificateTestCases,

oracleTestCases,
)

regoScanner := rego.NewScanner(trivyTypes.SourceCloud)
Expand Down

0 comments on commit 570238e

Please sign in to comment.