var logData = lager.Data{ "foo": "bar", "a-number": 7, } BeforeEach(func() { logger = lager.NewLogger(component) testSink = lagertest.NewTestSink() logger.RegisterSink(testSink) }) var TestCommonLogFeatures = func(level lager.LogLevel) { var log lager.LogFormat BeforeEach(func() { log = testSink.Logs()[0] }) It("writes a log to the sink", func() { Ω(testSink.Logs()).Should(HaveLen(1)) }) It("records the source component", func() { Ω(log.Source).Should(Equal(component)) }) It("outputs a properly-formatted message", func() { Ω(log.Message).Should(Equal(fmt.Sprintf("%s.%s", component, action))) }) It("has a timestamp", func() {
}) AfterEach(func() { ts.Close() }) It("doesn't output the authorization information", func() { req, err := http.NewRequest("GET", ts.URL, nil) req.Header.Add("Authorization", "this-is-a-secret") req.Header.Add("authorization", "this-is-a-secret2") req.Header.Add("AUTHORIZATION", "this-is-a-secret3") req.Header.Add("auThoRizaTion", "this-is-a-secret4") resp, err := client.Do(req) Expect(err).NotTo(HaveOccurred()) output, err := ioutil.ReadAll(resp.Body) resp.Body.Close() Expect(err).NotTo(HaveOccurred()) Expect(output).To(ContainSubstring("Dummy handler")) headers := testSink.Logs()[0].Data["request-headers"] Expect(headers).ToNot(HaveKey("Authorization")) Expect(headers).ToNot(HaveKey("authorization")) Expect(headers).ToNot(HaveKey("AUTHORIZATION")) Expect(headers).ToNot(HaveKey("auThoRizaTion")) }) })