Skip to content

Commit

Permalink
Fix certificate_manager_dns_authorization examples to use sweepable n…
Browse files Browse the repository at this point in the history
…ames (#7510)

* Fix certificate_manager_dns_authorization examples to use sweepable names

* Update other resource in proxy tests to be sweepable

* Fix test checks
  • Loading branch information
roaks3 authored Mar 22, 2023
1 parent 0ed7de8 commit c59cbca
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccComputeTargetHttpsProxy_update(t *testing.T) {
testAccCheckComputeTargetHttpsProxyExists(
t, "google_compute_target_https_proxy.foobar", &proxy),
testAccComputeTargetHttpsProxyDescription("Resource created for Terraform acceptance testing", &proxy),
testAccComputeTargetHttpsProxyHasSslCertificate(t, "httpsproxy-test-cert1-"+resourceSuffix, &proxy),
testAccComputeTargetHttpsProxyHasSslCertificate(t, "tf-test-httpsproxy-cert1-"+resourceSuffix, &proxy),
),
},

Expand All @@ -46,8 +46,8 @@ func TestAccComputeTargetHttpsProxy_update(t *testing.T) {
testAccCheckComputeTargetHttpsProxyExists(
t, "google_compute_target_https_proxy.foobar", &proxy),
testAccComputeTargetHttpsProxyDescription("Resource created for Terraform acceptance testing", &proxy),
testAccComputeTargetHttpsProxyHasSslCertificate(t, "httpsproxy-test-cert1-"+resourceSuffix, &proxy),
testAccComputeTargetHttpsProxyHasSslCertificate(t, "httpsproxy-test-cert2-"+resourceSuffix, &proxy),
testAccComputeTargetHttpsProxyHasSslCertificate(t, "tf-test-httpsproxy-cert1-"+resourceSuffix, &proxy),
testAccComputeTargetHttpsProxyHasSslCertificate(t, "tf-test-httpsproxy-cert2-"+resourceSuffix, &proxy),
),
},
},
Expand All @@ -71,7 +71,7 @@ func TestAccComputeTargetHttpsProxy_certificateMap(t *testing.T) {
testAccCheckComputeTargetHttpsProxyExists(
t, "google_compute_target_https_proxy.foobar", &proxy),
testAccComputeTargetHttpsProxyDescription("Resource created for Terraform acceptance testing", &proxy),
testAccComputeTargetHttpsProxyHasCertificateMap(t, "certificatemap-test-"+resourceSuffix, &proxy),
testAccComputeTargetHttpsProxyHasCertificateMap(t, "tf-test-certmap-"+resourceSuffix, &proxy),
),
},
},
Expand Down Expand Up @@ -149,26 +149,26 @@ func testAccComputeTargetHttpsProxy_basic1(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_https_proxy" "foobar" {
description = "Resource created for Terraform acceptance testing"
name = "httpsproxy-test-%s"
name = "tf-test-httpsproxy-%s"
url_map = google_compute_url_map.foobar.self_link
ssl_certificates = [google_compute_ssl_certificate.foobar1.self_link]
ssl_policy = google_compute_ssl_policy.foobar.self_link
}

resource "google_compute_backend_service" "foobar" {
name = "httpsproxy-test-backend-%s"
name = "tf-test-httpsproxy-backend-%s"
health_checks = [google_compute_http_health_check.zero.self_link]
}

resource "google_compute_http_health_check" "zero" {
name = "httpsproxy-test-health-check-%s"
name = "tf-test-httpsproxy-check-%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}

resource "google_compute_url_map" "foobar" {
name = "httpsproxy-test-url-map-%s"
name = "tf-test-httpsproxy-urlmap-%s"
default_service = google_compute_backend_service.foobar.self_link
host_rule {
hosts = ["mysite.com", "myothersite.com"]
Expand All @@ -190,21 +190,21 @@ resource "google_compute_url_map" "foobar" {
}

resource "google_compute_ssl_policy" "foobar" {
name = "sslproxy-test-%s"
name = "tf-test-sslproxy-%s"
description = "my-description"
min_tls_version = "TLS_1_2"
profile = "MODERN"
}

resource "google_compute_ssl_certificate" "foobar1" {
name = "httpsproxy-test-cert1-%s"
name = "tf-test-httpsproxy-cert1-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
}

resource "google_compute_ssl_certificate" "foobar2" {
name = "httpsproxy-test-cert2-%s"
name = "tf-test-httpsproxy-cert2-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
Expand All @@ -216,7 +216,7 @@ func testAccComputeTargetHttpsProxy_basic2(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_https_proxy" "foobar" {
description = "Resource created for Terraform acceptance testing"
name = "httpsproxy-test-%s"
name = "tf-test-httpsproxy-%s"
url_map = google_compute_url_map.foobar.self_link
ssl_certificates = [
google_compute_ssl_certificate.foobar1.self_link,
Expand All @@ -226,19 +226,19 @@ resource "google_compute_target_https_proxy" "foobar" {
}

resource "google_compute_backend_service" "foobar" {
name = "httpsproxy-test-backend-%s"
name = "tf-test-httpsproxy-backend-%s"
health_checks = [google_compute_http_health_check.zero.self_link]
}

resource "google_compute_http_health_check" "zero" {
name = "httpsproxy-test-health-check-%s"
name = "tf-test-httpsproxy-check-%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}

resource "google_compute_url_map" "foobar" {
name = "httpsproxy-test-url-map-%s"
name = "tf-test-httpsproxy-urlmap-%s"
default_service = google_compute_backend_service.foobar.self_link
host_rule {
hosts = ["mysite.com", "myothersite.com"]
Expand All @@ -260,21 +260,21 @@ resource "google_compute_url_map" "foobar" {
}

resource "google_compute_ssl_policy" "foobar" {
name = "sslproxy-test-%s"
name = "tf-test-sslproxy-%s"
description = "my-description"
min_tls_version = "TLS_1_2"
profile = "MODERN"
}

resource "google_compute_ssl_certificate" "foobar1" {
name = "httpsproxy-test-cert1-%s"
name = "tf-test-httpsproxy-cert1-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
}

resource "google_compute_ssl_certificate" "foobar2" {
name = "httpsproxy-test-cert2-%s"
name = "tf-test-httpsproxy-cert2-%s"
description = "very descriptive"
private_key = file("test-fixtures/ssl_cert/test.key")
certificate = file("test-fixtures/ssl_cert/test.crt")
Expand All @@ -286,41 +286,41 @@ func testAccComputeTargetHttpsProxy_certificateMap(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_https_proxy" "foobar" {
description = "Resource created for Terraform acceptance testing"
name = "httpsproxy-test-%s"
name = "tf-test-httpsproxy-%s"
url_map = google_compute_url_map.foobar.self_link
certificate_map = "//certificatemanager.googleapis.com/${google_certificate_manager_certificate_map.map.id}"
}

resource "google_compute_backend_service" "foobar" {
name = "httpsproxy-test-backend-%s"
name = "tf-test-httpsproxy-backend-%s"
health_checks = [google_compute_http_health_check.zero.self_link]
}

resource "google_compute_http_health_check" "zero" {
name = "httpsproxy-test-health-check-%s"
name = "tf-test-httpsproxy-check-%s"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}

resource "google_compute_url_map" "foobar" {
name = "httpsproxy-test-url-map-%s"
name = "tf-test-httpsproxy-urlmap-%s"
default_service = google_compute_backend_service.foobar.self_link
}

resource "google_certificate_manager_certificate_map" "map" {
name = "certificatemap-test-%s"
name = "tf-test-certmap-%s"
}

resource "google_certificate_manager_certificate_map_entry" "map_entry" {
name = "certificatemapentry-test-%s"
name = "tf-test-certmapentry-%s"
map = google_certificate_manager_certificate_map.map.name
certificates = [google_certificate_manager_certificate.certificate.id]
matcher = "PRIMARY"
}

resource "google_certificate_manager_certificate" "certificate" {
name = "certificate-test-%s"
name = "tf-test-cert-%s"
scope = "DEFAULT"
managed {
domains = [
Expand All @@ -333,7 +333,7 @@ resource "google_certificate_manager_certificate" "certificate" {
}

resource "google_certificate_manager_dns_authorization" "instance" {
name = "dnsauthorization-test-%s"
name = "tf-test-dnsauthz-%s"
domain = "mysite.com"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
)

func TestAccComputeTargetSslProxy_update(t *testing.T) {
target := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
sslPolicy := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
cert1 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
cert2 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
backend1 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
backend2 := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
hc := fmt.Sprintf("tssl-test-%s", RandString(t, 10))
target := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
sslPolicy := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
cert1 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
cert2 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
backend1 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
backend2 := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))
hc := fmt.Sprintf("tf-test-tssl-%s", RandString(t, 10))

resourceSuffix := RandString(t, 10)
var proxy compute.TargetSslProxy
Expand Down Expand Up @@ -55,15 +55,15 @@ func TestAccComputeTargetSslProxy_update(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeTargetSslProxyExists(
t, "google_compute_target_ssl_proxy.with_certificate_map", &proxy),
testAccCheckComputeTargetSslProxyHasCertificateMap(t, "certificatemap-test-1-"+resourceSuffix, &proxy),
testAccCheckComputeTargetSslProxyHasCertificateMap(t, "tf-test-certmap-1-"+resourceSuffix, &proxy),
),
},
{
Config: testAccComputeTargetSslProxy_certificateMap2(resourceSuffix),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeTargetSslProxyExists(
t, "google_compute_target_ssl_proxy.with_certificate_map", &proxy),
testAccCheckComputeTargetSslProxyHasCertificateMap(t, "certificatemap-test-2-"+resourceSuffix, &proxy),
testAccCheckComputeTargetSslProxyHasCertificateMap(t, "tf-test-certmap-2-"+resourceSuffix, &proxy),
),
},
},
Expand Down Expand Up @@ -233,19 +233,19 @@ func testAccComputeTargetSslProxy_certificateMap1(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_ssl_proxy" "with_certificate_map" {
description = "Resource created for Terraform acceptance testing"
name = "ssl-proxy-%s"
name = "tf-test-ssl-proxy-%s"
backend_service = google_compute_backend_service.foo.self_link
certificate_map = "//certificatemanager.googleapis.com/${google_certificate_manager_certificate_map.map1.id}"
}

resource "google_compute_backend_service" "foo" {
name = "backend-service-%s"
name = "tf-test-backend-%s"
protocol = "SSL"
health_checks = [google_compute_health_check.zero.self_link]
}

resource "google_compute_health_check" "zero" {
name = "health-check-%s"
name = "tf-test-check-%s"
check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
Expand All @@ -254,17 +254,17 @@ resource "google_compute_health_check" "zero" {
}

resource "google_certificate_manager_certificate_map" "map1" {
name = "certificatemap-test-1-%s"
name = "tf-test-certmap-1-%s"
}
resource "google_certificate_manager_certificate_map_entry" "map_entry" {
name = "certificatemapentry-test-%s"
name = "tf-test-certmapentry-%s"
map = google_certificate_manager_certificate_map.map1.name
certificates = [google_certificate_manager_certificate.certificate.id]
matcher = "PRIMARY"
}

resource "google_certificate_manager_certificate" "certificate" {
name = "certificate-test-%s"
name = "tf-test-cert-%s"
scope = "DEFAULT"
managed {
domains = [
Expand All @@ -277,7 +277,7 @@ resource "google_certificate_manager_certificate" "certificate" {
}

resource "google_certificate_manager_dns_authorization" "instance" {
name = "dnsauthorization-test-%s"
name = "tf-test-dnsauthz-%s"
domain = "mysite.com"
}
`, id, id, id, id, id, id, id)
Expand All @@ -287,19 +287,19 @@ func testAccComputeTargetSslProxy_certificateMap2(id string) string {
return fmt.Sprintf(`
resource "google_compute_target_ssl_proxy" "with_certificate_map" {
description = "Resource created for Terraform acceptance testing"
name = "ssl-proxy-%s"
name = "tf-test-ssl-proxy-%s"
backend_service = google_compute_backend_service.foo.self_link
certificate_map = "//certificatemanager.googleapis.com/${google_certificate_manager_certificate_map.map2.id}"
}

resource "google_compute_backend_service" "foo" {
name = "backend-service-%s"
name = "tf-test-backend-%s"
protocol = "SSL"
health_checks = [google_compute_health_check.zero.self_link]
}

resource "google_compute_health_check" "zero" {
name = "health-check-%s"
name = "tf-test-check-%s"
check_interval_sec = 1
timeout_sec = 1
tcp_health_check {
Expand All @@ -308,22 +308,22 @@ resource "google_compute_health_check" "zero" {
}

resource "google_certificate_manager_certificate_map" "map1" {
name = "certificatemap-test-1-%s"
name = "tf-test-certmap-1-%s"
}

resource "google_certificate_manager_certificate_map" "map2" {
name = "certificatemap-test-2-%s"
name = "tf-test-certmap-2-%s"
}

resource "google_certificate_manager_certificate_map_entry" "map_entry" {
name = "certificatemapentry-test-%s"
name = "tf-test-certmapentry-%s"
map = google_certificate_manager_certificate_map.map1.name
certificates = [google_certificate_manager_certificate.certificate.id]
matcher = "PRIMARY"
}

resource "google_certificate_manager_certificate" "certificate" {
name = "certificate-test-%s"
name = "tf-test-cert-%s"
scope = "DEFAULT"
managed {
domains = [
Expand All @@ -336,7 +336,7 @@ resource "google_certificate_manager_certificate" "certificate" {
}

resource "google_certificate_manager_dns_authorization" "instance" {
name = "dnsauthorization-test-%s"
name = "tf-test-dnsauthz-%s"
domain = "mysite.com"
}
`, id, id, id, id, id, id, id, id)
Expand Down

0 comments on commit c59cbca

Please sign in to comment.