Skip to content

Commit 90184a7

Browse files
committed
fix: correct test for spec chars in password
1 parent 2cd1e4b commit 90184a7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/main.tftest.hcl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ run "validate_databases" {
3030
}
3131

3232
assert {
33-
condition = postgresql_database.logical_db["app"].name == "app"
33+
condition = postgresql_database.logical_dbs["app"].name == "app"
3434
error_message = "Database should have correct name"
3535
}
3636

3737
assert {
38-
condition = postgresql_database.logical_db["app"].connection_limit == 10
38+
condition = postgresql_database.logical_dbs["app"].connection_limit == 10
3939
error_message = "Database should have correct connection limit"
4040
}
4141

4242
assert {
43-
condition = postgresql_database.logical_db["app2"].connection_limit == null
43+
condition = postgresql_database.logical_dbs["app2"].connection_limit == null
4444
error_message = "Database should have no connection limit"
4545
}
4646
}
@@ -58,6 +58,7 @@ run "validate_roles_with_password" {
5858
}
5959
}
6060

61+
6162
run "validate_roles_with_random_password" {
6263
command = apply
6364

@@ -71,7 +72,7 @@ run "validate_roles_with_random_password" {
7172
}
7273

7374
assert {
74-
condition = !contains(split("", postgresql_role.role["app_user2"].password), "!#$%^&*()<>-_")
75-
error_message = "Password should not contain the '!#$%^&*()<>-_' characters"
75+
condition = alltrue([for c in ["!", "#", "$", "%", "^", "&", "*", "(", ")", "<", ">", "-", "_"] : length(split(c, postgresql_role.role["app_user2"].password)) == 1])
76+
error_message = "Password contains forbidden special characters"
7677
}
7778
}

0 commit comments

Comments
 (0)