Skip to content

Commit

Permalink
update test assertion
Browse files Browse the repository at this point in the history
Signed-off-by: Simar <simar@linux.com>
  • Loading branch information
simar7 committed Jul 7, 2023
1 parent 47cd724 commit 0d62006
Showing 1 changed file with 23 additions and 50 deletions.
73 changes: 23 additions & 50 deletions pkg/cloud/aws/commands/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,45 +304,13 @@ const expectedCustomScanResult = `{
}
},
"Results": [
{
"Target": "",
"Class": "config",
"Type": "cloud",
"MisconfSummary": {
"Successes": 1,
"Failures": 0,
"Exceptions": 0
},
"Misconfigurations": [
{
"Type": "AWS",
"Title": "No example buckets",
"Description": "Buckets should not be named with \"example\" in the name",
"Namespace": "user.whatever",
"Query": "deny",
"Severity": "LOW",
"References": [
""
],
"Status": "PASS",
"Layer": {},
"CauseMetadata": {
"Provider": "cloud",
"Service": "s3",
"Code": {
"Lines": null
}
}
}
]
},
{
"Target": "arn:aws:s3:::examplebucket",
"Class": "config",
"Type": "cloud",
"MisconfSummary": {
"Successes": 1,
"Failures": 9,
"Failures": 10,
"Exceptions": 0
},
"Misconfigurations": [
Expand Down Expand Up @@ -584,6 +552,28 @@ const expectedCustomScanResult = `{
"Lines": null
}
}
},
{
"Type": "AWS",
"Title": "No example buckets",
"Description": "Buckets should not be named with \"example\" in the name",
"Message": "example bucket detected",
"Namespace": "user.whatever",
"Query": "deny",
"Severity": "LOW",
"References": [
""
],
"Status": "FAIL",
"Layer": {},
"CauseMetadata": {
"Resource": "arn:aws:s3:::examplebucket",
"Provider": "cloud",
"Service": "s3",
"Code": {
"Lines": null
}
}
}
]
}
Expand Down Expand Up @@ -1052,9 +1042,6 @@ func Test_Run(t *testing.T) {
PolicyPaths: []string{
filepath.Join(regoDir, "policies"),
},
DataPaths: []string{
filepath.Join(regoDir, "data"),
},
PolicyNamespaces: []string{
"user",
},
Expand All @@ -1079,18 +1066,9 @@ import data.settings.DS123.ignore_deletion_protection
deny[res] {
bucket := input.aws.s3.buckets[_]
ignore_deletion_protection == true
contains(bucket.name.value, "example")
res := result.new("example bucket detected", bucket.name)
}
`,
inputData: `{
"settings": {
"DS123": {
"ignore_deletion_protection": false
}
}
}
`,
cacheContent: "testdata/s3onlycache.json",
allServices: []string{"s3"},
Expand Down Expand Up @@ -1267,11 +1245,6 @@ Summary Report for compliance: my-custom-spec
require.NoError(t, os.WriteFile(filepath.Join(regoDir, "policies", "user.rego"), []byte(test.regoPolicy), 0644))
}

if test.inputData != "" {
require.NoError(t, os.MkdirAll(filepath.Join(regoDir, "data"), 0755))
require.NoError(t, os.WriteFile(filepath.Join(regoDir, "data", "data.json"), []byte(test.inputData), 0644))
}

if test.cacheContent != "" {
cacheRoot := t.TempDir()
test.options.CacheDir = cacheRoot
Expand Down

0 comments on commit 0d62006

Please sign in to comment.