Skip to content

Commit de0afd0

Browse files
committed
chore : refactor tests
1 parent f660c62 commit de0afd0

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

modules/permission_sets/main.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ resource "aws_ssoadmin_permission_set_inline_policy" "this" {
1414
inline_policy = each.value
1515
instance_arn = local.sso_instance_arn
1616
permission_set_arn = aws_ssoadmin_permission_set.this[each.key].arn
17-
18-
#Ensures that this resource waits for the specified permission set to be created or updated before proceeding.
19-
depends_on = [aws_ssoadmin_permission_set.this]
2017
}
2118

2219
resource "aws_ssoadmin_managed_policy_attachment" "this" {
@@ -25,9 +22,6 @@ resource "aws_ssoadmin_managed_policy_attachment" "this" {
2522
instance_arn = local.sso_instance_arn
2623
managed_policy_arn = each.value.policy_arn
2724
permission_set_arn = aws_ssoadmin_permission_set.this[each.value.ps_name].arn
28-
29-
#Ensures that this resource waits for the specified permission set to be created or updated before proceeding.
30-
depends_on = [aws_ssoadmin_permission_set.this]
3125
}
3226

3327
resource "aws_ssoadmin_customer_managed_policy_attachment" "this" {
@@ -38,7 +32,4 @@ resource "aws_ssoadmin_customer_managed_policy_attachment" "this" {
3832
name = each.value.policy_name
3933
path = each.value.policy_path
4034
}
41-
42-
#Ensures that this resource waits for the specified permission set to be created or updated before proceeding.
43-
depends_on = [aws_ssoadmin_permission_set.this]
4435
}

tests/permission_sets_unit-tests.tftest.hcl

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Attribute validations for permission_sets sub module
22
run "validate_inline_policy" {
3-
module {
4-
source = "./modules/permission_sets"
5-
}
3+
command = plan
4+
65
variables {
76
permission_sets = {
87
"dummy_ps" = {
@@ -15,16 +14,18 @@ run "validate_inline_policy" {
1514
}
1615
}
1716

18-
command = plan
17+
module {
18+
source = "./modules/permission_sets"
19+
}
20+
1921
expect_failures = [
2022
var.permission_sets["dummy_ps"]
2123
]
2224
}
2325

2426
run "validate_inline_policy_json_content" {
25-
module {
26-
source = "./modules/permission_sets"
27-
}
27+
command = plan
28+
2829
variables {
2930
permission_sets = {
3031
"dummy_ps" = {
@@ -37,17 +38,19 @@ run "validate_inline_policy_json_content" {
3738
}
3839
}
3940

40-
command = plan
41+
module {
42+
source = "./modules/permission_sets"
43+
}
44+
4145
expect_failures = [
4246
var.permission_sets["dummy_ps"]
4347
]
4448
}
4549

4650

4751
run "validate_permission_set_name" {
48-
module {
49-
source = "./modules/permission_sets"
50-
}
52+
command = plan
53+
5154
variables {
5255
permission_sets = {
5356
"dummy_ps" = {
@@ -59,7 +62,11 @@ run "validate_permission_set_name" {
5962
}
6063
}
6164
}
62-
command = plan
65+
66+
module {
67+
source = "./modules/permission_sets"
68+
}
69+
6370

6471
assert {
6572
condition = aws_ssoadmin_permission_set.this["dummy_ps"].name == var.permission_sets["dummy_ps"].name
@@ -68,9 +75,8 @@ run "validate_permission_set_name" {
6875
}
6976

7077
run "validate_permission_set_description" {
71-
module {
72-
source = "./modules/permission_sets"
73-
}
78+
command = plan
79+
7480
variables {
7581
permission_sets = {
7682
"dummy_ps" = {
@@ -82,7 +88,10 @@ run "validate_permission_set_description" {
8288
},
8389
}
8490
}
85-
command = plan
91+
92+
module {
93+
source = "./modules/permission_sets"
94+
}
8695

8796
assert {
8897
condition = aws_ssoadmin_permission_set.this["dummy_ps"].description == var.permission_sets["dummy_ps"].description
@@ -91,9 +100,9 @@ run "validate_permission_set_description" {
91100
}
92101

93102
run "check_permission_set_creation" {
94-
module {
95-
source = "./modules/permission_sets"
96-
}
103+
104+
command = apply
105+
97106
variables {
98107
permission_sets = {
99108
"dummy_ps" = {
@@ -105,7 +114,10 @@ run "check_permission_set_creation" {
105114
},
106115
}
107116
}
108-
command = apply
117+
118+
module {
119+
source = "./modules/permission_sets"
120+
}
109121

110122
assert {
111123
condition = can(aws_ssoadmin_permission_set.this["dummy_ps"])

0 commit comments

Comments
 (0)