@@ -5,6 +5,7 @@ package sysdig_test
55import (
66 "fmt"
77 "os"
8+ "regexp"
89 "testing"
910
1011 "github.com/draios/terraform-provider-sysdig/sysdig"
@@ -26,22 +27,82 @@ func TestAccVulnerabilityRuleBundle(t *testing.T) {
2627 "sysdig" : func () (* schema.Provider , error ) { return sysdig .Provider (), nil },
2728 },
2829 Steps : []resource.TestStep {
30+ {
31+ Config : incorrectVulnerabilityRuleBundleConfig (random ()),
32+ ExpectError : regexp .MustCompile ("empty rule detected, you need to specify one" ),
33+ },
34+ {
35+ Config : incorrectVulnerabilityRuleBundleConfig2 (random ()),
36+ ExpectError : regexp .MustCompile (`No more than 1 "image_label" blocks are allowed` ),
37+ },
38+ {
39+ Config : incorrectVulnerabilityRuleBundleConfig3 (random ()),
40+ ExpectError : regexp .MustCompile (`no predicate has been specified for image label rule` ),
41+ },
2942 {
3043 Config : minimalVulnerabilityRuleBundleConfig (random ()),
3144 },
32- // {
33- // ResourceName: "sysdig_secure_vulnerability_rule_bundle.sample",
34- // ImportState: true,
35- // ImportStateVerify: true,
36- // },
45+ {
46+ Config : fullVulnerabilityRuleBundleConfig (random ()),
47+ },
48+ {
49+ ResourceName : "sysdig_secure_vulnerability_rule_bundle.sample" ,
50+ ImportState : true ,
51+ ImportStateVerify : true ,
52+ },
3753 },
3854 })
3955}
4056
57+ func incorrectVulnerabilityRuleBundleConfig (suffix string ) string {
58+ return fmt .Sprintf (`
59+ resource "sysdig_secure_vulnerability_rule_bundle" "sample" {
60+ name = "TERRAFORM TEST %s"
61+ rule {}
62+ }
63+ ` , suffix )
64+ }
65+
66+ func incorrectVulnerabilityRuleBundleConfig2 (suffix string ) string {
67+ return fmt .Sprintf (`
68+ resource "sysdig_secure_vulnerability_rule_bundle" "sample" {
69+ name = "TERRAFORM TEST %s"
70+ rule {
71+ image_label {}
72+ image_label {}
73+ }
74+ }
75+ ` , suffix )
76+ }
77+
78+ func incorrectVulnerabilityRuleBundleConfig3 (suffix string ) string {
79+ return fmt .Sprintf (`
80+ resource "sysdig_secure_vulnerability_rule_bundle" "sample" {
81+ name = "TERRAFORM TEST %s"
82+ rule {
83+ image_label {}
84+ }
85+ }
86+ ` , suffix )
87+ }
88+
4189func minimalVulnerabilityRuleBundleConfig (suffix string ) string {
4290 return fmt .Sprintf (`
4391resource "sysdig_secure_vulnerability_rule_bundle" "sample" {
4492 name = "TERRAFORM TEST %s"
93+ rule {
94+ image_label {
95+ label_must_exist = "required-label"
96+ }
97+ }
98+ }
99+ ` , suffix )
100+ }
101+
102+ func fullVulnerabilityRuleBundleConfig (suffix string ) string {
103+ return fmt .Sprintf (`
104+ resource "sysdig_secure_vulnerability_rule_bundle" "sample" {
105+ name = "TERRAFORM TEST %s"
45106
46107 rule {
47108 image_label {
0 commit comments