mirror of
				https://github.com/appleboy/drone-ssh.git
				synced 2025-10-29 00:51:15 +08:00 
			
		
		
		
	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:
		
							parent
							
								
									b2a60a2fec
								
							
						
					
					
						commit
						b630bf1d33
					
				| @ -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) | ||||
|  | ||||
| @ -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{ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Bo-Yi.Wu
						Bo-Yi.Wu