diff --git a/Makefile b/Makefile index 6f87f72a..1a60f279 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ docker_test_integration: -e SERVICE_ACCOUNT_JSON \ -v "$(CURDIR)":/workspace \ $(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \ - /usr/local/bin/test_integration.sh + cft test run all # Execute lint tests within the docker container .PHONY: docker_test_lint diff --git a/build/int.cloudbuild.yaml b/build/int.cloudbuild.yaml index 8a144395..8369baa9 100644 --- a/build/int.cloudbuild.yaml +++ b/build/int.cloudbuild.yaml @@ -24,182 +24,201 @@ steps: - 'TF_VAR_org_id=$_ORG_ID' - 'TF_VAR_folder_id=$_FOLDER_ID' - 'TF_VAR_billing_account=$_BILLING_ACCOUNT' -- id: init-all - waitFor: - - prepare - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run all --stage init --verbose'] -- id: create - waitFor: - - init-all - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create'] -- id: converge - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge'] -- id: verify - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && sleep 720 && kitchen_do verify'] -- id: destroy - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy'] -# cdn-policy example -- id: cdn-policy-example-init - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage init --verbose'] -- id: cdn-policy-example-apply - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage apply --verbose'] -- id: cdn-policy-example-verify - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage verify --verbose'] -- id: cdn-policy-example-teardown - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage teardown --verbose'] -# traffic-director example -- id: traffic-director-example-init - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage init --verbose'] -- id: traffic-director-example-apply - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage apply --verbose'] -- id: traffic-director-example-verify - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage verify --verbose'] -- id: traffic-director-example-teardown - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage teardown --verbose'] -# certificate-map example -- id: certificate-map-example-init - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage init --verbose'] -- id: certificate-map-example-apply - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage apply --verbose'] -- id: certificate-map-example-verify - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage verify --verbose'] -- id: certificate-map-example-teardown - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage teardown --verbose'] -# managed-manual-certificates example -- id: user-managed-google-managed-ssl-example-init - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage init --verbose'] -- id: user-managed-google-managed-ssl-example-apply - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage apply --verbose'] -- id: user-managed-google-managed-ssl-example-verify - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage verify --verbose'] -- id: user-managed-google-managed-ssl-example-teardown - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage teardown --verbose'] -# cloudrun implicit serverless negs -- id: apply cloudrun-implicit - waitFor: - - create - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestCloudrunImplicit --stage apply --verbose'] -- id: verify cloudrun-implicit - waitFor: - - apply cloudrun-implicit - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'sleep 720 && cft test run TestCloudrunImplicit --stage verify --verbose'] -- id: teardown cloudrun-implicit - waitFor: - - verify cloudrun-implicit - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestCloudrunImplicit --stage teardown --verbose'] -# separate frontend and backend module for http load balancer -- id: apply lb-http-separate-frontend-and-backend - waitFor: - - create - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestSeparateFrontendAndBackend --stage apply --verbose'] -- id: verify lb-http-separate-frontend-and-backend - waitFor: - - apply lb-http-separate-frontend-and-backend - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'sleep 720 && cft test run TestSeparateFrontendAndBackend --stage verify --verbose'] -- id: teardown lb-http-separate-frontend-and-backend - waitFor: - - verify lb-http-separate-frontend-and-backend - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestSeparateFrontendAndBackend --stage teardown --verbose'] - # Internal cross regional http load balancer with cloud-run -- id: apply internal-lb-http - waitFor: - - create - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestInternalLbCloudRun --stage apply --verbose'] -- id: verify internal-lb-http - waitFor: - - apply internal-lb-http - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'sleep 360 && cft test run TestInternalLbCloudRun --stage verify --verbose'] -- id: teardown internal-lb-http - waitFor: - - verify internal-lb-http - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestInternalLbCloudRun --stage teardown --verbose'] -- id: apply internal-lb-http gce-mig - waitFor: - - create - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestInternalLbGCEMIG --stage apply --verbose'] -- id: verify internal-lb-http gce-mig - waitFor: - - apply internal-lb-http gce-mig - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'sleep 360 && cft test run TestInternalLbGCEMIG --stage verify --verbose'] -- id: teardown internal-lb-http gce-mig - waitFor: - - verify internal-lb-http gce-mig - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestInternalLbGCEMIG --stage teardown --verbose'] - # Backend Service with IAP Enabled -- id: init backend-with-iap - waitFor: - - teardown internal-lb-http gce-mig - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage init --verbose'] -- id: apply backend-with-iap - waitFor: - - init backend-with-iap - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage apply --verbose'] -- id: verify backend-with-iap - waitFor: - - apply backend-with-iap - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage verify --verbose'] -- id: teardown backend-with-iap - waitFor: - - verify backend-with-iap - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage teardown --verbose'] - # backend-with-psc-negs example -- id: init backend-with-psc-negs - waitFor: - - teardown backend-with-iap - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage init --verbose'] -- id: apply backend-with-psc-negs - waitFor: - - init backend-with-psc-negs - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage apply --verbose'] -- id: verify backend-with-psc-negs - waitFor: - - apply backend-with-psc-negs - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage verify --verbose'] -- id: teardown backend-with-psc-negs - waitFor: - - verify backend-with-psc-negs - name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' - args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage teardown --verbose'] +###- id: init-all +### waitFor: +### - prepare +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run all --stage init --verbose'] +#### cdn-policy example +###- id: cdn-policy-example-init +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage init --verbose'] +###- id: cdn-policy-example-apply +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage apply --verbose'] +###- id: cdn-policy-example-verify +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage verify --verbose'] +###- id: cdn-policy-example-teardown +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/cdn-policy --stage teardown --verbose'] +#### traffic-director example +###- id: traffic-director-example-init +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage init --verbose'] +###- id: traffic-director-example-apply +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage apply --verbose'] +###- id: traffic-director-example-verify +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage verify --verbose'] +###- id: traffic-director-example-teardown +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/traffic-director --stage teardown --verbose'] +#### certificate-map example +###- id: certificate-map-example-init +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage init --verbose'] +###- id: certificate-map-example-apply +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage apply --verbose'] +###- id: certificate-map-example-verify +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage verify --verbose'] +###- id: certificate-map-example-teardown +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/certificate-map --stage teardown --verbose'] +#### managed-manual-certificates example +###- id: user-managed-google-managed-ssl-example-init +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage init --verbose'] +###- id: user-managed-google-managed-ssl-example-apply +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage apply --verbose'] +###- id: user-managed-google-managed-ssl-example-verify +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage verify --verbose'] +###- id: user-managed-google-managed-ssl-example-teardown +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestAll/examples/user-managed-google-managed-ssl --stage teardown --verbose'] +#### cloudrun implicit serverless negs +###- id: apply cloudrun-implicit +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestCloudrunImplicit --stage apply --verbose'] +###- id: verify cloudrun-implicit +### waitFor: +### - apply cloudrun-implicit +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'sleep 720 && cft test run TestCloudrunImplicit --stage verify --verbose'] +###- id: teardown cloudrun-implicit +### waitFor: +### - verify cloudrun-implicit +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestCloudrunImplicit --stage teardown --verbose'] +#### separate frontend and backend module for http load balancer +###- id: apply lb-http-separate-frontend-and-backend +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestSeparateFrontendAndBackend --stage apply --verbose'] +###- id: verify lb-http-separate-frontend-and-backend +### waitFor: +### - apply lb-http-separate-frontend-and-backend +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'sleep 720 && cft test run TestSeparateFrontendAndBackend --stage verify --verbose'] +###- id: teardown lb-http-separate-frontend-and-backend +### waitFor: +### - verify lb-http-separate-frontend-and-backend +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestSeparateFrontendAndBackend --stage teardown --verbose'] +### # Internal cross regional http load balancer with cloud-run +###- id: apply internal-lb-http +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestInternalLbCloudRun --stage apply --verbose'] +###- id: verify internal-lb-http +### waitFor: +### - apply internal-lb-http +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'sleep 360 && cft test run TestInternalLbCloudRun --stage verify --verbose'] +###- id: teardown internal-lb-http +### waitFor: +### - verify internal-lb-http +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestInternalLbCloudRun --stage teardown --verbose'] +###- id: apply internal-lb-http gce-mig +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestInternalLbGCEMIG --stage apply --verbose'] +###- id: verify internal-lb-http gce-mig +### waitFor: +### - apply internal-lb-http gce-mig +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'sleep 360 && cft test run TestInternalLbGCEMIG --stage verify --verbose'] +###- id: teardown internal-lb-http gce-mig +### waitFor: +### - verify internal-lb-http gce-mig +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestInternalLbGCEMIG --stage teardown --verbose'] +- id: temp-run-the-new-ones + name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' + args: ['/bin/bash', '-c', 'cft test run TestMultiMig --verbose ; cft test run TestMultipleCerts --verbose ; cft test run TestMigNat --verbose ; cft test run TestHttpsRedirect --verbose ; cft test run TestCloudRunExplicit --verbose'] +### # cloudrun example +###- id: cloudrun +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestCloudRunExplicit --verbose'] +### # multi-mig-http-lb example +###- id: multi-mig-http-lb +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestMultiMig --verbose'] +### # multiple-certs example +###- id: multiple-certs +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestMultipleCerts --verbose'] +### # mig-nat-http-lb example +###- id: mig-nat +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestMigNat --verbose'] +### # https-redirect example +###- id: https-redirect +### waitFor: +### - init-all +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestHttpsRedirect --verbose'] +### # Backend Service with IAP Enabled +###- id: init backend-with-iap +### waitFor: +### - teardown internal-lb-http gce-mig +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage init --verbose'] +###- id: apply backend-with-iap +### waitFor: +### - init backend-with-iap +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage apply --verbose'] +###- id: verify backend-with-iap +### waitFor: +### - apply backend-with-iap +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage verify --verbose'] +###- id: teardown backend-with-iap +### waitFor: +### - verify backend-with-iap +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceIap --stage teardown --verbose'] +### # backend-with-psc-negs example +###- id: init backend-with-psc-negs +### waitFor: +### - teardown backend-with-iap +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage init --verbose'] +###- id: apply backend-with-psc-negs +### waitFor: +### - init backend-with-psc-negs +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage apply --verbose'] +###- id: verify backend-with-psc-negs +### waitFor: +### - apply backend-with-psc-negs +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage verify --verbose'] +###- id: teardown backend-with-psc-negs +### waitFor: +### - verify backend-with-psc-negs +### name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' +### args: ['/bin/bash', '-c', 'cft test run TestLbBackendServiceWithPscNeg --stage teardown --verbose'] tags: - 'ci' - 'integration' diff --git a/kitchen.yml b/kitchen.yml deleted file mode 100644 index 20cb636b..00000000 --- a/kitchen.yml +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - ---- -driver: - name: terraform - -provisioner: - name: terraform - -verifier: - name: terraform - -platforms: - - name: default - -suites: - - name: cloudrun - driver: - root_module_directory: test/fixtures/cloudrun - verify_version: false - verifier: - color: false - systems: - - name: cloudrun - backend: local - controls: - - http - - name: mig_nat - driver: - root_module_directory: test/fixtures/mig_nat/ - verify_version: false - verifier: - color: false - systems: - - name: mig_nat - backend: local - controls: - - http - - name: multi_certs - driver: - root_module_directory: test/fixtures/multi_certs/ - verify_version: false - verifier: - color: false - systems: - - name: multi_certs - backend: local - controls: - - https - - https_asset - - https_patterns - - name: multi_mig - driver: - root_module_directory: test/fixtures/multi_mig/ - verify_version: false - verifier: - color: false - systems: - - name: multi_mig - backend: local - controls: - - http - - name: https_redirect - driver: - root_module_directory: test/fixtures/https-redirect/ - verify_version: false - verifier: - color: false - systems: - - name: https_redirect - backend: local - controls: - - https diff --git a/test/fixtures/cloudrun/main.tf b/test/fixtures/cloudrun/main.tf deleted file mode 100644 index 2d1f072b..00000000 --- a/test/fixtures/cloudrun/main.tf +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -module "example" { - source = "../../../examples/cloudrun" - project_id = var.project_id - ssl = false - domain = null -} diff --git a/test/fixtures/cloudrun/outputs.tf b/test/fixtures/cloudrun/outputs.tf deleted file mode 100644 index 11cb9747..00000000 --- a/test/fixtures/cloudrun/outputs.tf +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -output "project_id" { - description = "The ID of the project in which resources are provisioned." - value = var.project_id -} - -output "lb_ip" { - value = module.example.load-balancer-ip -} diff --git a/test/fixtures/cloudrun/variables.tf b/test/fixtures/cloudrun/variables.tf deleted file mode 100644 index bba35006..00000000 --- a/test/fixtures/cloudrun/variables.tf +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -variable "project_id" { - description = "The ID of the project in which to provision resources." - type = string -} diff --git a/test/fixtures/cloudrun/versions.tf b/test/fixtures/cloudrun/versions.tf deleted file mode 100644 index 2a088552..00000000 --- a/test/fixtures/cloudrun/versions.tf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -terraform { - required_version = ">= 0.13.0" -} diff --git a/test/fixtures/https-redirect/main.tf b/test/fixtures/https-redirect/main.tf deleted file mode 100644 index 8010a082..00000000 --- a/test/fixtures/https-redirect/main.tf +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_id" "random_net" { - byte_length = 2 -} - -module "example" { - source = "../../../examples/https-redirect" - - network_name = "ci-lb-https-redirect-${random_id.random_net.hex}" - project = var.project_id -} diff --git a/test/fixtures/https-redirect/outputs.tf b/test/fixtures/https-redirect/outputs.tf deleted file mode 100644 index 0b30faea..00000000 --- a/test/fixtures/https-redirect/outputs.tf +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -output "project_id" { - description = "The ID of the project in which resources are provisioned." - value = var.project_id -} - -output "lb_ip" { - value = module.example.load-balancer-ip -} diff --git a/test/fixtures/https-redirect/variables.tf b/test/fixtures/https-redirect/variables.tf deleted file mode 100644 index 9db1f88e..00000000 --- a/test/fixtures/https-redirect/variables.tf +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -variable "project_id" { - description = "The ID of the project in which to provision resources." - type = string -} diff --git a/test/fixtures/https-redirect/versions.tf b/test/fixtures/https-redirect/versions.tf deleted file mode 100644 index b1df4b16..00000000 --- a/test/fixtures/https-redirect/versions.tf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -terraform { - required_version = ">= 0.13.0" -} diff --git a/test/fixtures/mig_nat/main.tf b/test/fixtures/mig_nat/main.tf deleted file mode 100644 index 5e6628d9..00000000 --- a/test/fixtures/mig_nat/main.tf +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_id" "random_net" { - byte_length = 2 -} - -module "example" { - source = "../../../examples/mig-nat-http-lb" - - network_name = "ci-lb-http-mig-nat-${random_id.random_net.hex}" - project = var.project_id -} diff --git a/test/fixtures/mig_nat/outputs.tf b/test/fixtures/mig_nat/outputs.tf deleted file mode 100644 index 0b30faea..00000000 --- a/test/fixtures/mig_nat/outputs.tf +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -output "project_id" { - description = "The ID of the project in which resources are provisioned." - value = var.project_id -} - -output "lb_ip" { - value = module.example.load-balancer-ip -} diff --git a/test/fixtures/mig_nat/variables.tf b/test/fixtures/mig_nat/variables.tf deleted file mode 100644 index 9db1f88e..00000000 --- a/test/fixtures/mig_nat/variables.tf +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -variable "project_id" { - description = "The ID of the project in which to provision resources." - type = string -} diff --git a/test/fixtures/mig_nat/versions.tf b/test/fixtures/mig_nat/versions.tf deleted file mode 100644 index b1df4b16..00000000 --- a/test/fixtures/mig_nat/versions.tf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -terraform { - required_version = ">= 0.13.0" -} diff --git a/test/fixtures/multi_certs/gcp-logo.svg b/test/fixtures/multi_certs/gcp-logo.svg deleted file mode 100644 index 45c38c4e..00000000 --- a/test/fixtures/multi_certs/gcp-logo.svg +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/fixtures/multi_certs/main.tf b/test/fixtures/multi_certs/main.tf deleted file mode 100644 index d2a718f3..00000000 --- a/test/fixtures/multi_certs/main.tf +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_id" "random_net" { - byte_length = 2 -} - -module "example" { - source = "../../../examples/multiple-certs" - - network_name = "ci-lb-http-multi-certs-${random_id.random_net.hex}" - project = var.project_id -} diff --git a/test/fixtures/multi_certs/outputs.tf b/test/fixtures/multi_certs/outputs.tf deleted file mode 100644 index 55d8d713..00000000 --- a/test/fixtures/multi_certs/outputs.tf +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -output "project_id" { - description = "The ID of the project in which resources are provisioned." - value = var.project_id -} - -output "lb_ip" { - value = module.example.load-balancer-ip -} - -output "group1_region" { - value = module.example.group1_region -} - -output "group2_region" { - value = module.example.group2_region -} - -output "group3_region" { - value = module.example.group3_region -} - -output "asset_url" { - value = module.example.asset-url -} - diff --git a/test/fixtures/multi_certs/variables.tf b/test/fixtures/multi_certs/variables.tf deleted file mode 100644 index 9db1f88e..00000000 --- a/test/fixtures/multi_certs/variables.tf +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -variable "project_id" { - description = "The ID of the project in which to provision resources." - type = string -} diff --git a/test/fixtures/multi_certs/versions.tf b/test/fixtures/multi_certs/versions.tf deleted file mode 100644 index b1df4b16..00000000 --- a/test/fixtures/multi_certs/versions.tf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -terraform { - required_version = ">= 0.13.0" -} diff --git a/test/fixtures/multi_mig/main.tf b/test/fixtures/multi_mig/main.tf deleted file mode 100644 index 8f15c045..00000000 --- a/test/fixtures/multi_mig/main.tf +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_id" "random_net" { - byte_length = 2 -} - -module "example" { - source = "../../../examples/multi-mig-http-lb" - - network_prefix = "ci-lb-http-multi-mig-nat-${random_id.random_net.hex}" - project = var.project_id -} diff --git a/test/fixtures/multi_mig/outputs.tf b/test/fixtures/multi_mig/outputs.tf deleted file mode 100644 index 0b30faea..00000000 --- a/test/fixtures/multi_mig/outputs.tf +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -output "project_id" { - description = "The ID of the project in which resources are provisioned." - value = var.project_id -} - -output "lb_ip" { - value = module.example.load-balancer-ip -} diff --git a/test/fixtures/multi_mig/variables.tf b/test/fixtures/multi_mig/variables.tf deleted file mode 100644 index 9db1f88e..00000000 --- a/test/fixtures/multi_mig/variables.tf +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -variable "project_id" { - description = "The ID of the project in which to provision resources." - type = string -} diff --git a/test/fixtures/multi_mig/versions.tf b/test/fixtures/multi_mig/versions.tf deleted file mode 100644 index b1df4b16..00000000 --- a/test/fixtures/multi_mig/versions.tf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -terraform { - required_version = ">= 0.13.0" -} diff --git a/test/integration/cloudrun/cloudrun_test.go b/test/integration/cloudrun/cloudrun_test.go new file mode 100644 index 00000000..365e1aba --- /dev/null +++ b/test/integration/cloudrun/cloudrun_test.go @@ -0,0 +1,42 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudrun_test + +import ( + "testing" + + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" + "github.com/stretchr/testify/assert" + + test "github.com/terraform-google-modules/terraform-google-lb-http/test/integration" +) + +func TestCloudRunExplicit(t *testing.T) { + vars := map[string]interface{}{ + "ssl": false, + "domain": "asdf", + } + bpt := tft.NewTFBlueprintTest(t, tft.WithVars(vars)) + + bpt.DefineVerify(func(assert *assert.Assertions) { + bpt.DefaultVerify(assert) + + loadBalancerIp := bpt.GetStringOutput("load-balancer-ip") + + test.AssertResponseStatus(t, assert, "http://"+loadBalancerIp, 200) + }) + + bpt.Test() +} diff --git a/test/integration/cloudrun/controls/http.rb b/test/integration/cloudrun/controls/http.rb deleted file mode 100644 index c7f63b70..00000000 --- a/test/integration/cloudrun/controls/http.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -control "http" do - title "HTTP Check" - - describe http("http://#{attribute("lb_ip")}") do - its('status') { should eq 200 } - end -end diff --git a/test/integration/cloudrun/inspec.yml b/test/integration/cloudrun/inspec.yml deleted file mode 100644 index fdf3d433..00000000 --- a/test/integration/cloudrun/inspec.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: cloudrun -attributes: - - name: project_id - required: true - type: string - - name: lb_ip - required: true - type: string diff --git a/test/integration/https-redirect/https_redirect_test.go b/test/integration/https-redirect/https_redirect_test.go new file mode 100644 index 00000000..8e4998fb --- /dev/null +++ b/test/integration/https-redirect/https_redirect_test.go @@ -0,0 +1,50 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package https_redirect_test + +import ( + "crypto/tls" + "net/http" + "testing" + + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" + "github.com/stretchr/testify/assert" + + test "github.com/terraform-google-modules/terraform-google-lb-http/test/integration" +) + +func TestHttpsRedirect(t *testing.T) { + bpt := tft.NewTFBlueprintTest(t) + + vars := map[string]interface{}{ + "network_name": "ci-lb-https-redirect", + "project": bpt.GetTFSetupStringOutput("project_id"), + } + + tft.WithVars(vars)(bpt) + + bpt.DefineVerify(func(assert *assert.Assertions) { + bpt.DefaultVerify(assert) + + loadBalancerIp := bpt.GetStringOutput("load-balancer-ip") + + test.AssertResponseStatus(t, assert, "http://"+loadBalancerIp, 301) + + insecureClient := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}} + test.AssertResponseStatusWithClient(t, assert, insecureClient, "https://"+loadBalancerIp, 200) + }) + + bpt.Test() +} diff --git a/test/integration/https_redirect/controls/https.rb b/test/integration/https_redirect/controls/https.rb deleted file mode 100644 index e23c594c..00000000 --- a/test/integration/https_redirect/controls/https.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -control "https" do - title "HTTPs Check" - - describe http("http://#{attribute("lb_ip")}") do - its('status') { should eq 301 } - end - describe http("https://#{attribute("lb_ip")}", - ssl_verify: false) do - its('status') { should eq 200 } - end -end diff --git a/test/integration/https_redirect/inspec.yml b/test/integration/https_redirect/inspec.yml deleted file mode 100644 index c97a2e29..00000000 --- a/test/integration/https_redirect/inspec.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: https_redirect -attributes: - - name: project_id - required: true - type: string - - name: lb_ip - required: true - type: string diff --git a/test/integration/mig-nat-http-lb/mig_nat_test.go b/test/integration/mig-nat-http-lb/mig_nat_test.go new file mode 100644 index 00000000..708183aa --- /dev/null +++ b/test/integration/mig-nat-http-lb/mig_nat_test.go @@ -0,0 +1,45 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package mig_nat_test + +import ( + "testing" + + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" + "github.com/stretchr/testify/assert" + + test "github.com/terraform-google-modules/terraform-google-lb-http/test/integration" +) + +func TestMigNat(t *testing.T) { + bpt := tft.NewTFBlueprintTest(t) + + vars := map[string]interface{}{ + "network_name": "ci-lb-http-mig-nat", + "project": bpt.GetTFSetupStringOutput("project_id"), + } + + tft.WithVars(vars)(bpt) + + bpt.DefineVerify(func(assert *assert.Assertions) { + bpt.DefaultVerify(assert) + + loadBalancerIp := bpt.GetStringOutput("load-balancer-ip") + + test.AssertResponseStatus(t, assert, "http://"+loadBalancerIp, 200) + }) + + bpt.Test() +} diff --git a/test/integration/mig_nat/controls/http.rb b/test/integration/mig_nat/controls/http.rb deleted file mode 100644 index c7f63b70..00000000 --- a/test/integration/mig_nat/controls/http.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -control "http" do - title "HTTP Check" - - describe http("http://#{attribute("lb_ip")}") do - its('status') { should eq 200 } - end -end diff --git a/test/integration/mig_nat/inspec.yml b/test/integration/mig_nat/inspec.yml deleted file mode 100644 index 0d4b27dc..00000000 --- a/test/integration/mig_nat/inspec.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: mig_nat -attributes: - - name: project_id - required: true - type: string - - name: lb_ip - required: true - type: string diff --git a/test/integration/multi-mig-http-lb/multi_mig_http_lb_test.go b/test/integration/multi-mig-http-lb/multi_mig_http_lb_test.go new file mode 100644 index 00000000..69d15b0c --- /dev/null +++ b/test/integration/multi-mig-http-lb/multi_mig_http_lb_test.go @@ -0,0 +1,45 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package multi_mig_http_lb_test + +import ( + "testing" + + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" + "github.com/stretchr/testify/assert" + + test "github.com/terraform-google-modules/terraform-google-lb-http/test/integration" +) + +func TestMultiMig(t *testing.T) { + bpt := tft.NewTFBlueprintTest(t) + + vars := map[string]interface{}{ + "network_prefix": "ci-lb-http-multi-mig-nat", + "project": bpt.GetTFSetupStringOutput("project_id"), + } + tft.WithVars(vars)(bpt) + + bpt.DefineVerify(func(assert *assert.Assertions) { + bpt.DefaultVerify(assert) + + loadBalancerIp := bpt.GetStringOutput("load-balancer-ip") + + // Get "http://34.149.217.1": EOF + test.AssertResponseStatus(t, assert, "http://"+loadBalancerIp, 200) + }) + + bpt.Test() +} diff --git a/test/integration/multi_certs/controls/https.rb b/test/integration/multi_certs/controls/https.rb deleted file mode 100644 index f021ed8b..00000000 --- a/test/integration/multi_certs/controls/https.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -control "https" do - title "HTTPs Check" - - describe http("https://#{attribute("lb_ip")}", - ssl_verify: false) do - its('status') { should eq 200 } - end -end diff --git a/test/integration/multi_certs/controls/https_asset.rb b/test/integration/multi_certs/controls/https_asset.rb deleted file mode 100644 index 33a0a8c1..00000000 --- a/test/integration/multi_certs/controls/https_asset.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -control "https_asset" do - title "HTTPs Check asset" - - describe http("#{attribute("asset_url")}", - ssl_verify: false) do - its('status') { should eq 200 } - end -end diff --git a/test/integration/multi_certs/controls/https_patterns.rb b/test/integration/multi_certs/controls/https_patterns.rb deleted file mode 100644 index 77d15ac1..00000000 --- a/test/integration/multi_certs/controls/https_patterns.rb +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -control "https_patterns" do - title "HTTPs Check region patterns" - - describe http("https://#{attribute("lb_ip")}/group1/", - ssl_verify: false) do - its('body') { should match /.*#{attribute("group1_region")}/ } - end - describe http("https://#{attribute("lb_ip")}/group2/", - ssl_verify: false) do - its('body') { should match /.*#{attribute("group2_region")}/ } - end - describe http("https://#{attribute("lb_ip")}/group3/", - ssl_verify: false) do - its('body') { should match /.*#{attribute("group3_region")}/ } - end -end diff --git a/test/integration/multi_certs/inspec.yml b/test/integration/multi_certs/inspec.yml deleted file mode 100644 index c5021537..00000000 --- a/test/integration/multi_certs/inspec.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: multi_certs -attributes: - - name: project_id - required: true - type: string - - name: lb_ip - required: true - type: string - - name: group1_region - required: true - type: string - - name: group2_region - required: true - type: string - - name: group3_region - required: true - type: string - - name: asset_url - required: true - type: string diff --git a/test/integration/multi_mig/controls/http.rb b/test/integration/multi_mig/controls/http.rb deleted file mode 100644 index c7f63b70..00000000 --- a/test/integration/multi_mig/controls/http.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -control "http" do - title "HTTP Check" - - describe http("http://#{attribute("lb_ip")}") do - its('status') { should eq 200 } - end -end diff --git a/test/integration/multi_mig/inspec.yml b/test/integration/multi_mig/inspec.yml deleted file mode 100644 index 60a57547..00000000 --- a/test/integration/multi_mig/inspec.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: multi_mig -attributes: - - name: project_id - required: true - type: string - - name: lb_ip - required: true - type: string diff --git a/test/integration/multiple-certs/multiple_certs_test.go b/test/integration/multiple-certs/multiple_certs_test.go new file mode 100644 index 00000000..39a93249 --- /dev/null +++ b/test/integration/multiple-certs/multiple_certs_test.go @@ -0,0 +1,67 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package multiple_certs_test + +import ( + "crypto/tls" + "net/http" + "testing" + + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" + "github.com/stretchr/testify/assert" + + test "github.com/terraform-google-modules/terraform-google-lb-http/test/integration" +) + +func TestMultipleCerts(t *testing.T) { + bpt := tft.NewTFBlueprintTest(t) + + vars := map[string]interface{}{ + "network_name": "ci-lb-http-multi-certs", + "project": bpt.GetTFSetupStringOutput("project_id"), + } + tft.WithVars(vars)(bpt) + + bpt.DefineVerify(func(assert *assert.Assertions) { + bpt.DefaultVerify(assert) + + loadBalancerURL := "https://" + bpt.GetStringOutput("load-balancer-ip") + + insecureClient := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}} + + // Check HTTPS + test.AssertResponseStatusWithClient(t, assert, insecureClient, loadBalancerURL, 200) + + // Check asset URL + test.AssertResponseStatusWithClient(t, assert, insecureClient, bpt.GetStringOutput("asset-url"), 200) + + { // Check region patterns + group1Region := bpt.GetStringOutput("group1_region") + group2Region := bpt.GetStringOutput("group2_region") + group3Region := bpt.GetStringOutput("group3_region") + + body1 := test.AssertResponseStatusWithClient(t, assert, insecureClient, loadBalancerURL+"/group1/", 200) + assert.Regexp(group1Region+"$", body1) + + body2 := test.AssertResponseStatusWithClient(t, assert, insecureClient, loadBalancerURL+"/group2/", 200) + assert.Regexp(group2Region+"$", body2) + + body3 := test.AssertResponseStatusWithClient(t, assert, insecureClient, loadBalancerURL+"/group3/", 200) + assert.Regexp(group3Region+"$", body3) + } + }) + + bpt.Test() +} diff --git a/test/integration/testhelper.go b/test/integration/testhelper.go index 66464aa1..de5eca53 100644 --- a/test/integration/testhelper.go +++ b/test/integration/testhelper.go @@ -22,15 +22,23 @@ import ( "github.com/stretchr/testify/assert" ) -func AssertResponseStatus(t *testing.T, assert *assert.Assertions, url string, statusCode int) { +func AssertResponseStatus(t *testing.T, assert *assert.Assertions, url string, statusCode int) (body string) { + return AssertResponseStatusWithClient(t, assert, nil, url, statusCode) +} + +func AssertResponseStatusWithClient(t *testing.T, assert *assert.Assertions, client *http.Client, url string, statusCode int) (body string) { + if client == nil { + client = &http.Client{} + } var resStatusCode int - resStatusCode, _, _ = httpGetRequest(t, url) + resStatusCode, body = httpGetRequest(t, client, url) assert.Equal(statusCode, resStatusCode) + return body } -func httpGetRequest(t *testing.T, url string) (statusCode int, body string, err error) { +func httpGetRequest(t *testing.T, client *http.Client, url string) (statusCode int, body string) { t.Helper() - res, err := http.Get(url) + res, err := client.Get(url) if err != nil { t.Fatalf("http get unexpected err: %v", err) } @@ -40,5 +48,5 @@ func httpGetRequest(t *testing.T, url string) (statusCode int, body string, err if err != nil { t.Fatalf("reading response body unexpected err: %v", err) } - return res.StatusCode, string(buffer), err + return res.StatusCode, string(buffer) }