aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/http/server_test.go
diff options
context:
space:
mode:
authorholisticode <holistic.computing@gmail.com>2017-04-13 17:06:19 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-13 17:06:19 +0800
commit409b61fe3c8046dc26f3442846e9f7032bebb9c5 (patch)
tree041d051d192165fdf1d56391ec63c67822492476 /swarm/api/http/server_test.go
parentd5d910e8b68f6c6b29ca85f5a9fa1b72b2cc08c1 (diff)
downloaddexon-409b61fe3c8046dc26f3442846e9f7032bebb9c5.tar
dexon-409b61fe3c8046dc26f3442846e9f7032bebb9c5.tar.gz
dexon-409b61fe3c8046dc26f3442846e9f7032bebb9c5.tar.bz2
dexon-409b61fe3c8046dc26f3442846e9f7032bebb9c5.tar.lz
dexon-409b61fe3c8046dc26f3442846e9f7032bebb9c5.tar.xz
dexon-409b61fe3c8046dc26f3442846e9f7032bebb9c5.tar.zst
dexon-409b61fe3c8046dc26f3442846e9f7032bebb9c5.zip
swarm/api: better name resolver handling (#3754)
Fixes #3608
Diffstat (limited to 'swarm/api/http/server_test.go')
-rw-r--r--swarm/api/http/server_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go
index 942f3ba0b..ceb8db75b 100644
--- a/swarm/api/http/server_test.go
+++ b/swarm/api/http/server_test.go
@@ -99,4 +99,32 @@ func TestBzzrGetPath(t *testing.T) {
}
}
+ nonhashtests := []string{
+ srv.URL + "/bzz:/name",
+ srv.URL + "/bzzi:/nonhash",
+ srv.URL + "/bzzr:/nonhash",
+ }
+
+ nonhashresponses := []string{
+ "error resolving name: 'name' does not resolve: no DNS to resolve name but is not a content hash\n",
+ "error resolving nonhash: 'nonhash' is not a content hash\n",
+ "error resolving nonhash: 'nonhash' does not resolve: no DNS to resolve name but is not a content hash\n",
+ }
+
+ for i, url := range nonhashtests {
+ var resp *http.Response
+ var respbody []byte
+
+ resp, err = http.Get(url)
+
+ if err != nil {
+ t.Fatalf("Request failed: %v", err)
+ }
+ defer resp.Body.Close()
+ respbody, err = ioutil.ReadAll(resp.Body)
+ if string(respbody) != nonhashresponses[i] {
+ t.Fatalf("Non-Hash response body does not match, expected: %v, got: %v", nonhashresponses[i], string(respbody))
+ }
+ }
+
}