Skip to content

Commit

Permalink
Add test for setting proxy allowlist
Browse files Browse the repository at this point in the history
  • Loading branch information
rahearn committed Dec 17, 2024
1 parent 904c49d commit f5d21a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ locals {
"*.fedoraproject.org", # fedora runner dependencies install
"s3.dualstack.us-east-1.amazonaws.com" # gitlab-runner-helper source for runners
]
proxy_allowlist = setunion(local.devtools_egress_allowlist, var.worker_egress_allowlist)
}

# the `depends_on` lines for each resource or module is needed to properly sequence initial creation
Expand Down Expand Up @@ -168,7 +169,7 @@ module "egress_proxy" {
cf_egress_space = module.egress_space.space
name = var.egress_app_name
allowports = [80, 443, 2222]
allowlist = setunion(local.devtools_egress_allowlist, var.worker_egress_allowlist)
allowlist = local.proxy_allowlist
# see egress_proxy/variables.tf for full list of optional arguments
depends_on = [module.egress_space]
}
Expand Down
19 changes: 17 additions & 2 deletions tests/creation.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ provider "cloudfoundry-community" {
}

variables {
cf_space_prefix = "glr-cg-ci-tests"
ci_server_token = "fake-gdg-server-token"
cf_space_prefix = "glr-cg-ci-tests"
ci_server_token = "fake-gdg-server-token"
worker_egress_allowlist = ["*.rubygems.org", "gsa-0.gitlab-dedicated.us"]
}

run "test-system-creation" {
Expand Down Expand Up @@ -94,4 +95,18 @@ run "test-system-creation" {
])
error_message = "Service account is granted space_developer on the egress space"
}

assert {
condition = local.proxy_allowlist == toset([
"*.fr.cloud.gov",
"gsa-0.gitlab-dedicated.us",
"deb.debian.org",
"*.ubuntu.com",
"dl-cdn.alpinelinux.org",
"*.fedoraproject.org",
"s3.dualstack.us-east-1.amazonaws.com",
"*.rubygems.org"
])
error_message = "The egress allowlist contains manager and worker entries"
}
}

0 comments on commit f5d21a1

Please sign in to comment.