|
| 1 | +// Copyright 2022-2024 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +package safer_cluster |
| 15 | + |
| 16 | +import ( |
| 17 | + "strings" |
| 18 | + "testing" |
| 19 | + "time" |
| 20 | + |
| 21 | + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/gcloud" |
| 22 | + "github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft" |
| 23 | + "github.com/stretchr/testify/assert" |
| 24 | + "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/testutils" |
| 25 | + gkeutils "github.com/terraform-google-modules/terraform-google-kubernetes-engine/test/integration/utils" |
| 26 | +) |
| 27 | + |
| 28 | +func TestSaferClusterIapBastion(t *testing.T) { |
| 29 | + bpt := tft.NewTFBlueprintTest(t, |
| 30 | + tft.WithRetryableTerraformErrors(testutils.RetryableTransientErrors, 3, 2*time.Minute), |
| 31 | + ) |
| 32 | + |
| 33 | + bpt.DefineVerify(func(assert *assert.Assertions) { |
| 34 | + //Skipping Default Verify as the Verify Stage fails due to change in Client Cert Token |
| 35 | + // bpt.DefaultVerify(assert) |
| 36 | + gkeutils.TGKEVerify(t, bpt, assert) // Verify Resources |
| 37 | + |
| 38 | + test_command, _ := strings.CutPrefix(bpt.GetStringOutput("test_command"), "gcloud ") |
| 39 | + cluster_version := bpt.GetStringOutput("cluster_version") |
| 40 | + |
| 41 | + op := gcloud.Runf(t, test_command) |
| 42 | + |
| 43 | + assert.Equal(cluster_version, op.Get("gitVersion").String(), "SSH into VM and verify connectivity to GKE") |
| 44 | + }) |
| 45 | + |
| 46 | + bpt.Test() |
| 47 | +} |
0 commit comments