From b74f35b07862c7d7ddd6dd0c99036416bbaa8e03 Mon Sep 17 00:00:00 2001 From: Balint Gabor Date: Tue, 10 Apr 2018 14:09:05 +0200 Subject: [PATCH] swarm/api: Added encrypted test cases --- swarm/api/client/client_test.go | 20 ++++++++++++++++++-- swarm/api/http/server_test.go | 9 ++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/swarm/api/client/client_test.go b/swarm/api/client/client_test.go index fb053ad662..dd5efabd1a 100644 --- a/swarm/api/client/client_test.go +++ b/swarm/api/client/client_test.go @@ -61,6 +61,14 @@ func TestClientUploadDownloadRaw(t *testing.T) { // TestClientUploadDownloadFiles test uploading and downloading files to swarm // manifests func TestClientUploadDownloadFiles(t *testing.T) { + testClientUploadDownloadFiles(false, t) +} + +func TestClientUploadDownloadFilesEncrypted(t *testing.T) { + testClientUploadDownloadFiles(true, t) +} + +func testClientUploadDownloadFiles(toEncrypt bool, t *testing.T) { srv := testutil.NewTestSwarmServer(t) defer srv.Close() @@ -74,7 +82,7 @@ func TestClientUploadDownloadFiles(t *testing.T) { Size: int64(len(data)), }, } - hash, err := client.Upload(file, manifest, false) + hash, err := client.Upload(file, manifest, toEncrypt) if err != nil { t.Fatal(err) } @@ -217,6 +225,14 @@ func TestClientUploadDownloadDirectory(t *testing.T) { // TestClientFileList tests listing files in a swarm manifest func TestClientFileList(t *testing.T) { + testClientFileList(false, t) +} + +func TestClientFileListEncrypted(t *testing.T) { + testClientFileList(true, t) +} + +func testClientFileList(toEncrypt bool, t *testing.T) { srv := testutil.NewTestSwarmServer(t) defer srv.Close() @@ -224,7 +240,7 @@ func TestClientFileList(t *testing.T) { defer os.RemoveAll(dir) client := NewClient(srv.URL) - hash, err := client.UploadDirectory(dir, "", "", false) + hash, err := client.UploadDirectory(dir, "", "", toEncrypt) if err != nil { t.Fatalf("error uploading directory: %s", err) } diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go index 78a2c77c68..01ed796f8b 100644 --- a/swarm/api/http/server_test.go +++ b/swarm/api/http/server_test.go @@ -458,6 +458,13 @@ func testBzzGetPath(encrypted bool, t *testing.T) { // a trailing slash gets redirected to include the trailing slash so that // relative URLs work as expected. func TestBzzRootRedirect(t *testing.T) { + testBzzRootRedirect(false, t) +} +func TestBzzRootRedirectEncrypted(t *testing.T) { + testBzzRootRedirect(true, t) +} + +func testBzzRootRedirect(toEncrypt bool, t *testing.T) { srv := testutil.NewTestSwarmServer(t) defer srv.Close() @@ -472,7 +479,7 @@ func TestBzzRootRedirect(t *testing.T) { Size: int64(len(data)), }, } - hash, err := client.Upload(file, "", false) + hash, err := client.Upload(file, "", toEncrypt) if err != nil { t.Fatal(err) }