示例#1
0
						events := []EventHolder{otherEvent, event}

						eventSource.NextStub = func() (models.Event, error) {
							var e EventHolder
							time.Sleep(10 * time.Millisecond)
							if len(events) == 0 {
								return nil, nil
							}
							e, events = events[0], events[1:]
							return e.event, nil
						}
					})

					It("does not call AppCrashed", func() {
						Eventually(ccClient.AppCrashedCallCount).Should(Equal(1))
						buffer := logger.Buffer()
						Expect(buffer).To(Say("process-guid"))
						Expect(buffer).NotTo(Say("other-process-guid"))
					})
				})
			})

			Context("and after < before", func() {
				BeforeEach(func() {
					before.Instance.CrashCount = 1
				})

				It("does not call AppCrashed", func() {
					Consistently(ccClient.AppCrashedCallCount).Should(Equal(0))
				})
			})
示例#2
0
		dummyRequest.Header.Add("Authorization", fakePassword)

		fakeResponseWriter = &apifakes.FakeResponseWriter{}
		fakeHandler = &fakes.FakeHandler{}

		logger = lagertest.NewTestLogger("backup-download-test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.INFO))
	})

	It("should log requests that are prefixed with routePrefix", func() {
		loggerMiddleware := middleware.NewLogger(logger, routePrefix)
		loggerHandler := loggerMiddleware.Wrap(fakeHandler)

		loggerHandler.ServeHTTP(fakeResponseWriter, dummyRequest)

		logContents := logger.Buffer().Contents()
		Expect(logContents).To(ContainSubstring("request"))
		Expect(logContents).To(ContainSubstring("response"))
	})

	It("should not log credentials", func() {
		loggerMiddleware := middleware.NewLogger(logger, routePrefix)
		loggerHandler := loggerMiddleware.Wrap(fakeHandler)

		loggerHandler.ServeHTTP(fakeResponseWriter, dummyRequest)

		logContents := logger.Buffer().Contents()
		Expect(logContents).ToNot(ContainSubstring(fakePassword))
	})

	It("should call next handler", func() {
示例#3
0
			tcpRouteMapping := db.TcpRouteMapping{
				TcpRoute: db.TcpRoute{
					RouterGroupGuid: DefaultRouterGroupGuid,
					ExternalPort:    5222,
				},
				HostPort: 61000,
				HostIP:   "some-ip-1",
			}
			err := routingApiClient.UpsertTcpRouteMappings([]db.TcpRouteMapping{tcpRouteMapping})
			Expect(err).ToNot(HaveOccurred())

			tcpRouteMappings, err := routingApiClient.TcpRouteMappings()
			Expect(err).NotTo(HaveOccurred())
			Expect(tcpRouteMappings).To(ContainElement(tcpRouteMapping))

			allOutput := logger.Buffer()
			runner := testrunner.New(routerConfigurerPath, routerConfigurerArgs)
			session, err = gexec.Start(runner.Command, allOutput, allOutput)
			Expect(err).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			logger.Info("shutting-down")
			session.Signal(os.Interrupt)
			Eventually(session.Exited, 5*time.Second).Should(BeClosed())
			server.Signal(os.Interrupt)
			Eventually(server.Wait(), 5*time.Second).Should(Receive())
			oauthServer.Close()
		})

		It("syncs with routing api", func() {