fix #636: review nitpicks
License: MIT Signed-off-by: Alexey Novikov <alexey@novikov.io>
This commit is contained in:
parent
53d624e701
commit
a586548e62
|
@ -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"
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user