- Refactor SSH-related integration tests to use a reusable SSHTestConfig struct and a new runSSHContainerTest helper function
- Support testing both key-based and password-based authentication by passing configuration via SSHTestConfig
- Move duplicated test setup code for containerized SSH server to the helper function
- Update assertions to check outputs against configurable expected values for each test
- Add test for password-based authentication in addition to existing sudo command test
Signed-off-by: appleboy <appleboy.tw@gmail.com>
- Remove USER_PASSWORD from test environment setup
- Update comment to correctly state that password authentication is disabled
Signed-off-by: appleboy <appleboy.tw@gmail.com>
- 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>
- Add a test that dynamically starts an OpenSSH server in a Docker container for integration testing.
- Configure the container with test credentials, allow password and sudo access, and inject the public key.
- Update the test to use the actual Docker container's hostname, dynamic port, username, and password.
- Improve error handling and test skipping if the Docker environment is not available.
Signed-off-by: appleboy <appleboy.tw@gmail.com>
- Remove unused import of strconv
- Remove environment variables PUID and PGID from the test container setup
- Enable UseInsecureCipher in SSH options for compatibility
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* chore: enhance testing with updated libraries and new test cases
- Update `testify` library from `v1.8.4` to `v1.10.0`
- Add dependency for `testcontainers-go` library
- Add various indirect dependencies
- Include `context` and `fmt` packages in test file
- Add test for SSH connection using `testcontainers` library
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* refactor: improve performance by optimizing string conversions
- Add the `strconv` import.
- Replace `fmt.Sprintf` with `strconv.Itoa` for converting UID and GID to string.
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* test: switch to alternative image source for SSH testing
- Update image name in the SSH test from `lscr.io/linuxserver/openssh-server:latest` to `linuxserver/openssh-server:latest`.
Signed-off-by: appleboy <appleboy.tw@gmail.com>
---------
Signed-off-by: appleboy <appleboy.tw@gmail.com>
- Update `.golangci.yaml` to version 2 and streamline settings
- Remove specific linters from `.golangci.yaml` configuration
- Add exclusion and formatter settings to `.golangci.yaml`
- Change error message formatting in `plugin.go` to lowercase
- Use `strings.ReplaceAll` instead of `strings.Replace` for better readability and performance in `plugin.go` and `plugin_test.go`
Signed-off-by: appleboy <appleboy.tw@gmail.com>
- Simplify log output by removing "out:" and "err:" prefixes in `plugin.go`
- Update test expectations to match the new log output format
Signed-off-by: appleboy <appleboy.tw@gmail.com>
* docs: improve documentation and configuration handling
- Clarify valid values for the IP protocol in usage messages for both main application and proxy settings
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* test: improve IPv6 command execution tests
- Add a new test function `TestCommandWithIPv6` to check command execution with an IPv6 address
- Initialize test variables and expected output for the IPv6 command test
- Set up a `Plugin` struct with IPv6 host, user, port, key path, script, and command timeout for testing
- Verify that `plugin.Exec()` returns `nil` (no error) in the IPv6 test
- Assert that the output of the command execution matches the expected output in the IPv6 test
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* test: enhance test suite and CI robustness
- Add support for IPv6 protocol in `TestCommandWithIPv6` test case in `plugin_test.go`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update2
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update3
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update4
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update5
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update5
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* update5
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Add a new flag to the main.go file
- Add a new field to the Plugin type in the plugin.go file
- Remove two lines from the plugin_test.go file
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Add a new flag `allenvs` to pass all environment variables to the shell script
- Implement the `AllEnvs` functionality in the `exec` function
- Add a new function `findEnvs` to find all environment variables with specified prefixes
- Add tests for the `findEnvs` function and the `AllEnvs` functionality
- Add `trimValues` function for cleaning up slice values
- Remove unused `wg.Done()` call
- Modify `Exec` function to launch goroutines for each host in `Config.Host`
- Add test for `ScriptStop` with multiple hosts and sync mode
refer to: https://github.com/appleboy/ssh-action/issues/233