Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func TestRunStandardSolutionSchematics(t *testing.T) {
{Name: "existing_secrets_manager_instance_crn", Value: permanentResources["secretsManagerCRN"], DataType: "string"},
{Name: "service_credential_secrets", Value: serviceCredentialSecrets, DataType: "list(object)"},
{Name: "service_credential_names", Value: string(serviceCredentialNamesJSON), DataType: "map(string)"},
{Name: "admin_pass", Value: GetRandomAdminPassword(t), DataType: "string"},
}
err = options.RunSchematicTest()
assert.Nil(t, err, "This should not have errored")
Expand All @@ -173,15 +174,6 @@ func TestRunStandardSolutionSchematics(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)
_, err := rand.Read(randomBytes)
if err != nil {
log.Fatal(err)
}
// add character prefix to avoid generated password beginning with special char and must have a number
randomPass := "A1" + base64.URLEncoding.EncodeToString(randomBytes)[:13]

options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
Testing: t,
TerraformDir: standardSolutionTerraformDir,
Expand All @@ -196,7 +188,6 @@ func TestRunStandardUpgradeSolution(t *testing.T) {
"kms_endpoint_type": "public",
"provider_visibility": "public",
"resource_group_name": options.Prefix,
"admin_pass": randomPass,
}

output, err := options.RunTestUpgrade()
Expand All @@ -205,3 +196,12 @@ func TestRunStandardUpgradeSolution(t *testing.T) {
assert.NotNil(t, output, "Expected some output")
}
}

func GetRandomAdminPassword(t *testing.T) string {
// 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]
return randomPass
}