-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new resource google_compute_target_ssl_proxy #569
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
"github.com/hashicorp/terraform/terraform" | ||
"reflect" | ||
) | ||
|
||
func TestAccComputeTargetSslProxy_basic(t *testing.T) { | ||
|
@@ -23,8 +24,8 @@ func TestAccComputeTargetSslProxy_basic(t *testing.T) { | |
resource.TestStep{ | ||
Config: testAccComputeTargetSslProxy_basic1(target, cert, backend, hc), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckComputeTargetSslProxyExists( | ||
"google_compute_target_ssl_proxy.foobar"), | ||
testAccCheckComputeTargetSslProxy( | ||
"google_compute_target_ssl_proxy.foobar", "NONE", []string{cert}), | ||
), | ||
}, | ||
}, | ||
|
@@ -47,15 +48,15 @@ func TestAccComputeTargetSslProxy_update(t *testing.T) { | |
resource.TestStep{ | ||
Config: testAccComputeTargetSslProxy_basic1(target, cert1, backend1, hc), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckComputeTargetSslProxyExists( | ||
"google_compute_target_ssl_proxy.foobar"), | ||
testAccCheckComputeTargetSslProxy( | ||
"google_compute_target_ssl_proxy.foobar", "NONE", []string{cert1}), | ||
), | ||
}, | ||
resource.TestStep{ | ||
Config: testAccComputeTargetSslProxy_basic2(target, cert1, cert2, backend1, backend2, hc), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckComputeTargetSslProxyExists( | ||
"google_compute_target_ssl_proxy.foobar"), | ||
testAccCheckComputeTargetSslProxy( | ||
"google_compute_target_ssl_proxy.foobar", "PROXY_V1", []string{cert1, cert2}), | ||
), | ||
}, | ||
}, | ||
|
@@ -80,7 +81,7 @@ func testAccCheckComputeTargetSslProxyDestroy(s *terraform.State) error { | |
return nil | ||
} | ||
|
||
func testAccCheckComputeTargetSslProxyExists(n string) resource.TestCheckFunc { | ||
func testAccCheckComputeTargetSslProxy(n, proxyHeader string, sslCerts []string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
if !ok { | ||
|
@@ -103,6 +104,19 @@ func testAccCheckComputeTargetSslProxyExists(n string) resource.TestCheckFunc { | |
return fmt.Errorf("TargetSslProxy not found") | ||
} | ||
|
||
if found.ProxyHeader != proxyHeader { | ||
return fmt.Errorf("Wrong proxy header. Expected '%s', got '%s'", proxyHeader, found.ProxyHeader) | ||
} | ||
|
||
foundCertsName := make([]string, 0, len(found.SslCertificates)) | ||
for _, foundCert := range found.SslCertificates { | ||
foundCertsName = append(foundCertsName, GetResourceNameFromSelfLink(foundCert)) | ||
} | ||
|
||
if !reflect.DeepEqual(foundCertsName, sslCerts) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does order matter? If it doesn't, you might consider sorting or something before doing the deepEqual There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, after waiting for the full test run to finish and reading the API docs, one and only one certificate must be specified at this time (they might support more in the future). So I added a From the docs: |
||
return fmt.Errorf("Wrong ssl certificates. Expected '%s', got '%s'", sslCerts, found.SslCertificates) | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to do more testing here (e.g. that the stored parameters match the set parameters)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done