From 0d02cbb190e0c7c00983b32ff8b1ab3687de91b0 Mon Sep 17 00:00:00 2001 From: appleboy Date: Sun, 27 Apr 2025 09:24:52 +0800 Subject: [PATCH] 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 --- plugin_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin_test.go b/plugin_test.go index 6cad782..b69fec9 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -930,8 +930,8 @@ func TestSudoCommand(t *testing.T) { Env: map[string]string{ "USER_NAME": "testuser", "USER_PASSWORD": "testpass", - "PASSWORD_ACCESS": "true", // Enable password authentication - "SUDO_ACCESS": "true", // Optional: grant sudo access + "PASSWORD_ACCESS": "false", // Enable password authentication + "SUDO_ACCESS": "true", // Optional: grant sudo access "PUBLIC_KEY": string(pubKey), }, // Wait for the SSH port (2222) to be listening @@ -976,7 +976,6 @@ func TestSudoCommand(t *testing.T) { Host: []string{host}, Username: "testuser", // Use the configured username Port: port.Int(), // Use the mapped port - Password: "testpass", // Use the configured password KeyPath: "./tests/.ssh/id_rsa", Script: []string{ `sudo su - -c "whoami"`,