Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve gateway options test #5433

Merged
merged 1 commit into from
Sep 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core

dh.Handler, err = makeHandler(n,
ts.Listener,
VersionOption(),
IPNSHostnameOption(),
GatewayOption(false, "/ipfs", "/ipns"),
VersionOption(),
)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -290,6 +290,23 @@ func TestIPNSHostnameRedirect(t *testing.T) {
} else if hdr[0] != "/good-prefix/foo/" {
t.Errorf("location header is %v, expected /good-prefix/foo/", hdr[0])
}

// make sure /version isn't exposed
req, err = http.NewRequest("GET", ts.URL+"/version", nil)
if err != nil {
t.Fatal(err)
}
req.Host = "example.net"
req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix")

res, err = doWithoutRedirect(req)
if err != nil {
t.Fatal(err)
}

if res.StatusCode != 404 {
t.Fatalf("expected a 404 error, got: %s", res.Status)
}
}

func TestIPNSHostnameBacklinks(t *testing.T) {
Expand Down