github.com/adamar/terraform@v0.2.2-0.20141016210445-2e703afdad0e/helper/ssh/password_test.go (about)

     1  package ssh
     2  
     3  import (
     4  	"code.google.com/p/go.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  }