-
Notifications
You must be signed in to change notification settings - Fork 22
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
OCM-13040 | test: Bastion proxy support username and password #81
base: main
Are you sure you want to change the base?
Conversation
b976ed6
to
0eef957
Compare
0eef957
to
91c5622
Compare
pkg/test/vpc_client/bastion.go
Outdated
systemctl start squid | ||
systemctl enable squid`, cidrBlock) | ||
username := utils.RandomLabel(5) | ||
password := utils.RandomLabel(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a try to see if there is another function can generate password with special characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not find a function which can generate password with special characters, create a new fun named GeneratePassword() to implement it.
pkg/test/vpc_client/bastion.go
Outdated
username := utils.RandomLabel(5) | ||
password := utils.RandomLabel(10) | ||
|
||
hashedPassword, err := generateBcryptPassword(password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a generate username and password function. The function is too huge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, create a new func generateWriteSquidPasswordFileCommand() to generate username/password, and put them into squid's password file.
pkg/test/vpc_client/bastion.go
Outdated
encodeUserData := base64.StdEncoding.EncodeToString([]byte(userData)) | ||
return vpc.LaunchBastion("", zone, encodeUserData, keypairName, privateKeyPath) | ||
line := fmt.Sprintf("%s:%s\n", username, hashedPassword) | ||
remoteFilePath := "/etc/squid/passwords" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't hardcode here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, create a const SquidPasswordFilePath.
pkg/test/vpc_client/bastion.go
Outdated
return vpc.LaunchBastion("", zone, encodeUserData, keypairName, privateKeyPath) | ||
line := fmt.Sprintf("%s:%s\n", username, hashedPassword) | ||
remoteFilePath := "/etc/squid/passwords" | ||
hostName := fmt.Sprintf("%s:22", *instance.PublicIpAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't make it hardcode here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, create a const SSHPort
pkg/test/vpc_client/bastion.go
Outdated
line := fmt.Sprintf("%s:%s\n", username, hashedPassword) | ||
remoteFilePath := "/etc/squid/passwords" | ||
hostName := fmt.Sprintf("%s:22", *instance.PublicIpAddress) | ||
createFileCMD := fmt.Sprintf("sudo touch %s", remoteFilePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generate a new function for the username/password written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, create a new func named generateWriteSquidPasswordFileCommand() to generate username and password.
pkg/test/vpc_client/bastion.go
Outdated
createFileCMD, | ||
copyPasswordCMD, | ||
} | ||
privateKeyName := fmt.Sprintf("%s-%s", path.Join(privateKeyPath, keypairName), "keyPair.pem") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the keypath to a common function. Otherwise I have to maintain too many places and it will cause unexpected error during running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, create a new func GetPrivateKeyName() in aws utils.
pkg/test/vpc_client/bastion.go
Outdated
log.LogInfo("Found existing bastion: %s", *insts[0].InstanceId) | ||
return &insts[0], nil | ||
|
||
proxyUrl = fmt.Sprintf("http://%s:%s@%s:3128", username, password, *instance.PublicIpAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
net/url related packages to use an official function for the url generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, using net/url construct proxy url.
Put more logs to the code blocks. |
91c5622
to
78c2c53
Compare
Updated, add info log and error log in related functions. |
78c2c53
to
5604e86
Compare
5604e86
to
56dbd0d
Compare
No description provided.