crypto/ssh: Allow customization of the client version.

R=agl, golang-dev, dave
CC=golang-dev
https://golang.org/cl/13176044
This commit is contained in:
JP Sugarbroad
2013-08-27 13:40:08 -04:00
committed by Adam Langley
parent 504f1d5525
commit c2c80b64c0
2 changed files with 49 additions and 4 deletions
+34
View File
@@ -0,0 +1,34 @@
package ssh
import (
"net"
"testing"
)
func testClientVersion(t *testing.T, config *ClientConfig, expected string) {
clientConn, serverConn := net.Pipe()
receivedVersion := make(chan string, 1)
go func() {
version, err := readVersion(serverConn)
if err != nil {
receivedVersion <- ""
} else {
receivedVersion <- string(version)
}
serverConn.Close()
}()
Client(clientConn, config)
actual := <-receivedVersion
if actual != expected {
t.Fatalf("got %s; want %s", actual, expected)
}
}
func TestCustomClientVersion(t *testing.T) {
version := "Test-Client-Version-0.0"
testClientVersion(t, &ClientConfig{ClientVersion: version}, version)
}
func TestDefaultClientVersion(t *testing.T) {
testClientVersion(t, &ClientConfig{}, string(clientVersion))
}