2013-06-06 02:05:39 -04:00
|
|
|
package ssh
|
|
|
|
|
|
|
|
import (
|
2014-04-26 14:19:37 -04:00
|
|
|
"code.google.com/p/go.crypto/ssh"
|
2013-07-03 01:00:31 -04:00
|
|
|
"reflect"
|
2013-06-06 02:05:39 -04:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2013-07-03 01:00:31 -04:00
|
|
|
func TestPasswordKeyboardInteractive_Impl(t *testing.T) {
|
|
|
|
var raw interface{}
|
|
|
|
raw = PasswordKeyboardInteractive("foo")
|
2014-04-10 04:48:55 -04:00
|
|
|
if _, ok := raw.(ssh.KeyboardInteractiveChallenge); !ok {
|
|
|
|
t.Fatal("PasswordKeyboardInteractive must implement KeyboardInteractiveChallenge")
|
2013-07-03 01:00:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPasswordKeybardInteractive_Challenge(t *testing.T) {
|
|
|
|
p := PasswordKeyboardInteractive("foo")
|
2014-04-10 04:48:55 -04:00
|
|
|
result, err := p("foo", "bar", []string{"one", "two"}, nil)
|
2013-07-03 01:00:31 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err not nil: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(result, []string{"foo", "foo"}) {
|
|
|
|
t.Fatalf("invalid password: %#v", result)
|
|
|
|
}
|
|
|
|
}
|