@@ -18,6 +18,210 @@ var configVariables = config.Variables{
18
18
"zone_id" : config .StringVariable (os .Getenv ("CLOUDFLARE_ZONE_ID" )),
19
19
}
20
20
21
+ func TestAccCloudflareRuleset_Name (t * testing.T ) {
22
+ resource .Test (t , resource.TestCase {
23
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
24
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
25
+ Steps : []resource.TestStep {
26
+ {
27
+ ConfigFile : config .TestNameFile ("before.tf" ),
28
+ ConfigVariables : configVariables ,
29
+ ConfigPlanChecks : resource.ConfigPlanChecks {
30
+ PreApply : []plancheck.PlanCheck {
31
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionCreate ),
32
+ plancheck .ExpectKnownValue (
33
+ "cloudflare_ruleset.my_ruleset" ,
34
+ tfjsonpath .New ("name" ),
35
+ knownvalue .StringExact ("My ruleset" ),
36
+ ),
37
+ },
38
+ },
39
+ ConfigStateChecks : []statecheck.StateCheck {
40
+ statecheck .ExpectKnownValue (
41
+ "cloudflare_ruleset.my_ruleset" ,
42
+ tfjsonpath .New ("name" ),
43
+ knownvalue .StringExact ("My ruleset" ),
44
+ ),
45
+ },
46
+ },
47
+ {
48
+ ConfigFile : config .TestNameFile ("after.tf" ),
49
+ ConfigVariables : configVariables ,
50
+ ConfigPlanChecks : resource.ConfigPlanChecks {
51
+ PreApply : []plancheck.PlanCheck {
52
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionReplace ),
53
+ plancheck .ExpectKnownValue (
54
+ "cloudflare_ruleset.my_ruleset" ,
55
+ tfjsonpath .New ("name" ),
56
+ knownvalue .StringExact ("My updated ruleset" ),
57
+ ),
58
+ },
59
+ },
60
+ ConfigStateChecks : []statecheck.StateCheck {
61
+ statecheck .ExpectKnownValue (
62
+ "cloudflare_ruleset.my_ruleset" ,
63
+ tfjsonpath .New ("name" ),
64
+ knownvalue .StringExact ("My updated ruleset" ),
65
+ ),
66
+ },
67
+ },
68
+ },
69
+ })
70
+ }
71
+
72
+ func TestAccCloudflareRuleset_Description (t * testing.T ) {
73
+ resource .Test (t , resource.TestCase {
74
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
75
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
76
+ Steps : []resource.TestStep {
77
+ {
78
+ ConfigFile : config .TestNameFile ("before.tf" ),
79
+ ConfigVariables : configVariables ,
80
+ ConfigPlanChecks : resource.ConfigPlanChecks {
81
+ PreApply : []plancheck.PlanCheck {
82
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionCreate ),
83
+ plancheck .ExpectKnownValue (
84
+ "cloudflare_ruleset.my_ruleset" ,
85
+ tfjsonpath .New ("description" ),
86
+ knownvalue .StringExact ("My ruleset description" ),
87
+ ),
88
+ },
89
+ },
90
+ ConfigStateChecks : []statecheck.StateCheck {
91
+ statecheck .ExpectKnownValue (
92
+ "cloudflare_ruleset.my_ruleset" ,
93
+ tfjsonpath .New ("description" ),
94
+ knownvalue .StringExact ("My ruleset description" ),
95
+ ),
96
+ },
97
+ },
98
+ {
99
+ ConfigFile : config .TestNameFile ("after.tf" ),
100
+ ConfigVariables : configVariables ,
101
+ ConfigPlanChecks : resource.ConfigPlanChecks {
102
+ PreApply : []plancheck.PlanCheck {
103
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionUpdate ),
104
+ plancheck .ExpectKnownValue (
105
+ "cloudflare_ruleset.my_ruleset" ,
106
+ tfjsonpath .New ("name" ),
107
+ knownvalue .StringExact ("My updated ruleset description" ),
108
+ ),
109
+ },
110
+ },
111
+ ConfigStateChecks : []statecheck.StateCheck {
112
+ statecheck .ExpectKnownValue (
113
+ "cloudflare_ruleset.my_ruleset" ,
114
+ tfjsonpath .New ("name" ),
115
+ knownvalue .StringExact ("My updated ruleset" ),
116
+ ),
117
+ },
118
+ },
119
+ },
120
+ })
121
+ }
122
+
123
+ func TestAccCloudflareRuleset_Phase (t * testing.T ) {
124
+ resource .Test (t , resource.TestCase {
125
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
126
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
127
+ Steps : []resource.TestStep {
128
+ {
129
+ ConfigFile : config .TestNameFile ("before.tf" ),
130
+ ConfigVariables : configVariables ,
131
+ ConfigPlanChecks : resource.ConfigPlanChecks {
132
+ PreApply : []plancheck.PlanCheck {
133
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionCreate ),
134
+ plancheck .ExpectKnownValue (
135
+ "cloudflare_ruleset.my_ruleset" ,
136
+ tfjsonpath .New ("phase" ),
137
+ knownvalue .StringExact ("http_request_firewall_custom" ),
138
+ ),
139
+ },
140
+ },
141
+ ConfigStateChecks : []statecheck.StateCheck {
142
+ statecheck .ExpectKnownValue (
143
+ "cloudflare_ruleset.my_ruleset" ,
144
+ tfjsonpath .New ("phase" ),
145
+ knownvalue .StringExact ("http_request_firewall_custom" ),
146
+ ),
147
+ },
148
+ },
149
+ {
150
+ ConfigFile : config .TestNameFile ("after.tf" ),
151
+ ConfigVariables : configVariables ,
152
+ ConfigPlanChecks : resource.ConfigPlanChecks {
153
+ PreApply : []plancheck.PlanCheck {
154
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionReplace ),
155
+ plancheck .ExpectKnownValue (
156
+ "cloudflare_ruleset.my_ruleset" ,
157
+ tfjsonpath .New ("phase" ),
158
+ knownvalue .StringExact ("http_request_firewall_managed" ),
159
+ ),
160
+ },
161
+ },
162
+ ConfigStateChecks : []statecheck.StateCheck {
163
+ statecheck .ExpectKnownValue (
164
+ "cloudflare_ruleset.my_ruleset" ,
165
+ tfjsonpath .New ("phase" ),
166
+ knownvalue .StringExact ("http_request_firewall_managed" ),
167
+ ),
168
+ },
169
+ },
170
+ },
171
+ })
172
+ }
173
+
174
+ func TestAccCloudflareRuleset_Kind (t * testing.T ) {
175
+ resource .Test (t , resource.TestCase {
176
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
177
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
178
+ Steps : []resource.TestStep {
179
+ {
180
+ ConfigFile : config .TestNameFile ("before.tf" ),
181
+ ConfigVariables : configVariables ,
182
+ ConfigPlanChecks : resource.ConfigPlanChecks {
183
+ PreApply : []plancheck.PlanCheck {
184
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionCreate ),
185
+ plancheck .ExpectKnownValue (
186
+ "cloudflare_ruleset.my_ruleset" ,
187
+ tfjsonpath .New ("kind" ),
188
+ knownvalue .StringExact ("root" ),
189
+ ),
190
+ },
191
+ },
192
+ ConfigStateChecks : []statecheck.StateCheck {
193
+ statecheck .ExpectKnownValue (
194
+ "cloudflare_ruleset.my_ruleset" ,
195
+ tfjsonpath .New ("kind" ),
196
+ knownvalue .StringExact ("root" ),
197
+ ),
198
+ },
199
+ },
200
+ {
201
+ ConfigFile : config .TestNameFile ("after.tf" ),
202
+ ConfigVariables : configVariables ,
203
+ ConfigPlanChecks : resource.ConfigPlanChecks {
204
+ PreApply : []plancheck.PlanCheck {
205
+ plancheck .ExpectResourceAction ("cloudflare_ruleset.my_ruleset" , plancheck .ResourceActionReplace ),
206
+ plancheck .ExpectKnownValue (
207
+ "cloudflare_ruleset.my_ruleset" ,
208
+ tfjsonpath .New ("kind" ),
209
+ knownvalue .StringExact ("custom" ),
210
+ ),
211
+ },
212
+ },
213
+ ConfigStateChecks : []statecheck.StateCheck {
214
+ statecheck .ExpectKnownValue (
215
+ "cloudflare_ruleset.my_ruleset" ,
216
+ tfjsonpath .New ("kind" ),
217
+ knownvalue .StringExact ("custom" ),
218
+ ),
219
+ },
220
+ },
221
+ },
222
+ })
223
+ }
224
+
21
225
func TestAccCloudflareRuleset_RuleLogging (t * testing.T ) {
22
226
resource .Test (t , resource.TestCase {
23
227
PreCheck : func () { acctest .TestAccPreCheck (t ) },
0 commit comments