-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathresource_sysdig_secure_rule_syscall_test.go
More file actions
82 lines (69 loc) · 2 KB
/
resource_sysdig_secure_rule_syscall_test.go
File metadata and controls
82 lines (69 loc) · 2 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
81
82
//go:build tf_acc_sysdig_secure || tf_acc_policies || tf_acc_onprem_secure
package sysdig_test
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/draios/terraform-provider-sysdig/sysdig"
)
func TestAccRuleSyscall(t *testing.T) {
t.Skip("List matching rules are deprecated - skipping tests")
rText := func() string { return acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) }
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
if v := os.Getenv("SYSDIG_SECURE_API_TOKEN"); v == "" {
t.Fatal("SYSDIG_SECURE_API_TOKEN must be set for acceptance tests")
}
},
ProviderFactories: map[string]func() (*schema.Provider, error){
"sysdig": func() (*schema.Provider, error) {
return sysdig.Provider(), nil
},
},
Steps: []resource.TestStep{
{
Config: ruleSyscallWithName(rText()),
},
{
ResourceName: "sysdig_secure_rule_syscall.foo",
ImportState: true,
ImportStateVerify: true,
},
{
Config: ruleSyscallWithoutTags(rText()),
},
{
Config: ruleSyscallWithMinimalConfig(rText()),
},
},
})
}
func ruleSyscallWithName(name string) string {
return fmt.Sprintf(`
resource "sysdig_secure_rule_syscall" "foo" {
name = "TERRAFORM TEST %s"
description = "TERRAFORM TEST %s"
tags = ["syscall", "cis"]
matching = true // default
syscalls = ["open", "execve"]
}`, name, name)
}
func ruleSyscallWithoutTags(name string) string {
return fmt.Sprintf(`
resource "sysdig_secure_rule_syscall" "foo" {
name = "TERRAFORM TEST %s"
description = "TERRAFORM TEST %s"
matching = true // default
syscalls = ["open", "execve"]
}`, name, name)
}
func ruleSyscallWithMinimalConfig(name string) string {
return fmt.Sprintf(`
resource "sysdig_secure_rule_syscall" "foo-minimal" {
name = "TERRAFORM TEST %s"
description = "TERRAFORM TEST %s"
}`, name, name)
}