1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 08:47:42 +08:00

adds tests for gateway url escaping

License: MIT
Signed-off-by: Stephen Whitmore <noffle@ipfs.io>
This commit is contained in:
Stephen Whitmore
2016-03-02 16:46:49 -08:00
parent ec7623bb81
commit 1ee3645a49

View File

@ -261,7 +261,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
dagn2.AddNodeLink("bar", dagn3) dagn2.AddNodeLink("bar", dagn3)
dagn1.AddNodeLink("foo", dagn2) dagn1.AddNodeLink("foo? #<'", dagn2)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -279,7 +279,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String())
// make request to directory listing // make request to directory listing
req, err := http.NewRequest("GET", ts.URL+"/foo/", nil) req, err := http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/", nil)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -298,13 +298,13 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
s := string(body) s := string(body)
t.Logf("body: %s\n", string(body)) t.Logf("body: %s\n", string(body))
if !strings.Contains(s, "Index of /foo/") { if !strings.Contains(s, "Index of /foo? #&lt;&#39;/") {
t.Fatalf("expected a path in directory listing") t.Fatalf("expected a path in directory listing")
} }
if !strings.Contains(s, "<a href=\"/\">") { if !strings.Contains(s, "<a href=\"/\">") {
t.Fatalf("expected backlink in directory listing") t.Fatalf("expected backlink in directory listing")
} }
if !strings.Contains(s, "<a href=\"/foo/file.txt\">") { if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/file.txt\">") {
t.Fatalf("expected file in directory listing") t.Fatalf("expected file in directory listing")
} }
@ -339,7 +339,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
} }
// make request to directory listing // make request to directory listing
req, err = http.NewRequest("GET", ts.URL+"/foo/bar/", nil) req, err = http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/bar/", nil)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -358,13 +358,13 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
s = string(body) s = string(body)
t.Logf("body: %s\n", string(body)) t.Logf("body: %s\n", string(body))
if !strings.Contains(s, "Index of /foo/bar/") { if !strings.Contains(s, "Index of /foo? #&lt;&#39;/bar/") {
t.Fatalf("expected a path in directory listing") t.Fatalf("expected a path in directory listing")
} }
if !strings.Contains(s, "<a href=\"/foo/\">") { if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/\">") {
t.Fatalf("expected backlink in directory listing") t.Fatalf("expected backlink in directory listing")
} }
if !strings.Contains(s, "<a href=\"/foo/bar/file.txt\">") { if !strings.Contains(s, "<a href=\"/foo%3F%20%23%3C%27/bar/file.txt\">") {
t.Fatalf("expected file in directory listing") t.Fatalf("expected file in directory listing")
} }