From 3afaba78fbfd1ddfd2258c3d57f6ed41c2486f63 Mon Sep 17 00:00:00 2001 From: sigua-cs Date: Wed, 7 Sep 2022 22:38:45 +0300 Subject: [PATCH] add tests max payload size to proxy_test.go --- proxy_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/proxy_test.go b/proxy_test.go index bc97639d..6015ee7b 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/tls" "fmt" + "github.com/contentsquare/chproxy/cache" "io" "math/rand" "net" @@ -249,6 +250,19 @@ func TestReverseProxy_ServeHTTP1(t *testing.T) { return makeRequest(p) }, }, + { + cfg: goodCfg, + name: "max payload size limit", + expResponse: okResponse, + expStatusCode: http.StatusOK, + f: func(p *reverseProxy) *http.Response { + p.caches["max_payload_size"] = &cache.AsyncCache{ + MaxPayloadSize: 8 * 1024 * 1024, + } + p.users["default"].cache = p.caches["max_payload_size"] + return makeRequest(p) + }, + }, { cfg: goodCfg, name: "queue overflow for user", @@ -397,6 +411,21 @@ func TestReverseProxy_ServeHTTP1(t *testing.T) { return makeCustomRequest(p, req) }, }, + { + cfg: authCfg, + name: "post request max payload size", + expResponse: okResponse, + expStatusCode: http.StatusOK, + f: func(p *reverseProxy) *http.Response { + uri := fmt.Sprintf("%s?user=foo&password=bar", fakeServer.URL) + req := httptest.NewRequest("POST", uri, nil) + p.caches["max_payload_size"] = &cache.AsyncCache{ + MaxPayloadSize: 8 * 1024 * 1024, + } + p.users["foo"].cache = p.caches["max_payload_size"] + return makeCustomRequest(p, req) + }, + }, } for _, tc := range testCases {