chore(auth): allow use password and key at same time

ref: https://github.com/appleboy/ssh-action/issues/178

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu 2023-02-28 16:58:03 +08:00
parent b2a60a2fec
commit b630bf1d33
2 changed files with 0 additions and 22 deletions

View File

@ -17,7 +17,6 @@ var (
errMissingHost = errors.New("Error: missing server host")
errMissingPasswordOrKey = errors.New("Error: can't connect without a private SSH key or password")
errCommandTimeOut = errors.New("Error: command timeout")
errSetPasswordandKey = errors.New("can't set password and key at the same time")
)
type (
@ -173,10 +172,6 @@ func (p Plugin) Exec() error {
return errMissingPasswordOrKey
}
if len(p.Config.Key) != 0 && len(p.Config.Password) != 0 {
return errSetPasswordandKey
}
wg := sync.WaitGroup{}
wg.Add(len(p.Config.Host))
errChannel := make(chan error)

View File

@ -38,23 +38,6 @@ func TestMissingKeyOrPassword(t *testing.T) {
assert.Equal(t, errMissingPasswordOrKey, err)
}
func TestSetPasswordAndKey(t *testing.T) {
plugin := Plugin{
Config{
Host: []string{"localhost"},
Username: "ubuntu",
Password: "1234",
Key: "1234",
},
os.Stdout,
}
err := plugin.Exec()
assert.NotNil(t, err)
assert.Equal(t, errSetPasswordandKey, err)
}
func TestIncorrectPassword(t *testing.T) {
plugin := Plugin{
Config: Config{