. "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Logs", func() { var fakeLogSender *fake.FakeLogSender BeforeEach(func() { fakeLogSender = fake.NewFakeLogSender() logs.Initialize(fakeLogSender) }) It("delegates SendAppLog", func() { logs.SendAppLog("app-id", "custom-log-message", "App", "0") Expect(fakeLogSender.GetLogs()).To(HaveLen(1)) Expect(fakeLogSender.GetLogs()[0]).To(Equal(fake.Log{AppId: "app-id", Message: "custom-log-message", SourceType: "App", SourceInstance: "0", MessageType: "OUT"})) }) It("delegates SendAppErrorLog", func() { logs.SendAppErrorLog("app-id", "custom-log-error-message", "App", "0") Expect(fakeLogSender.GetLogs()).To(HaveLen(1)) Expect(fakeLogSender.GetLogs()[0]).To(Equal(fake.Log{AppId: "app-id", Message: "custom-log-error-message", SourceType: "App", SourceInstance: "0", MessageType: "ERR"})) }) Context("when errors occur", func() { BeforeEach(func() { fakeLogSender.ReturnError = errors.New("error occurred") })
var err error client, err = ssh.Dial("tcp", proxyAddress, clientConfig) Expect(err).NotTo(HaveOccurred()) }) It("handshakes with the target using the provided configuration", func() { Eventually(daemonAuthenticator.AuthenticateCallCount).Should(Equal(1)) metadata, password := daemonAuthenticator.AuthenticateArgsForCall(0) Expect(metadata.User()).To(Equal("some-user")) Expect(string(password)).To(Equal("some-password")) }) It("emits a successful log message on behalf of the lrp", func() { Eventually(fakeLogSender.GetLogs).Should(HaveLen(1)) logMessage := fakeLogSender.GetLogs()[0] Expect(logMessage.AppId).To(Equal("a-guid")) Expect(logMessage.SourceType).To(Equal("SSH")) Expect(logMessage.SourceInstance).To(Equal("1")) Expect(logMessage.Message).To(Equal("a-message")) }) Context("when the target contains a host fingerprint", func() { Context("when the fingerprint is an md5 hash", func() { BeforeEach(func() { targetConfigJson, err := json.Marshal(proxy.TargetConfig{ Address: sshdListener.Addr().String(), HostFingerprint: helpers.MD5Fingerprint(TestHostKey.PublicKey()), User: "******", Password: "******", })