From 9b0a848e0a238ffd33e42133f896436e0706b253 Mon Sep 17 00:00:00 2001 From: Jordan-Williams2 Date: Fri, 17 Jan 2025 15:31:18 +0000 Subject: [PATCH 1/4] fix: bug with password --- common-dev-assets | 2 +- solutions/standard/main.tf | 5 +---- tests/pr_test.go | 11 +++++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common-dev-assets b/common-dev-assets index 8a13c7bc..8dca3088 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit 8a13c7bc97e6e00b17615320a48fb89fe2a099f7 +Subproject commit 8dca308818240658cff0861789b251ad310afc78 diff --git a/solutions/standard/main.tf b/solutions/standard/main.tf index ab6c3ecb..ec5ad674 100644 --- a/solutions/standard/main.tf +++ b/solutions/standard/main.tf @@ -234,10 +234,7 @@ locals { # if - replace first char with J # elseif _ replace first char with K # else use asis - generated_admin_password = startswith(random_password.admin_password[0].result, "-") ? "J${substr(random_password.admin_password[0].result, 1, -1)}" : startswith(random_password.admin_password[0].result, "_") ? "K${substr(random_password.admin_password[0].result, 1, -1)}" : random_password.admin_password[0].result - - # admin password to use - admin_pass = var.admin_pass == null ? local.generated_admin_password : var.admin_pass + admin_pass = var.admin_pass == null ? (startswith(random_password.admin_password[0].result, "-") ? "J${substr(random_password.admin_password[0].result, 1, -1)}" : startswith(random_password.admin_password[0].result, "_") ? "K${substr(random_password.admin_password[0].result, 1, -1)}" : random_password.admin_password[0].result) : var.admin_pass } ####################################################################################################################### diff --git a/tests/pr_test.go b/tests/pr_test.go index 12640483..70075dde 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -2,12 +2,15 @@ package test import ( + "crypto/rand" + "encoding/base64" "log" "os" "testing" "github.com/gruntwork-io/terratest/modules/terraform" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo" "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common" "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper" @@ -148,6 +151,13 @@ func TestRunStandardSolutionIBMKeys(t *testing.T) { func TestRunStandardUpgradeSolution(t *testing.T) { t.Parallel() + // Generate a 15 char long random string for the admin_pass + randomBytes := make([]byte, 13) + _, randErr := rand.Read(randomBytes) + require.Nil(t, randErr) // do not proceed if we can't gen a random password + + randomPass := "A1" + base64.URLEncoding.EncodeToString(randomBytes)[:13] + options := testhelper.TestOptionsDefault(&testhelper.TestOptions{ Testing: t, TerraformDir: standardSolutionTerraformDir, @@ -161,6 +171,7 @@ func TestRunStandardUpgradeSolution(t *testing.T) { "kms_endpoint_type": "public", "provider_visibility": "public", "resource_group_name": options.Prefix, + "admin_pass": randomPass, } output, err := options.RunTestUpgrade() From 1d9a18445b76e90ab23b0fc94ca31cecbe5a4cbc Mon Sep 17 00:00:00 2001 From: Jordan-Williams2 Date: Fri, 17 Jan 2025 15:37:38 +0000 Subject: [PATCH 2/4] fix: bug with password --- common-dev-assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-dev-assets b/common-dev-assets index 8dca3088..279ef172 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit 8dca308818240658cff0861789b251ad310afc78 +Subproject commit 279ef17206e4b671a7c7c5ef442f032969fdb033 From 0587a2dc2215ec6f1791828b580b2d17df75edc8 Mon Sep 17 00:00:00 2001 From: Jordan-Williams2 Date: Sun, 19 Jan 2025 22:25:56 +0000 Subject: [PATCH 3/4] fix: submodule --- common-dev-assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-dev-assets b/common-dev-assets index 279ef172..8a13c7bc 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit 279ef17206e4b671a7c7c5ef442f032969fdb033 +Subproject commit 8a13c7bc97e6e00b17615320a48fb89fe2a099f7 From 277986c3bcc69569604867136ec60d7b84d0a393 Mon Sep 17 00:00:00 2001 From: Jordan-Williams2 Date: Sun, 19 Jan 2025 23:10:55 +0000 Subject: [PATCH 4/4] SKIP UPGRADE TEST --- tests/pr_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pr_test.go b/tests/pr_test.go index 70075dde..65c614d0 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -151,7 +151,7 @@ func TestRunStandardSolutionIBMKeys(t *testing.T) { func TestRunStandardUpgradeSolution(t *testing.T) { t.Parallel() - // Generate a 15 char long random string for the admin_pass + // Generate a 15 char long random string for the admin_pass. randomBytes := make([]byte, 13) _, randErr := rand.Read(randomBytes) require.Nil(t, randErr) // do not proceed if we can't gen a random password