Skip to content

Commit

Permalink
add tests max payload size to proxy_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
sigua-cs committed Sep 7, 2022
1 parent c65a989 commit 3afaba7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/tls"
"fmt"
"github.com/contentsquare/chproxy/cache"
"io"
"math/rand"
"net"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3afaba7

Please sign in to comment.