From fbb53e167c4cd18993c7ead459cb82557d192b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Levente=20T=C3=B3th?= Date: Mon, 18 Dec 2023 23:37:05 +0100 Subject: [PATCH] test: bzz api --- pkg/api/bzz_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/api/bzz_test.go b/pkg/api/bzz_test.go index e6d52d8acd3..d2ad44e507c 100644 --- a/pkg/api/bzz_test.go +++ b/pkg/api/bzz_test.go @@ -187,6 +187,28 @@ func TestBzzFiles(t *testing.T) { ) }) + t.Run("redundancy", func(t *testing.T) { + fileName := "my-pictures.jpeg" + + var resp api.BzzUploadResponse + jsonhttptest.Request(t, client, http.MethodPost, fileUploadResource+"?name="+fileName, http.StatusCreated, + jsonhttptest.WithRequestHeader(api.SwarmDeferredUploadHeader, "true"), + jsonhttptest.WithRequestHeader(api.SwarmPostageBatchIdHeader, batchOkStr), + jsonhttptest.WithRequestBody(bytes.NewReader(simpleData)), + jsonhttptest.WithRequestHeader(api.SwarmEncryptHeader, "True"), + jsonhttptest.WithRequestHeader(api.SwarmRedundancyLevelHeader, "4"), + jsonhttptest.WithRequestHeader(api.ContentTypeHeader, "image/jpeg; charset=utf-8"), + jsonhttptest.WithUnmarshalJSONResponse(&resp), + ) + + jsonhttptest.Request(t, client, http.MethodGet, fileDownloadResource(resp.Reference.String()), http.StatusOK, + jsonhttptest.WithExpectedContentLength(len(simpleData)), + jsonhttptest.WithExpectedResponseHeader(api.ContentTypeHeader, "image/jpeg; charset=utf-8"), + jsonhttptest.WithExpectedResponseHeader(api.ContentDispositionHeader, fmt.Sprintf(`inline; filename="%s"`, fileName)), + jsonhttptest.WithExpectedResponse(simpleData), + ) + }) + t.Run("filter out filename path", func(t *testing.T) { fileName := "my-pictures.jpeg" fileNameWithPath := "../../" + fileName