File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
13
13
"os/exec"
14
14
"path/filepath"
15
15
"strconv"
16
+ "sync"
16
17
"testing"
17
18
"time"
18
19
@@ -232,14 +233,26 @@ func TestServerResponseTooLarge(t *testing.T) {
232
233
response .Keys = make ([]byte , maxAgentResponseBytes + 1 )
233
234
234
235
agent := NewClient (a )
235
- go b .Write (ssh .Marshal (response ))
236
+ var wg sync.WaitGroup
237
+ wg .Add (1 )
238
+ go func () {
239
+ defer wg .Done ()
240
+ n , _ := b .Write (ssh .Marshal (response ))
241
+ if n < 4 {
242
+ t .Fatalf ("At least 4 bytes (the response size) should have been successfully written: %d < 4" , n )
243
+ }
244
+ }()
236
245
_ , err = agent .List ()
237
246
if err == nil {
238
247
t .Fatal ("Did not get error result" )
239
248
}
240
249
if err .Error () != "agent: client error: response too large" {
241
250
t .Fatal ("Did not get expected error result" )
242
251
}
252
+ // We need to explicitly close the client connection or else the server-side write call might block waiting for
253
+ // the client to consume the entire message (which it shouldn't)
254
+ a .Close ()
255
+ wg .Wait ()
243
256
}
244
257
245
258
func TestAuth (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments