2024-05-10 04:56:16 +02:00
|
|
|
package ssh
|
2024-04-09 03:00:40 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSSH_validate(t *testing.T) {
|
2024-05-10 04:56:16 +02:00
|
|
|
cfg := &Config{}
|
|
|
|
if err := cfg.Validate(); err == nil {
|
2024-04-09 03:00:40 +02:00
|
|
|
t.Error("expected an error")
|
|
|
|
} else if !errors.Is(err, ErrEndpointWithoutSSHUsername) {
|
|
|
|
t.Errorf("expected error to be '%v', got '%v'", ErrEndpointWithoutSSHUsername, err)
|
|
|
|
}
|
2024-05-10 04:56:16 +02:00
|
|
|
cfg.Username = "username"
|
|
|
|
if err := cfg.Validate(); err == nil {
|
2024-04-09 03:00:40 +02:00
|
|
|
t.Error("expected an error")
|
|
|
|
} else if !errors.Is(err, ErrEndpointWithoutSSHPassword) {
|
|
|
|
t.Errorf("expected error to be '%v', got '%v'", ErrEndpointWithoutSSHPassword, err)
|
|
|
|
}
|
2024-05-10 04:56:16 +02:00
|
|
|
cfg.Password = "password"
|
|
|
|
if err := cfg.Validate(); err != nil {
|
2024-04-09 03:00:40 +02:00
|
|
|
t.Errorf("expected no error, got '%v'", err)
|
|
|
|
}
|
|
|
|
}
|