mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-05-09 18:23:21 +08:00
chore(auth): allow use password and key at same time (#240)
This commit is contained in:
parent
d0ed2bb2fb
commit
1a95b5f1b3
@ -17,7 +17,6 @@ var (
|
|||||||
errMissingHost = errors.New("Error: missing server host")
|
errMissingHost = errors.New("Error: missing server host")
|
||||||
errMissingPasswordOrKey = errors.New("Error: can't connect without a private SSH key or password")
|
errMissingPasswordOrKey = errors.New("Error: can't connect without a private SSH key or password")
|
||||||
errCommandTimeOut = errors.New("Error: command timeout")
|
errCommandTimeOut = errors.New("Error: command timeout")
|
||||||
errSetPasswordandKey = errors.New("can't set password and key at the same time")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -173,10 +172,6 @@ func (p Plugin) Exec() error {
|
|||||||
return errMissingPasswordOrKey
|
return errMissingPasswordOrKey
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(p.Config.Key) != 0 && len(p.Config.Password) != 0 {
|
|
||||||
return errSetPasswordandKey
|
|
||||||
}
|
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(len(p.Config.Host))
|
wg.Add(len(p.Config.Host))
|
||||||
errChannel := make(chan error)
|
errChannel := make(chan error)
|
||||||
|
@ -38,23 +38,6 @@ func TestMissingKeyOrPassword(t *testing.T) {
|
|||||||
assert.Equal(t, errMissingPasswordOrKey, err)
|
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) {
|
func TestIncorrectPassword(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Config: Config{
|
Config: Config{
|
||||||
|
Loading…
Reference in New Issue
Block a user