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) (#14070)

* Fix certificate_manager_dns_authorization examples to use sweepable names

* Update other resource in proxy tests to be sweepable

* Fix test checks

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Mar 22, 2023
1 parent 59f7e9b commit efcff70
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 50 deletions.
3 changes: 3 additions & 0 deletions .changelog/7510.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
52 changes: 26 additions & 26 deletions google/resource_compute_target_https_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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 @@ -41,8 +41,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 @@ -66,7 +66,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 @@ -144,26 +144,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 @@ -185,21 +185,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 @@ -211,7 +211,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 @@ -221,19 +221,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 @@ -255,21 +255,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 @@ -281,41 +281,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 @@ -328,7 +328,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
48 changes: 24 additions & 24 deletions google/resource_compute_target_ssl_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,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 @@ -50,15 +50,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 @@ -228,19 +228,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 @@ -249,17 +249,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 @@ -272,7 +272,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 @@ -282,19 +282,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 @@ -303,22 +303,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 @@ -331,7 +331,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 efcff70

Please sign in to comment.