go.crypto/ssh: add hook for host key checking.

R=dave, agl
CC=gobot, golang-dev
https://golang.org/cl/9922043
This commit is contained in:
Han-Wen Nienhuys
2013-06-21 12:46:35 -04:00
committed by Adam Langley
parent b88b016522
commit afdc305bc8
4 changed files with 95 additions and 5 deletions
+19
View File
@@ -33,6 +33,25 @@ func TestRunCommandSuccess(t *testing.T) {
}
}
func TestHostKeyCheck(t *testing.T) {
server := newServer(t)
defer server.Shutdown()
conf := clientConfig()
k := conf.HostKeyChecker.(*storedHostKey)
// change the key.
k.keys["ssh-rsa"][25]++
conn, err := server.TryDial(conf)
if err == nil {
conn.Close()
t.Fatalf("dial should have failed.")
} else if !strings.Contains(err.Error(), "host key mismatch") {
t.Fatalf("'host key mismatch' not found in %v", err)
}
}
func TestRunCommandFailed(t *testing.T) {
server := newServer(t)
defer server.Shutdown()