Left: | ||
Right: |
OLD | NEW |
---|---|
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 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 package ssh | 5 package ssh |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "crypto/dsa" | 9 "crypto/dsa" |
10 "io" | 10 "io" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 defer l.Close() | 172 defer l.Close() |
173 c, err := l.Accept() | 173 c, err := l.Accept() |
174 if err != nil { | 174 if err != nil { |
175 t.Errorf("Unable to accept incoming connection: %v", err ) | 175 t.Errorf("Unable to accept incoming connection: %v", err ) |
176 return | 176 return |
177 } | 177 } |
178 if err := c.Handshake(); err != nil { | 178 if err := c.Handshake(); err != nil { |
179 // not Errorf because this is expected to | 179 // not Errorf because this is expected to |
180 // fail for some tests. | 180 // fail for some tests. |
181 t.Logf("Handshaking error: %v", err) | 181 t.Logf("Handshaking error: %v", err) |
182 c.Close() | |
182 return | 183 return |
183 } | 184 } |
184 defer c.Close() | 185 defer c.Close() |
jpsugar
2013/11/11 18:48:17
How about just moving this up above c.Handshake?
hanwen-google
2013/11/12 14:44:42
Done.
| |
185 }() | 186 }() |
186 return l.Addr().String() | 187 return l.Addr().String() |
187 } | 188 } |
188 | 189 |
189 func TestClientAuthPublicKey(t *testing.T) { | 190 func TestClientAuthPublicKey(t *testing.T) { |
190 config := &ClientConfig{ | 191 config := &ClientConfig{ |
191 User: "testuser", | 192 User: "testuser", |
192 Auth: []ClientAuth{ | 193 Auth: []ClientAuth{ |
193 ClientAuthKeyring(clientKeychain), | 194 ClientAuthKeyring(clientKeychain), |
194 }, | 195 }, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 }, | 360 }, |
360 } | 361 } |
361 c, err := Dial("tcp", newMockAuthServer(t), config) | 362 c, err := Dial("tcp", newMockAuthServer(t), config) |
362 if err == nil || !strings.Contains(err.Error(), "no common algorithms") { | 363 if err == nil || !strings.Contains(err.Error(), "no common algorithms") { |
363 t.Errorf("got %v, expected 'no common algorithms'", err) | 364 t.Errorf("got %v, expected 'no common algorithms'", err) |
364 } | 365 } |
365 if c != nil { | 366 if c != nil { |
366 c.Close() | 367 c.Close() |
367 } | 368 } |
368 } | 369 } |
OLD | NEW |