Skip to content

Commit 6c5820f

Browse files
jor2Jordan-Williams2
andauthored
test: use schematics for admin pass (#477)
Co-authored-by: Jordan-Williams2 <[email protected]>
1 parent 8396201 commit 6c5820f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/pr_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func TestRunStandardSolutionSchematics(t *testing.T) {
165165
{Name: "existing_secrets_manager_instance_crn", Value: permanentResources["secretsManagerCRN"], DataType: "string"},
166166
{Name: "service_credential_secrets", Value: serviceCredentialSecrets, DataType: "list(object)"},
167167
{Name: "service_credential_names", Value: string(serviceCredentialNamesJSON), DataType: "map(string)"},
168+
{Name: "admin_pass", Value: GetRandomAdminPassword(t), DataType: "string"},
168169
}
169170
err = options.RunSchematicTest()
170171
assert.Nil(t, err, "This should not have errored")
@@ -173,13 +174,6 @@ func TestRunStandardSolutionSchematics(t *testing.T) {
173174
func TestRunStandardUpgradeSolution(t *testing.T) {
174175
t.Parallel()
175176

176-
// Generate a 15 char long random string for the admin_pass.
177-
randomBytes := make([]byte, 13)
178-
_, randErr := rand.Read(randomBytes)
179-
require.Nil(t, randErr) // do not proceed if we can't gen a random password
180-
181-
randomPass := "A1" + base64.URLEncoding.EncodeToString(randomBytes)[:13]
182-
183177
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
184178
Testing: t,
185179
TerraformDir: standardSolutionTerraformDir,
@@ -194,7 +188,6 @@ func TestRunStandardUpgradeSolution(t *testing.T) {
194188
"kms_endpoint_type": "public",
195189
"provider_visibility": "public",
196190
"resource_group_name": options.Prefix,
197-
"admin_pass": randomPass,
198191
}
199192

200193
output, err := options.RunTestUpgrade()
@@ -241,3 +234,12 @@ func TestRunCompleteUpgradeExample(t *testing.T) {
241234
assert.NotNil(t, output, "Expected some output")
242235
}
243236
}
237+
238+
func GetRandomAdminPassword(t *testing.T) string {
239+
// Generate a 15 char long random string for the admin_pass
240+
randomBytes := make([]byte, 13)
241+
_, randErr := rand.Read(randomBytes)
242+
require.Nil(t, randErr) // do not proceed if we can't gen a random password
243+
randomPass := "A1" + base64.URLEncoding.EncodeToString(randomBytes)[:13]
244+
return randomPass
245+
}

0 commit comments

Comments
 (0)