Skip to content

Commit 183b4f9

Browse files
committed
New fail mocks for null
Added testing for the null values in the aws_security_group_rule loop. Moved the function docs to the right folder.
1 parent 0f47eed commit 183b4f9

File tree

4 files changed

+150
-28
lines changed

4 files changed

+150
-28
lines changed

governance/third-generation/aws/test/restrict-ingress-sg-rule-rdp/mock-tfplan-fail.sentinel

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ resource_changes = {
1616
"from_port": 0,
1717
"ipv6_cidr_blocks": [],
1818
"prefix_list_ids": [],
19-
"protocol": "-1",
19+
"protocol": "tcp",
2020
"security_groups": [],
2121
"self": false,
22-
"to_port": 3389,
22+
"to_port": 9443,
2323
},
2424
],
2525
"name": "bar",
@@ -69,13 +69,13 @@ resource_changes = {
6969
"0.0.0.0/0",
7070
],
7171
"description": "baz",
72-
"from_port": 0,
72+
"from_port": null,
7373
"ipv6_cidr_blocks": [],
7474
"prefix_list_ids": [],
7575
"protocol": "tcp",
7676
"security_groups": [],
7777
"self": false,
78-
"to_port": 9443,
78+
"to_port": 3389,
7979
},
8080
],
8181
"name": "baz",
@@ -174,18 +174,42 @@ resource_changes = {
174174
"create",
175175
],
176176
"after": {
177-
"description": "seuss",
177+
"description": "seuss",
178+
"ingress": [
179+
{
180+
"cidr_blocks": [
181+
"0.0.0.0/0",
182+
],
183+
"description": "seuss",
184+
"from_port": 3389,
185+
"ipv6_cidr_blocks": [],
186+
"prefix_list_ids": [],
187+
"protocol": "tcp",
188+
"security_groups": [],
189+
"self": false,
190+
"to_port": null,
191+
},
192+
],
178193
"name": "seuss",
179194
"name_prefix": null,
180195
"revoke_rules_on_delete": false,
181196
"tags": null,
182197
"timeouts": null,
183198
},
184199
"after_unknown": {
185-
"arn": true,
186-
"egress": true,
187-
"id": true,
188-
"ingress": true,
200+
"arn": true,
201+
"egress": true,
202+
"id": true,
203+
"ingress": [
204+
{
205+
"cidr_blocks": [
206+
false,
207+
],
208+
"ipv6_cidr_blocks": [],
209+
"prefix_list_ids": [],
210+
"security_groups": [],
211+
},
212+
],
189213
"owner_id": true,
190214
"vpc_id": true,
191215
},
@@ -195,7 +219,7 @@ resource_changes = {
195219
"index": null,
196220
"mode": "managed",
197221
"module_address": "",
198-
"name": "seuss",
222+
"name": "foo",
199223
"provider_name": "aws",
200224
"type": "aws_security_group",
201225
},
@@ -215,7 +239,7 @@ resource_changes = {
215239
"prefix_list_ids": null,
216240
"protocol": "-1",
217241
"self": false,
218-
"to_port": 0,
242+
"to_port": 9443,
219243
"type": "ingress",
220244
},
221245
"after_unknown": {
@@ -247,7 +271,7 @@ resource_changes = {
247271
"0.0.0.0/0",
248272
],
249273
"description": "green",
250-
"from_port": 0,
274+
"from_port": 3389,
251275
"ipv6_cidr_blocks": null,
252276
"prefix_list_ids": null,
253277
"protocol": "tcp",
@@ -284,12 +308,12 @@ resource_changes = {
284308
"0.0.0.0/0",
285309
],
286310
"description": "ham",
287-
"from_port": 0,
311+
"from_port": null,
288312
"ipv6_cidr_blocks": null,
289313
"prefix_list_ids": null,
290314
"protocol": "tcp",
291315
"self": false,
292-
"to_port": 9443,
316+
"to_port": 3389,
293317
"type": "ingress",
294318
},
295319
"after_unknown": {
@@ -310,4 +334,41 @@ resource_changes = {
310334
"provider_name": "aws",
311335
"type": "aws_security_group_rule",
312336
},
313-
}
337+
"aws_security_group_rule.bar": {
338+
"address": "aws_security_group_rule.bar",
339+
"change": {
340+
"actions": [
341+
"create",
342+
],
343+
"after": {
344+
"cidr_blocks": [
345+
"0.0.0.0/0",
346+
],
347+
"description": "bar",
348+
"from_port": 3389,
349+
"ipv6_cidr_blocks": null,
350+
"prefix_list_ids": null,
351+
"protocol": "tcp",
352+
"self": false,
353+
"to_port": null,
354+
"type": "ingress",
355+
},
356+
"after_unknown": {
357+
"cidr_blocks": [
358+
false,
359+
],
360+
"id": true,
361+
"security_group_id": true,
362+
"source_security_group_id": true,
363+
},
364+
"before": null,
365+
},
366+
"deposed": "",
367+
"index": null,
368+
"mode": "managed",
369+
"module_address": "",
370+
"name": "bar",
371+
"provider_name": "aws",
372+
"type": "aws_security_group_rule",
373+
},
374+
}

governance/third-generation/aws/test/restrict-ingress-sg-rule-ssh/mock-tfplan-fail.sentinel

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ resource_changes = {
1616
"from_port": 0,
1717
"ipv6_cidr_blocks": [],
1818
"prefix_list_ids": [],
19-
"protocol": "-1",
19+
"protocol": "tcp",
2020
"security_groups": [],
2121
"self": false,
22-
"to_port": 22,
22+
"to_port": 1024,
2323
},
2424
],
2525
"name": "bar",
@@ -69,13 +69,13 @@ resource_changes = {
6969
"0.0.0.0/0",
7070
],
7171
"description": "baz",
72-
"from_port": 0,
72+
"from_port": null,
7373
"ipv6_cidr_blocks": [],
7474
"prefix_list_ids": [],
7575
"protocol": "tcp",
7676
"security_groups": [],
7777
"self": false,
78-
"to_port": 1024,
78+
"to_port": 22,
7979
},
8080
],
8181
"name": "baz",
@@ -174,18 +174,42 @@ resource_changes = {
174174
"create",
175175
],
176176
"after": {
177-
"description": "seuss",
177+
"description": "seuss",
178+
"ingress": [
179+
{
180+
"cidr_blocks": [
181+
"0.0.0.0/0",
182+
],
183+
"description": "seuss",
184+
"from_port": 22,
185+
"ipv6_cidr_blocks": [],
186+
"prefix_list_ids": [],
187+
"protocol": "tcp",
188+
"security_groups": [],
189+
"self": false,
190+
"to_port": null,
191+
},
192+
],
178193
"name": "seuss",
179194
"name_prefix": null,
180195
"revoke_rules_on_delete": false,
181196
"tags": null,
182197
"timeouts": null,
183198
},
184199
"after_unknown": {
185-
"arn": true,
186-
"egress": true,
187-
"id": true,
188-
"ingress": true,
200+
"arn": true,
201+
"egress": true,
202+
"id": true,
203+
"ingress": [
204+
{
205+
"cidr_blocks": [
206+
false,
207+
],
208+
"ipv6_cidr_blocks": [],
209+
"prefix_list_ids": [],
210+
"security_groups": [],
211+
},
212+
],
189213
"owner_id": true,
190214
"vpc_id": true,
191215
},
@@ -195,7 +219,7 @@ resource_changes = {
195219
"index": null,
196220
"mode": "managed",
197221
"module_address": "",
198-
"name": "seuss",
222+
"name": "foo",
199223
"provider_name": "aws",
200224
"type": "aws_security_group",
201225
},
@@ -215,7 +239,7 @@ resource_changes = {
215239
"prefix_list_ids": null,
216240
"protocol": "-1",
217241
"self": false,
218-
"to_port": 0,
242+
"to_port": 1024,
219243
"type": "ingress",
220244
},
221245
"after_unknown": {
@@ -284,12 +308,12 @@ resource_changes = {
284308
"0.0.0.0/0",
285309
],
286310
"description": "ham",
287-
"from_port": 0,
311+
"from_port": null,
288312
"ipv6_cidr_blocks": null,
289313
"prefix_list_ids": null,
290314
"protocol": "tcp",
291315
"self": false,
292-
"to_port": 1024,
316+
"to_port": 22,
293317
"type": "ingress",
294318
},
295319
"after_unknown": {
@@ -310,4 +334,41 @@ resource_changes = {
310334
"provider_name": "aws",
311335
"type": "aws_security_group_rule",
312336
},
337+
"aws_security_group_rule.bar": {
338+
"address": "aws_security_group_rule.bar",
339+
"change": {
340+
"actions": [
341+
"create",
342+
],
343+
"after": {
344+
"cidr_blocks": [
345+
"0.0.0.0/0",
346+
],
347+
"description": "bar",
348+
"from_port": 22,
349+
"ipv6_cidr_blocks": null,
350+
"prefix_list_ids": null,
351+
"protocol": "tcp",
352+
"self": false,
353+
"to_port": null,
354+
"type": "ingress",
355+
},
356+
"after_unknown": {
357+
"cidr_blocks": [
358+
false,
359+
],
360+
"id": true,
361+
"security_group_id": true,
362+
"source_security_group_id": true,
363+
},
364+
"before": null,
365+
},
366+
"deposed": "",
367+
"index": null,
368+
"mode": "managed",
369+
"module_address": "",
370+
"name": "bar",
371+
"provider_name": "aws",
372+
"type": "aws_security_group_rule",
373+
},
313374
}

0 commit comments

Comments
 (0)