@cryptotaxi247 / kubo / commits / eabd6a0ad

improve gateway options test

Unfortunately, this doesn't really test the *actual* gateway config as it uses the options specified by the test. However, it's a step in the right direction. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Sep 6, 2018 at 11:00 UTC eabd6a0ad4fe0bde0c344b0c3086c480b0b6bc4e
1 file changed +18 -1
core/corehttp/gateway_test.go
+18 -1
@@ -128,9 +128,9 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core
128
129 dh.Handler, err = makeHandler(n,
130 ts.Listener,
131 - VersionOption(),
131 IPNSHostnameOption(),
132 GatewayOption(false, "/ipfs", "/ipns"),
133 + VersionOption(),
134 )
135 if err != nil {
136 t.Fatal(err)
@@ -290,6 +290,23 @@ func TestIPNSHostnameRedirect(t *testing.T) {
290 } else if hdr[0] != "/good-prefix/foo/" {
291 t.Errorf("location header is %v, expected /good-prefix/foo/", hdr[0])
292 }
293 +
294 + // make sure /version isn't exposed
295 + req, err = http.NewRequest("GET", ts.URL+"/version", nil)
296 + if err != nil {
297 + t.Fatal(err)
298 + }
299 + req.Host = "example.net"
300 + req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix")
301 +
302 + res, err = doWithoutRedirect(req)
303 + if err != nil {
304 + t.Fatal(err)
305 + }
306 +
307 + if res.StatusCode != 404 {
308 + t.Fatalf("expected a 404 error, got: %s", res.Status)
309 + }
310 }
311
312 func TestIPNSHostnameBacklinks(t *testing.T) {