diff options
| author | Eric Milliken <emilliken@gmail.com> | 2012-12-18 11:33:58 -0500 |
|---|---|---|
| committer | Adam Langley <agl@golang.org> | 2012-12-18 11:33:58 -0500 |
| commit | 61ab4d36dfa7fa0e3b13aebf87f8127a649463fb (patch) | |
| tree | 2308b5e9ac055427202890f3f62be46c011cfcbe /ssh/session_test.go | |
| parent | d95b28330da59cfd5b511cea8d98ce3379610013 (diff) | |
| download | go-x-crypto-61ab4d36dfa7fa0e3b13aebf87f8127a649463fb.tar.xz | |
go.crypto/ssh: support OpenSSH keepalives
Fixes golang/go#4552.
R=minux.ma, agl
CC=golang-dev
https://golang.org/cl/6948059
Diffstat (limited to 'ssh/session_test.go')
| -rw-r--r-- | ssh/session_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ssh/session_test.go b/ssh/session_test.go index 0c64ed2..218d002 100644 --- a/ssh/session_test.go +++ b/ssh/session_test.go @@ -498,6 +498,24 @@ func TestServerWindow(t *testing.T) { } } +// Verify the client can handle a keepalive packet from the server. +func TestClientHandlesKeepalives(t *testing.T) { + conn := dial(channelKeepaliveSender, t) + defer conn.Close() + session, err := conn.NewSession() + if err != nil { + t.Fatal(err) + } + defer session.Close() + if err := session.Shell(); err != nil { + t.Fatalf("Unable to execute command: %v", err) + } + err = session.Wait() + if err != nil { + t.Fatalf("expected nil but got: %v", err) + } +} + type exitStatusMsg struct { PeersId uint32 Request string @@ -687,3 +705,18 @@ func copyNRandomly(title string, dst io.Writer, src io.Reader, n int) (int, erro } return written, nil } + +func channelKeepaliveSender(ch *serverChan, t *testing.T) { + defer ch.Close() + shell := newServerShell(ch, "> ") + readLine(shell, t) + msg := channelRequestMsg{ + PeersId: ch.remoteId, + Request: "keepalive@openssh.com", + WantReply: true, + } + if err := ch.writePacket(marshal(msgChannelRequest, msg)); err != nil { + t.Errorf("unable to send channel keepalive request: %v", err) + } + sendStatus(0, ch, t) +} |
