forked from GoogleCloudPlatform/kms-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add apache and nginx integration test and outputs (GoogleCloudP…
- Loading branch information
1 parent
5133efd
commit bb99a9f
Showing
15 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
test/integration/oss-apache-web-server/apache_web_server_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package apache_web_server | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" | ||
"github.com/gruntwork-io/terratest/modules/shell" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFakeApacheWebServerModule(t *testing.T) { | ||
apacheT := tft.NewTFBlueprintTest(t) | ||
apacheT.DefineVerify(func(assert *assert.Assertions) { | ||
apacheT.DefaultVerify(assert) | ||
|
||
command := shell.Command{ | ||
Command: "gcloud", | ||
Args: []string{ | ||
"compute", | ||
"ssh", | ||
"--zone", | ||
"us-central1-a", | ||
fmt.Sprintf("username@%s", apacheT.GetStringOutput("vm_hostname")), | ||
"--tunnel-through-iap", | ||
"--project", | ||
apacheT.GetStringOutput("project_id"), | ||
"--impersonate-service-account", | ||
apacheT.GetStringOutput("service_account_email"), | ||
"--command", | ||
`curl -v --insecure https://127.0.0.1`, | ||
}, | ||
} | ||
|
||
op, err := shell.RunCommandAndGetOutputE(t, command) | ||
|
||
assert.Contains(op, "HTTP/1.1 200 OK", "Request must return 200") | ||
assert.Contains(op, "SSL certificate verify result: self-signed certificate", "SSL must be verified") | ||
assert.Nil(err) | ||
}) | ||
apacheT.Test() | ||
} |
58 changes: 58 additions & 0 deletions
58
test/integration/oss-nginx-ssl-offloading/ssl_offloading_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package nginx_ssl_offloading | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" | ||
"github.com/gruntwork-io/terratest/modules/shell" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNginxSslOffloadingModule(t *testing.T) { | ||
nginxT := tft.NewTFBlueprintTest(t) | ||
nginxT.DefineVerify(func(assert *assert.Assertions) { | ||
nginxT.DefaultVerify(assert) | ||
|
||
command := shell.Command{ | ||
Command: "gcloud", | ||
Args: []string{ | ||
"compute", | ||
"ssh", | ||
"--zone", | ||
"us-central1-a", | ||
fmt.Sprintf("username@%s", nginxT.GetStringOutput("vm_hostname")), | ||
"--tunnel-through-iap", | ||
"--project", | ||
nginxT.GetStringOutput("project_id"), | ||
"--impersonate-service-account", | ||
nginxT.GetStringOutput("service_account_email"), | ||
"--command", | ||
`openssl s_client -connect localhost:443 2>&1 <<< "GET /"`, | ||
}, | ||
} | ||
|
||
shell.RunCommandAndGetOutputE(t, command) // GET does not output in the first execution | ||
op, err := shell.RunCommandAndGetOutputE(t, command) | ||
|
||
assert.Contains(op, "Welcome to nginx!", "GET request failed") | ||
assert.Contains(op, "self-signed certificate", "SSL must be verified") | ||
assert.Contains(op, "SSL handshake has read", "SSL handshake failed") | ||
assert.Nil(err) | ||
}) | ||
nginxT.Test() | ||
} |