github.com/ves/terraform@v0.8.0-beta2/communicator/ssh/password_test.go (about) 1 package ssh 2 3 import ( 4 "reflect" 5 "testing" 6 7 "golang.org/x/crypto/ssh" 8 ) 9 10 func TestPasswordKeyboardInteractive_Impl(t *testing.T) { 11 var raw interface{} 12 raw = PasswordKeyboardInteractive("foo") 13 if _, ok := raw.(ssh.KeyboardInteractiveChallenge); !ok { 14 t.Fatal("PasswordKeyboardInteractive must implement KeyboardInteractiveChallenge") 15 } 16 } 17 18 func TestPasswordKeybardInteractive_Challenge(t *testing.T) { 19 p := PasswordKeyboardInteractive("foo") 20 result, err := p("foo", "bar", []string{"one", "two"}, nil) 21 if err != nil { 22 t.Fatalf("err not nil: %s", err) 23 } 24 25 if !reflect.DeepEqual(result, []string{"foo", "foo"}) { 26 t.Fatalf("invalid password: %#v", result) 27 } 28 }