Skip to content

Commit 95a87c8

Browse files
committed
fix redirect test
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>
1 parent 86db1c5 commit 95a87c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

github_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io/ioutil"
66
"net/http"
7+
"net/url"
78
"time"
89

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

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

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

0 commit comments

Comments
 (0)