github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/communicator/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  }