Skip to content

Commit

Permalink
fix redirect test
Browse files Browse the repository at this point in the history
The http.Client got smarter. The http client only removes the
Authorization header if the base domain is different. When we start
these two local http test servers, they both have the same "base
domain", which is `127.0.0.1`, so the http client never strips the
Authorization header. To work around this I changed the external server
URL to be `localhost`.

So setup looked like this:

http://127.0.0.1:4455 -> redirect to http://127.0.0.1:5566

Now the redirect looks like this:

http://127.0.0.1:4455 -> redirect to http://localhost:5566

Signed-off-by: Taylor Silva <dev@taydev.net>
  • Loading branch information
taylorsilva committed Oct 17, 2024
1 parent 86db1c5 commit 95a87c8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"

. "github.com/concourse/github-release-resource"
Expand Down Expand Up @@ -649,8 +650,11 @@ var _ = Describe("GitHub Client", func() {

BeforeEach(func() {
externalServer = ghttp.NewServer()
u, err := url.Parse(externalServer.URL())
Expect(err).NotTo(HaveOccurred())
externalUrl := fmt.Sprintf("http://localhost:%s", u.Port())

appendGetHandler(server, redirectPath, 307, "", true, locationHeader(externalServer.URL()+"/somewhere-else"))
appendGetHandler(server, redirectPath, 307, "", true, locationHeader(externalUrl+"/somewhere-else"))
appendGetHandler(externalServer, "/somewhere-else", 200, redirectFileContents, false)
})

Expand Down

0 comments on commit 95a87c8

Please sign in to comment.