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