Skip to content

chore: update the format of random password #4445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion huaweicloud/services/acceptance/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ func RandomCidrAndGatewayIp() (string, string) {
return fmt.Sprintf("172.16.%d.0/24", seed), fmt.Sprintf("172.16.%d.1", seed)
}

// RandomPassword can generate a 12-character random password. The password format is
// uppercase letters*3 + lowercase letters*3 + special characters*2 + numbers*4
// You can use "customChars" to overwrite the special characters.
func RandomPassword(customChars ...string) string {
var specialChars string
if len(customChars) < 1 {
Expand All @@ -533,7 +536,7 @@ func RandomPassword(customChars ...string) string {
specialChars = customChars[0]
}
return fmt.Sprintf("%s%s%s%d",
acctest.RandStringFromCharSet(2, "ABCDEFGHIJKLMNOPQRSTUVWXZY"),
acctest.RandStringFromCharSet(3, "ABCDEFGHIJKLMNOPQRSTUVWXZY"),
acctest.RandStringFromCharSet(3, acctest.CharSetAlpha),
acctest.RandStringFromCharSet(2, specialChars),
acctest.RandIntRange(1000, 9999))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func TestAccDisasterRecoveryTasksDataSource_basic(t *testing.T) {
resourceName := "data.huaweicloud_dws_disaster_recovery_tasks.name_filter"
dc := acceptance.InitDataSourceCheck(resourceName)
name := acceptance.RandomAccResourceName()
// The cluster password requires a minimum length of 12 characters, and the string 'gap' is used to fill in the gap.
password := acceptance.RandomPassword() + "gap"
password := acceptance.RandomPassword()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheck(t) },
ProviderFactories: acceptance.TestAccProviderFactories,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestAccResourceDisasterRecoveryTask_basic(t *testing.T) {
obj interface{}
resourceName = "huaweicloud_dws_disaster_recovery_task.test"
name = acceptance.RandomAccResourceName()
password = acceptance.RandomPassword() + "a"
password = acceptance.RandomPassword()
)
rc := acceptance.InitResourceCheck(
resourceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ resource "huaweicloud_dws_cluster" "test" {

func testAccWorkLoadPlan_basic(name string) string {
password := acceptance.RandomPassword("@#%&_=!")
password += "123"

return fmt.Sprintf(`
%s
Expand Down
Loading