Skip to content
Open
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
4 changes: 3 additions & 1 deletion tests/utils/handler/cluster_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,9 @@ func (ch *clusterHandler) GenerateClusterCreateFlags() ([]string, error) {
log.Logger.Infof("Proxy auth is enabled. Going to generate the user and password and record in %s",
config.Test.ProxyAuthFile)
username := "proxyuser"
_, password := resourcesHandler.PrepareAdminUser()

// Remove all special characters, keep only alphanumeric characters
password := helper.GenerateRandomString(10)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and maintainability, it's better to define the password length as a constant instead of using a magic number 10.

Suggested change
password := helper.GenerateRandomString(10)
const proxyPasswordLength = 10
password := helper.GenerateRandomString(proxyPasswordLength)

Comment on lines +745 to +746

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change introduces a call to helper.GenerateRandomString, but this function does not appear to be defined in the tests/utils/helper package based on the files provided. This will cause a compilation error. Please ensure this function is defined and included in the pull request.

Additionally, the comment is slightly inaccurate. It says // Remove all special characters..., but the code is generating a new string, not modifying an existing one. A more accurate comment would be // Generate a password containing only alphanumeric characters..

Suggested change
// Remove all special characters, keep only alphanumeric characters
password := helper.GenerateRandomString(10)
// Generate a password containing only alphanumeric characters.
password := helper.GenerateRandomString(10)

_, err = helper.CreateFileWithContent(config.Test.ProxyAuthFile, fmt.Sprintf("%s:%s", username, password))
if err != nil {
return flags, err
Expand Down