2014-07-10 23:52:43 +02:00
|
|
|
package ssh
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
2016-04-19 02:28:46 +02:00
|
|
|
|
|
|
|
"golang.org/x/crypto/ssh"
|
2014-07-10 23:52:43 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestPasswordKeyboardInteractive_Impl(t *testing.T) {
|
|
|
|
var raw interface{}
|
|
|
|
raw = PasswordKeyboardInteractive("foo")
|
|
|
|
if _, ok := raw.(ssh.KeyboardInteractiveChallenge); !ok {
|
|
|
|
t.Fatal("PasswordKeyboardInteractive must implement KeyboardInteractiveChallenge")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPasswordKeybardInteractive_Challenge(t *testing.T) {
|
|
|
|
p := PasswordKeyboardInteractive("foo")
|
|
|
|
result, err := p("foo", "bar", []string{"one", "two"}, nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err not nil: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(result, []string{"foo", "foo"}) {
|
|
|
|
t.Fatalf("invalid password: %#v", result)
|
|
|
|
}
|
|
|
|
}
|