mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
![Nick Jacques](/assets/img/avatar_default.png)
* Add SSL Policy to provider * Add resource for SSL Policy * Add SSL Policy data source * Add tests for SSL Policy resource * Add documentation for SSL Policy resource * Add SSL Policy datasource docs * Add test for SSL Policy datasource * Update SSL Policy datasource docs * Make full update for SSL Policy resource * SSL Policy resource test multi-attrib update * Clean up SSL Policy datasource * Set-ify custom_features in SSL Policy resource * Document description ForceNew rationale * Remove refs to TLS_1_3 * Update docs: plural -> singular * Remove extraneous attrs from datasource * Fix update logic for custom_features and add enabled_features * Update docs to include enabled_features * Add test for updating to/from custom_features * Add TLS 1.3 bug link * Add import between multi-step test configs * Move Profile and minTlsVersion back into sslPolicy struct
84 lines
1.9 KiB
Go
84 lines
1.9 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
func TestAccDataSourceGoogleSslPolicy(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccDataSourceGoogleSslPolicy(),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
testAccDataSourceGoogleSslPolicyCheck("data.google_compute_ssl_policy.ssl_policy", "google_compute_ssl_policy.foobar"),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccDataSourceGoogleSslPolicyCheck(data_source_name string, resource_name string) resource.TestCheckFunc {
|
|
return func(s *terraform.State) error {
|
|
ds, ok := s.RootModule().Resources[data_source_name]
|
|
if !ok {
|
|
return fmt.Errorf("root module has no resource called %s", data_source_name)
|
|
}
|
|
|
|
rs, ok := s.RootModule().Resources[resource_name]
|
|
if !ok {
|
|
return fmt.Errorf("can't find %s in state", resource_name)
|
|
}
|
|
|
|
ds_attr := ds.Primary.Attributes
|
|
rs_attr := rs.Primary.Attributes
|
|
|
|
ssl_policy_attrs_to_test := []string{
|
|
"id",
|
|
"self_link",
|
|
"name",
|
|
"description",
|
|
"min_tls_version",
|
|
"profile",
|
|
"custom_features",
|
|
}
|
|
|
|
for _, attr_to_check := range ssl_policy_attrs_to_test {
|
|
if ds_attr[attr_to_check] != rs_attr[attr_to_check] {
|
|
return fmt.Errorf(
|
|
"%s is %s; want %s",
|
|
attr_to_check,
|
|
ds_attr[attr_to_check],
|
|
rs_attr[attr_to_check],
|
|
)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func testAccDataSourceGoogleSslPolicy() string {
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_compute_ssl_policy" "foobar" {
|
|
name = "%s"
|
|
description = "my-description"
|
|
min_tls_version = "TLS_1_2"
|
|
profile = "MODERN"
|
|
}
|
|
|
|
data "google_compute_ssl_policy" "ssl_policy" {
|
|
name = "${google_compute_ssl_policy.foobar.name}"
|
|
}
|
|
`, acctest.RandomWithPrefix("test-ssl-policy"))
|
|
}
|