Commit a23897f5 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

communicator/ssh: Add type for static passwords

parent aee611db
package ssh
// An implementation of ssh.ClientPassword so that you can use a static
// string password for the password to ClientAuthPassword.
type Password string
func (p Password) Password(user string) (string, error) {
return string(p), nil
}
package ssh
import (
"code.google.com/p/go.crypto/ssh"
"testing"
)
func TestPassword_Impl(t *testing.T) {
var raw interface{}
raw = Password("foo")
if _, ok := raw.(ssh.ClientPassword); !ok {
t.Fatal("Password must implement ClientPassword")
}
}
func TestPasswordPassword(t *testing.T) {
p := Password("foo")
result, err := p.Password("user")
if err != nil {
t.Fatalf("err not nil: %s", err)
}
if result != "foo" {
t.Fatalf("invalid password: %s", result)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment