@cryptotaxi247 / kubo / commits / 1ee3645a4

adds tests for gateway url escaping

License: MIT Signed-off-by: Stephen Whitmore <noffle@ipfs.io>

Stephen Whitmore committed Mar 2, 2016 at 16:46 UTC 1ee3645a4940b5bcb369af249bf881c070ee30a6
1 file changed +8 -8
core/corehttp/gateway_test.go
+8 -8
@@ -261,7 +261,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
261 t.Fatal(err)
262 }
263 dagn2.AddNodeLink("bar", dagn3)
264 - dagn1.AddNodeLink("foo", dagn2)
264 + dagn1.AddNodeLink("foo? #<'", dagn2)
265 if err != nil {
266 t.Fatal(err)
267 }
@@ -279,7 +279,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
279 ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String())
280
281 // make request to directory listing
282 - req, err := http.NewRequest("GET", ts.URL+"/foo/", nil)
282 + req, err := http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/", nil)
283 if err != nil {
284 t.Fatal(err)
285 }
@@ -298,13 +298,13 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
298 s := string(body)
299 t.Logf("body: %s\n", string(body))
300
301 - if !strings.Contains(s, "Index of /foo/") {
301 + if !strings.Contains(s, "Index of /foo? #&lt;&#39;/") {
302 t.Fatalf("expected a path in directory listing")
303 }
304 if !strings.Contains(s, "<a href=\"/\">") {
305 t.Fatalf("expected backlink in directory listing")
306 }
307 - if !strings.Contains(s, "<a href=\"/foo/file.txt\">") {
307 + if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/file.txt\">") {
308 t.Fatalf("expected file in directory listing")
309 }
310
@@ -339,7 +339,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
339 }
340
341 // make request to directory listing
342 - req, err = http.NewRequest("GET", ts.URL+"/foo/bar/", nil)
342 + req, err = http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/bar/", nil)
343 if err != nil {
344 t.Fatal(err)
345 }
@@ -358,13 +358,13 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
358 s = string(body)
359 t.Logf("body: %s\n", string(body))
360
361 - if !strings.Contains(s, "Index of /foo/bar/") {
361 + if !strings.Contains(s, "Index of /foo? #&lt;&#39;/bar/") {
362 t.Fatalf("expected a path in directory listing")
363 }
364 - if !strings.Contains(s, "<a href=\"/foo/\">") {
364 + if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/\">") {
365 t.Fatalf("expected backlink in directory listing")
366 }
367 - if !strings.Contains(s, "<a href=\"/foo/bar/file.txt\">") {
367 + if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/bar/file.txt\">") {
368 t.Fatalf("expected file in directory listing")
369 }
370