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

Delta Between Two Patch Sets: ssh/test/session_test.go

Issue 14494058: code review 14494058: go.crypto/ssh: support rekeying in both directions. (Closed)
Left Patch Set: diff -r ef3d7138b0b5 https://code.google.com/p/go.crypto Created 10 years, 5 months ago
Right Patch Set: diff -r cd1eea1eb828 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:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build !windows 5 // +build !windows
6 6
7 package test 7 package test
8 8
9 // Session functional tests. 9 // Session functional tests.
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 n, err := io.Copy(buf, stdout) 116 n, err := io.Copy(buf, stdout)
117 if err != nil { 117 if err != nil {
118 t.Fatalf("error reading from remote stdout: %s", err) 118 t.Fatalf("error reading from remote stdout: %s", err)
119 } 119 }
120 120
121 if n != 2048 { 121 if n != 2048 {
122 t.Fatalf("Expected %d bytes but read only %d from remote command ", 2048, n) 122 t.Fatalf("Expected %d bytes but read only %d from remote command ", 2048, n)
123 } 123 }
124 } 124 }
125 125
126 func TestKeyChange(t *testing.T) {
127 server := newServer(t)
128 defer server.Shutdown()
129 conf := clientConfig()
130 conf.Crypto.RekeyThreshold = 1024
131 conn := server.Dial(conf)
132 defer conn.Close()
133
134 for i := 0; i < 4; i++ {
135 session, err := conn.NewSession()
136 if err != nil {
137 t.Fatalf("unable to create new session: %s", err)
138 }
139
140 stdout, err := session.StdoutPipe()
141 if err != nil {
142 t.Fatalf("unable to acquire stdout pipe: %s", err)
143 }
144
145 err = session.Start("dd if=/dev/urandom bs=1024 count=1")
146 if err != nil {
147 t.Fatalf("unable to execute remote command: %s", err)
148 }
149 buf := new(bytes.Buffer)
150 n, err := io.Copy(buf, stdout)
151 if err != nil {
152 t.Fatalf("error reading from remote stdout: %s", err)
153 }
154
155 if n != 1024 {
156 t.Fatalf("Expected %d bytes but read only %d from remote command", 2048, n)
dfc 2013/11/03 08:23:03 the test doesn't match the failure message
157 }
158 }
159
160 if changes := conf.HostKeyChecker.(*storedHostKey).checkCount; changes < 4 {
161 t.Errorf("got %d key changes, want 4", changes)
162 }
163 }
164
126 func TestInvalidTerminalMode(t *testing.T) { 165 func TestInvalidTerminalMode(t *testing.T) {
127 server := newServer(t) 166 server := newServer(t)
128 defer server.Shutdown() 167 defer server.Shutdown()
129 conn := server.Dial(clientConfig()) 168 conn := server.Dial(clientConfig())
130 defer conn.Close() 169 defer conn.Close()
131 170
132 session, err := conn.NewSession() 171 session, err := conn.NewSession()
133 if err != nil { 172 if err != nil {
134 t.Fatalf("session failed: %v", err) 173 t.Fatalf("session failed: %v", err)
135 } 174 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 215
177 var buf bytes.Buffer 216 var buf bytes.Buffer
178 if _, err := io.Copy(&buf, stdout); err != nil { 217 if _, err := io.Copy(&buf, stdout); err != nil {
179 t.Fatalf("reading failed: %s", err) 218 t.Fatalf("reading failed: %s", err)
180 } 219 }
181 220
182 if sttyOutput := buf.String(); !strings.Contains(sttyOutput, "-echo ") { 221 if sttyOutput := buf.String(); !strings.Contains(sttyOutput, "-echo ") {
183 t.Fatalf("terminal mode failure: expected -echo in stty output, got %s", sttyOutput) 222 t.Fatalf("terminal mode failure: expected -echo in stty output, got %s", sttyOutput)
184 } 223 }
185 } 224 }
LEFTRIGHT

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