Exemplo n.º 1
0
		req.SetBasicAuth("user", "pass")

		resp, err = client.Do(req)
		Expect(err).ToNot(HaveOccurred())
		Expect(resp).ToNot(BeNil())
		Expect(resp.StatusCode).To(Equal(200))

		body, err := ioutil.ReadAll(resp.Body)
		defer resp.Body.Close()
		Expect(err).ToNot(HaveOccurred())
		Expect(string(body)).To(MatchRegexp(".*1\\.2\\.3\\.4:1234.*\n"))
	})

	Context("when proxy proto is enabled", func() {
		BeforeEach(func() {
			config.EnablePROXY = true
		})

		It("sets the X-Forwarded-For header", func() {
			app := testcommon.NewTestApp([]route.Uri{"proxy.vcap.me"}, config.Port, mbusClient, nil, "")

			rCh := make(chan string)
			app.AddHandler("/", func(w http.ResponseWriter, r *http.Request) {
				rCh <- r.Header.Get("X-Forwarded-For")
			})
			app.Listen()
			Eventually(func() bool {
				return appRegistered(registry, app)
			}).Should(BeTrue())

			host := fmt.Sprintf("proxy.vcap.me:%d", config.Port)