globalRequestHandler = &fake_handlers.FakeGlobalRequestHandler{} globalRequestHandler.HandleRequestStub = func(logger lager.Logger, request *ssh.Request) { request.Reply(true, []byte("response-payload")) } daemonGlobalRequestHandlers["test-global-request"] = globalRequestHandler }) It("gets forwarded to the daemon and the response comes back", func() { accepted, response, err := client.SendRequest("test-global-request", true, []byte("request-payload")) Expect(err).NotTo(HaveOccurred()) Expect(accepted).To(BeTrue()) Expect(response).To(Equal([]byte("response-payload"))) Expect(globalRequestHandler.HandleRequestCallCount()).To(Equal(1)) _, request := globalRequestHandler.HandleRequestArgsForCall(0) Expect(request.Type).To(Equal("test-global-request")) Expect(request.WantReply).To(BeTrue()) Expect(request.Payload).To(Equal([]byte("request-payload"))) }) }) Context("when the client requests a new channel", func() { var newChannelHandler *fake_handlers.FakeNewChannelHandler BeforeEach(func() { newChannelHandler = &fake_handlers.FakeNewChannelHandler{} newChannelHandler.HandleNewChannelStub = func(logger lager.Logger, newChannel ssh.NewChannel) { newChannel.Reject(ssh.Prohibited, "not now") } daemonNewChannelHandlers["test"] = newChannelHandler