mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-05-09 18:23:21 +08:00
refactor: migrate TestSudoCommand to key-based authentication
- Disable password authentication by setting PASSWORD_ACCESS to false in TestSudoCommand - Remove the use of direct password authentication in favor of key-based authentication in TestSudoCommand Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
parent
ff79cee470
commit
0d02cbb190
@ -930,8 +930,8 @@ func TestSudoCommand(t *testing.T) {
|
|||||||
Env: map[string]string{
|
Env: map[string]string{
|
||||||
"USER_NAME": "testuser",
|
"USER_NAME": "testuser",
|
||||||
"USER_PASSWORD": "testpass",
|
"USER_PASSWORD": "testpass",
|
||||||
"PASSWORD_ACCESS": "true", // Enable password authentication
|
"PASSWORD_ACCESS": "false", // Enable password authentication
|
||||||
"SUDO_ACCESS": "true", // Optional: grant sudo access
|
"SUDO_ACCESS": "true", // Optional: grant sudo access
|
||||||
"PUBLIC_KEY": string(pubKey),
|
"PUBLIC_KEY": string(pubKey),
|
||||||
},
|
},
|
||||||
// Wait for the SSH port (2222) to be listening
|
// Wait for the SSH port (2222) to be listening
|
||||||
@ -976,7 +976,6 @@ func TestSudoCommand(t *testing.T) {
|
|||||||
Host: []string{host},
|
Host: []string{host},
|
||||||
Username: "testuser", // Use the configured username
|
Username: "testuser", // Use the configured username
|
||||||
Port: port.Int(), // Use the mapped port
|
Port: port.Int(), // Use the mapped port
|
||||||
Password: "testpass", // Use the configured password
|
|
||||||
KeyPath: "./tests/.ssh/id_rsa",
|
KeyPath: "./tests/.ssh/id_rsa",
|
||||||
Script: []string{
|
Script: []string{
|
||||||
`sudo su - -c "whoami"`,
|
`sudo su - -c "whoami"`,
|
||||||
|
Loading…
Reference in New Issue
Block a user