-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathresource_sysdig_secure_posture_zone_test.go
More file actions
80 lines (70 loc) · 1.87 KB
/
resource_sysdig_secure_posture_zone_test.go
File metadata and controls
80 lines (70 loc) · 1.87 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//go:build tf_acc_sysdig_secure || tf_acc_ibm_secure
package sysdig_test
import (
"fmt"
"testing"
"github.com/draios/terraform-provider-sysdig/sysdig"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func TestAccSecurePostureZone(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: preCheckAnyEnv(t, SysdigSecureApiTokenEnv, SysdigIBMSecureAPIKeyEnv),
ProviderFactories: map[string]func() (*schema.Provider, error){
"sysdig": func() (*schema.Provider, error) {
return sysdig.Provider(), nil
},
},
Steps: []resource.TestStep{
{
Config: minimalSecurePostureZone(randomText(10)),
},
{
Config: securePostureZoneWithScopes(randomText(10)),
},
{
Config: securePostureZoneWithPolicies(randomText(10)),
},
{
ResourceName: "sysdig_secure_posture_zone.z1",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func minimalSecurePostureZone(name string) string {
return fmt.Sprintf(`
resource "sysdig_secure_posture_zone" "z1" {
name = "%s"
}`, name)
}
func securePostureZoneWithScopes(name string) string {
return fmt.Sprintf(`
resource "sysdig_secure_posture_zone" "z1" {
name = "%s"
scopes {
scope {
target_type = "aws"
rules = "organization in (\"o1\", \"o2\") and account in (\"a1\", \"a2\")"
}
scope {
target_type = "azure"
rules = "organization contains \"o1\""
}
}
}`, name)
}
func securePostureZoneWithPolicies(name string) string {
return fmt.Sprintf(`
resource "sysdig_secure_posture_policy" "test" {
name = "%s-policy"
description = "test policy for posture zone"
is_active = true
type = "Unknown"
}
resource "sysdig_secure_posture_zone" "z1" {
name = "%s"
policy_ids = [sysdig_secure_posture_policy.test.id]
}`, name, name)
}