2018-09-24 22:35:43 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// This file is automatically generated by Magic Modules and manual
|
|
|
|
// changes will be clobbered when the file is regenerated.
|
|
|
|
//
|
|
|
|
// Please read more about how to change this file in
|
|
|
|
// .github/CONTRIBUTING.md.
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
2018-10-26 18:03:43 +00:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2018-09-24 22:35:43 +00:00
|
|
|
)
|
|
|
|
|
2018-11-09 21:02:03 +00:00
|
|
|
func TestAccComputeSslPolicy_sslPolicyBasicExample(t *testing.T) {
|
2018-09-24 22:35:43 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckComputeSslPolicyDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
{
|
2018-11-09 21:02:03 +00:00
|
|
|
Config: testAccComputeSslPolicy_sslPolicyBasicExample(acctest.RandString(10)),
|
2018-09-24 22:35:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
ResourceName: "google_compute_ssl_policy.prod-ssl-policy",
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-11-09 21:02:03 +00:00
|
|
|
func testAccComputeSslPolicy_sslPolicyBasicExample(val string) string {
|
2018-09-24 22:35:43 +00:00
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_compute_ssl_policy" "prod-ssl-policy" {
|
|
|
|
name = "production-ssl-policy-%s"
|
|
|
|
profile = "MODERN"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_ssl_policy" "nonprod-ssl-policy" {
|
|
|
|
name = "nonprod-ssl-policy-%s"
|
|
|
|
profile = "MODERN"
|
|
|
|
min_tls_version = "TLS_1_2"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_ssl_policy" "custom-ssl-policy" {
|
|
|
|
name = "custom-ssl-policy-%s"
|
|
|
|
min_tls_version = "TLS_1_2"
|
|
|
|
profile = "CUSTOM"
|
|
|
|
custom_features = ["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"]
|
|
|
|
}
|
|
|
|
`, val, val, val,
|
|
|
|
)
|
|
|
|
}
|
2018-10-26 18:03:43 +00:00
|
|
|
|
|
|
|
func testAccCheckComputeSslPolicyDestroy(s *terraform.State) error {
|
|
|
|
for _, rs := range s.RootModule().Resources {
|
|
|
|
if rs.Type != "google_compute_ssl_policy" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
config := testAccProvider.Meta().(*Config)
|
|
|
|
|
|
|
|
url, err := replaceVarsForTest(rs, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/sslPolicies/{{name}}")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = sendRequest(config, "GET", url, nil)
|
|
|
|
if err == nil {
|
|
|
|
return fmt.Errorf("ComputeSslPolicy still exists at %s", url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|