Skip to content

Commit

Permalink
Test that network policies have expected length of 1 in addition to c…
Browse files Browse the repository at this point in the history
…orrect values
  • Loading branch information
rahearn committed Jun 24, 2024
1 parent f112015 commit 83b73f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ module "egress_space" {
1. cd to module root. Example: `cd s3`
1. Run `terraform init`
1. Run `terraform test`

When updating code, try to cover every input and output variable with at least one test to verify it is connected properly.
6 changes: 3 additions & 3 deletions clamav/tests/creation.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ run "test_app_creation" {
}

assert {
condition = [for policy in cloudfoundry_network_policy.clamav_routing.policy : policy.source_app][0] == data.cloudfoundry_app.app.id
condition = [for policy in cloudfoundry_network_policy.clamav_routing.policy : policy.source_app] == [data.cloudfoundry_app.app.id]
error_message = "Routing policy allows traffic from the source app"
}

assert {
condition = [for policy in cloudfoundry_network_policy.clamav_routing.policy : policy.destination_app][0] == cloudfoundry_app.clamav_api.id
condition = [for policy in cloudfoundry_network_policy.clamav_routing.policy : policy.destination_app] == [cloudfoundry_app.clamav_api.id]
error_message = "Routing policy allows traffic to the clamav app"
}

assert {
condition = [for policy in cloudfoundry_network_policy.clamav_routing.policy : policy.port][0] == "61443"
condition = [for policy in cloudfoundry_network_policy.clamav_routing.policy : policy.port] == ["61443"]
error_message = "Routing policy opens up traffic on the internal https port"
}
}
Expand Down

0 comments on commit 83b73f7

Please sign in to comment.