From a586548e626373cea70bf4f09e5cbf3fd0a8cec7 Mon Sep 17 00:00:00 2001 From: Alexey Novikov Date: Mon, 11 Mar 2019 05:25:26 +0000 Subject: [PATCH] fix #636: review nitpicks License: MIT Signed-off-by: Alexey Novikov --- api/ipfsproxy/config_test.go | 4 ++-- api/rest/config_test.go | 4 ++-- api/rest/restapi_test.go | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/api/ipfsproxy/config_test.go b/api/ipfsproxy/config_test.go index c1c192de..adab4f7d 100644 --- a/api/ipfsproxy/config_test.go +++ b/api/ipfsproxy/config_test.go @@ -14,8 +14,8 @@ var cfgJSON = []byte(` "read_timeout": "10m0s", "read_header_timeout": "5s", "write_timeout": "10m0s", - "idle_timeout": "1m0s", - "max_header_bytes": 16384, + "idle_timeout": "1m0s", + "max_header_bytes": 16384, "extract_headers_extra": [], "extract_headers_path": "/api/v0/version", "extract_headers_ttl": "5m" diff --git a/api/rest/config_test.go b/api/rest/config_test.go index 4ae1cfb8..22f0cf3e 100644 --- a/api/rest/config_test.go +++ b/api/rest/config_test.go @@ -20,8 +20,8 @@ var cfgJSON = []byte(` "read_timeout": "30s", "read_header_timeout": "5s", "write_timeout": "1m0s", - "idle_timeout": "2m0s", - "max_header_bytes": 16384, + "idle_timeout": "2m0s", + "max_header_bytes": 16384, "basic_auth_credentials": null, "cors_allowed_origins": ["myorigin"], "cors_allowed_methods": ["GET"], diff --git a/api/rest/restapi_test.go b/api/rest/restapi_test.go index 7e5c8e38..23551504 100644 --- a/api/rest/restapi_test.go +++ b/api/rest/restapi_test.go @@ -1088,7 +1088,7 @@ func assertHTTPStatusIsTooLarge(resp *http.Response) error { return httpStatusCodeChecker(resp, http.StatusRequestHeaderFieldsTooLarge) } -func makeInvertedHTTPStatusAssert(checker responseChecker) responseChecker { +func makeHTTPStatusNegatedAssert(checker responseChecker) responseChecker { return func(resp *http.Response) error { if checker(resp) == nil { return fmt.Errorf("unexpected HTTP status code: %d", resp.StatusCode) @@ -1244,31 +1244,31 @@ func TestBasicAuth(t *testing.T) { method: "GET", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), - checker: makeInvertedHTTPStatusAssert(assertHTTPStatusIsUnauthoriazed), + checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, httpTestcase{ method: "POST", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), - checker: makeInvertedHTTPStatusAssert(assertHTTPStatusIsUnauthoriazed), + checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, httpTestcase{ method: "DELETE", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), - checker: makeInvertedHTTPStatusAssert(assertHTTPStatusIsUnauthoriazed), + checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, httpTestcase{ method: "BAR", path: "/foo", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), - checker: makeInvertedHTTPStatusAssert(assertHTTPStatusIsUnauthoriazed), + checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, httpTestcase{ method: "GET", path: "/id", shaper: makeBasicAuthRequestShaper(validUserName, validUserPassword), - checker: makeInvertedHTTPStatusAssert(assertHTTPStatusIsUnauthoriazed), + checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsUnauthoriazed), }, } { testBothEndpoints(t, tc.getTestFunction(rest)) @@ -1295,7 +1295,7 @@ func TestLimitMaxHeaderSize(t *testing.T) { method: "GET", path: "/foo", shaper: makeLongHeaderShaper(maxHeaderBytes / 2), - checker: makeInvertedHTTPStatusAssert(assertHTTPStatusIsTooLarge), + checker: makeHTTPStatusNegatedAssert(assertHTTPStatusIsTooLarge), }, } { testBothEndpoints(t, tc.getTestFunction(rest))