Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(335)

Delta Between Two Patch Sets: ssh/client_test.go

Issue 14641044: code review 14641044: go.crypto/ssh: put version exchange in function (Closed)
Left Patch Set: diff -r bb19605bfacc https://code.google.com/p/go.crypto Created 10 years, 5 months ago
Right Patch Set: diff -r bb19605bfacc https://code.google.com/p/go.crypto Created 10 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « ssh/client.go ('k') | ssh/server.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package ssh 1 package ssh
2 2
3 import ( 3 import (
4 "net" 4 "net"
5 "testing" 5 "testing"
6 ) 6 )
7 7
8 func testClientVersion(t *testing.T, config *ClientConfig, expected string) { 8 func testClientVersion(t *testing.T, config *ClientConfig, expected string) {
9 clientConn, serverConn := net.Pipe() 9 clientConn, serverConn := net.Pipe()
10 receivedVersion := make(chan string, 1) 10 receivedVersion := make(chan string, 1)
11 go func() { 11 go func() {
12 version, err := readVersion(serverConn) 12 version, err := readVersion(serverConn)
13 if err != nil { 13 if err != nil {
14 receivedVersion <- "" 14 receivedVersion <- ""
15 } else { 15 } else {
16 receivedVersion <- string(version) 16 receivedVersion <- string(version)
17 } 17 }
18 serverConn.Close() 18 serverConn.Close()
19 }() 19 }()
20 Client(clientConn, config) 20 Client(clientConn, config)
21 actual := <-receivedVersion 21 actual := <-receivedVersion
22 if actual != expected { 22 if actual != expected {
23 t.Fatalf("got %s; want %s", actual, expected) 23 t.Fatalf("got %s; want %s", actual, expected)
24 } 24 }
25 } 25 }
26 26
27 func TestCustomClientVersion(t *testing.T) { 27 func TestCustomClientVersion(t *testing.T) {
28 version := "Test-Client-Version-0.0" 28 version := "Test-Client-Version-0.0"
29 » testClientVersion(t, &ClientConfig{ClientVersion: version}, "SSH-2.0-"+v ersion) 29 » testClientVersion(t, &ClientConfig{ClientVersion: version}, version)
dfc 2013/10/14 00:32:28 Why not just // rfc NNN requires the client vers
hanwen-google 2013/10/14 06:41:44 because that would send back SSH-2.0-SSH-2.0-Test.
30 } 30 }
31 31
32 func TestDefaultClientVersion(t *testing.T) { 32 func TestDefaultClientVersion(t *testing.T) {
33 » testClientVersion(t, &ClientConfig{}, string(packageVersion)) 33 » testClientVersion(t, &ClientConfig{}, packageVersion)
dfc 2013/10/14 00:32:28 dumb question, probably by fault, why isn't packag
hanwen-google 2013/10/14 06:41:44 to not change things? I don't where you and Adam w
34 } 34 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b