Skip to content

Commit a410415

Browse files
committed
fix(tests): Skip onprem unsupported policy types
* Do not run cloud policy types tests with `tf_acc_onprem_secure` tag * Change rules order to fix `TestAccCustomPolicy`: ``` resource_sysdig_secure_custom_policy_test.go:19: Step 2/12 error running import: ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import. map[string]string{ - "rules.0.name": "Write below etc", + "rules.0.name": "TERRAFORM TEST 6yf1pzvnbf - Terminal Shell", - "rules.1.name": "TERRAFORM TEST 6yf1pzvnbf - Terminal Shell", + "rules.1.name": "Write below etc", } ```
1 parent 5f3febf commit a410415

5 files changed

+87
-88
lines changed

sysdig/data_source_sysdig_secure_aws_ml_policy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build tf_acc_sysdig_secure || tf_acc_policies_aws || tf_acc_onprem_secure
1+
//go:build tf_acc_sysdig_secure || tf_acc_policies_aws
22

33
package sysdig_test
44

sysdig/data_source_sysdig_secure_trusted_cloud_identity_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build tf_acc_sysdig_secure || tf_acc_onprem_secure
1+
//go:build tf_acc_sysdig_secure
22

33
package sysdig_test
44

sysdig/resource_sysdig_secure_aws_ml_policy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build tf_acc_sysdig_secure || tf_acc_policies_aws || tf_acc_onprem_secure
1+
//go:build tf_acc_sysdig_secure || tf_acc_policies_aws
22

33
package sysdig_test
44

sysdig/resource_sysdig_secure_custom_policy_test.go

+45-42
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,62 @@ import (
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1212

13+
"github.com/draios/terraform-provider-sysdig/buildinfo"
1314
"github.com/draios/terraform-provider-sysdig/sysdig"
1415
)
1516

1617
func TestAccCustomPolicy(t *testing.T) {
1718
rText := func() string { return acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) }
1819
policy1 := rText()
20+
21+
steps := []resource.TestStep{
22+
{
23+
Config: customPolicyWithName(policy1),
24+
},
25+
{
26+
ResourceName: "sysdig_secure_custom_policy.sample",
27+
ImportState: true,
28+
ImportStateVerify: true,
29+
},
30+
{
31+
Config: customPolicyWithRulesOrderChange(policy1),
32+
},
33+
{
34+
Config: customPolicyWithoutActions(rText()),
35+
},
36+
{
37+
Config: customPolicyWithoutNotificationChannels(rText()),
38+
},
39+
{
40+
Config: customPolicyWithMinimumConfiguration(rText()),
41+
},
42+
{
43+
Config: customPoliciesWithDifferentSeverities(rText()),
44+
},
45+
{
46+
Config: customPoliciesWithKillAction(rText()),
47+
},
48+
{
49+
Config: customPoliciesWithDisabledRules(rText()),
50+
},
51+
}
52+
53+
if !buildinfo.OnpremSecure {
54+
steps = append(steps,
55+
resource.TestStep{Config: customPoliciesForAWSCloudtrail(rText())},
56+
resource.TestStep{Config: customPoliciesForGCPAuditLog(rText())},
57+
resource.TestStep{Config: customPoliciesForAzurePlatformlogs(rText())},
58+
)
59+
}
60+
1961
resource.ParallelTest(t, resource.TestCase{
2062
PreCheck: preCheckAnyEnv(t, SysdigSecureApiTokenEnv),
2163
ProviderFactories: map[string]func() (*schema.Provider, error){
2264
"sysdig": func() (*schema.Provider, error) {
2365
return sysdig.Provider(), nil
2466
},
2567
},
26-
Steps: []resource.TestStep{
27-
{
28-
Config: customPolicyWithName(policy1),
29-
},
30-
{
31-
ResourceName: "sysdig_secure_custom_policy.sample",
32-
ImportState: true,
33-
ImportStateVerify: true,
34-
},
35-
{
36-
Config: customPolicyWithRulesOrderChange(policy1),
37-
},
38-
{
39-
Config: customPolicyWithoutActions(rText()),
40-
},
41-
{
42-
Config: customPolicyWithoutNotificationChannels(rText()),
43-
},
44-
{
45-
Config: customPolicyWithMinimumConfiguration(rText()),
46-
},
47-
{
48-
Config: customPoliciesWithDifferentSeverities(rText()),
49-
},
50-
{
51-
Config: customPoliciesWithKillAction(rText()),
52-
},
53-
{
54-
Config: customPoliciesForAWSCloudtrail(rText()),
55-
},
56-
{
57-
Config: customPoliciesForGCPAuditLog(rText()),
58-
},
59-
{
60-
Config: customPoliciesForAzurePlatformlogs(rText()),
61-
},
62-
{
63-
Config: customPoliciesWithDisabledRules(rText()),
64-
},
65-
},
68+
Steps: steps,
6669
})
6770
}
6871

@@ -79,11 +82,11 @@ resource "sysdig_secure_custom_policy" "sample" {
7982
runbook = "https://sysdig.com"
8083
8184
rules {
82-
name = "Write below etc"
85+
name = sysdig_secure_rule_falco.terminal_shell.name
8386
enabled = true
8487
}
8588
rules {
86-
name = sysdig_secure_rule_falco.terminal_shell.name
89+
name = "Write below etc"
8790
enabled = true
8891
}
8992

sysdig/resource_sysdig_secure_policy_test.go

+39-43
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,58 @@ import (
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1212

13+
"github.com/draios/terraform-provider-sysdig/buildinfo"
1314
"github.com/draios/terraform-provider-sysdig/sysdig"
1415
)
1516

1617
func TestAccPolicy(t *testing.T) {
1718
rText := func() string { return acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) }
1819

20+
steps := []resource.TestStep{
21+
{
22+
Config: policyWithName(rText()),
23+
},
24+
{
25+
ResourceName: "sysdig_secure_policy.sample",
26+
ImportState: true,
27+
ImportStateVerify: true,
28+
},
29+
{
30+
Config: policyWithoutActions(rText()),
31+
},
32+
{
33+
Config: policyWithoutNotificationChannels(rText()),
34+
},
35+
{
36+
Config: policyWithMinimumConfiguration(rText()),
37+
},
38+
{
39+
Config: policiesWithDifferentSeverities(rText()),
40+
},
41+
{
42+
Config: policiesWithKillAction(rText()),
43+
},
44+
}
45+
46+
if !buildinfo.OnpremSecure {
47+
steps = append(steps,
48+
resource.TestStep{Config: policiesForAWSCloudtrail(rText())},
49+
resource.TestStep{Config: policiesForGCPAuditLog(rText())},
50+
resource.TestStep{Config: policiesForAzurePlatformlogs(rText())},
51+
resource.TestStep{Config: policiesForFalcoCloudAWSCloudtrail(rText())},
52+
resource.TestStep{Config: policiesForOkta(rText())},
53+
resource.TestStep{Config: policiesForGithub(rText())},
54+
)
55+
}
56+
1957
resource.ParallelTest(t, resource.TestCase{
2058
PreCheck: preCheckAnyEnv(t, SysdigSecureApiTokenEnv),
2159
ProviderFactories: map[string]func() (*schema.Provider, error){
2260
"sysdig": func() (*schema.Provider, error) {
2361
return sysdig.Provider(), nil
2462
},
2563
},
26-
Steps: []resource.TestStep{
27-
{
28-
Config: policyWithName(rText()),
29-
},
30-
{
31-
ResourceName: "sysdig_secure_policy.sample",
32-
ImportState: true,
33-
ImportStateVerify: true,
34-
},
35-
{
36-
Config: policyWithoutActions(rText()),
37-
},
38-
{
39-
Config: policyWithoutNotificationChannels(rText()),
40-
},
41-
{
42-
Config: policyWithMinimumConfiguration(rText()),
43-
},
44-
{
45-
Config: policiesWithDifferentSeverities(rText()),
46-
},
47-
{
48-
Config: policiesWithKillAction(rText()),
49-
},
50-
{
51-
Config: policiesForAWSCloudtrail(rText()),
52-
},
53-
{
54-
Config: policiesForGCPAuditLog(rText()),
55-
},
56-
{
57-
Config: policiesForAzurePlatformlogs(rText()),
58-
},
59-
{
60-
Config: policiesForFalcoCloudAWSCloudtrail(rText()),
61-
},
62-
{
63-
Config: policiesForOkta(rText()),
64-
},
65-
{
66-
Config: policiesForGithub(rText()),
67-
},
68-
},
64+
Steps: steps,
6965
})
7066
}
7167

0 commit comments

Comments
 (0)