Skip to content

Commit 7d064b3

Browse files
committed
chore : refactor code
1 parent 6e01fa6 commit 7d064b3

File tree

2 files changed

+34
-78
lines changed

2 files changed

+34
-78
lines changed
Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,57 @@
1-
run "checks_identity_group_creation" {
21

3-
module {
4-
source = "./modules/sso_groups"
5-
}
2+
#Argument validation for user-group-assignment module
3+
run "check_for_invalid_user" {
4+
command = plan
65

76
variables {
8-
sso_groups = {
9-
"Dummy_Group" = {
10-
group_name = "Dummy_Group"
11-
group_description = "Dummy_Group for testing purpose"
12-
}
7+
user_groups_mapping = {
8+
"dummyUser@gmail.com" = [
9+
"Group1"
10+
]
1311
}
1412
}
1513

16-
command = plan
17-
18-
assert {
19-
condition = aws_identitystore_group.this["Dummy_Group"].display_name == "Dummy_Group"
20-
error_message = "Group 'Dummy_Group' doesn't match"
14+
module {
15+
source = "./modules/sso_groups"
2116
}
2217

23-
assert {
24-
condition = aws_identitystore_group.this["Dummy_Group"].description == var.sso_groups["Dummy_Group"].group_description
25-
error_message = "Group description ${var.sso_groups["Dummy_Group"].group_description} doesn't match"
26-
}
18+
expect_failures = [
19+
var.user_groups_mapping
20+
]
2721
}
2822

29-
run "check_for_empty_groups" {
23+
run "check_for_valid_user_with_no_groups" {
24+
command = plan
25+
26+
variables {
27+
user_groups_mapping = {
28+
"dummyUser@gmail.com" = []
29+
}
30+
}
31+
3032
module {
3133
source = "./modules/sso_groups"
3234
}
3335

36+
expect_failures = [
37+
var.user_groups_mapping
38+
]
39+
}
40+
41+
run "check_for_invalid_group" {
42+
command = plan
43+
3444
variables {
3545
user_groups_mapping = {
36-
"user" = []
46+
"dummyUser@gmail.com" = [""]
3747
}
3848
}
3949

40-
command = plan
50+
module {
51+
source = "./modules/sso_groups"
52+
}
4153

4254
expect_failures = [
43-
var.user_groups_mapping["user"]
55+
var.user_groups_mapping
4456
]
4557
}

tests/user_groups_assignment_unit-tests.tftest.hcl

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)