integration: add test for query string params (#3302)

This commit is contained in:
Caleb Doxsey 2022-04-28 19:42:23 +00:00 committed by GitHub
parent 2e1366c417
commit 820be99a2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@ import (
"encoding/json"
"io"
"net/http"
"net/url"
"testing"
"time"
@ -15,6 +16,42 @@ import (
"github.com/pomerium/pomerium/integration/flows"
)
func TestQueryStringParams(t *testing.T) {
ctx := context.Background()
ctx, clearTimeout := context.WithTimeout(ctx, time.Second*30)
defer clearTimeout()
qs := url.Values{
"q1": {"a&b&c"},
"q2": {"x?y?z"},
}
req, err := http.NewRequestWithContext(ctx, "GET", "https://httpdetails.localhost.pomerium.io/?"+qs.Encode(), nil)
if err != nil {
t.Fatal(err)
}
res, err := getClient().Do(req)
if !assert.NoError(t, err, "unexpected http error") {
return
}
defer res.Body.Close()
var result struct {
Query map[string]string
}
err = json.NewDecoder(res.Body).Decode(&result)
if !assert.NoError(t, err) {
return
}
assert.Equal(t, map[string]string{
"q1": "a&b&c",
"q2": "x?y?z",
}, result.Query,
"expected custom request header to be sent upstream")
}
func TestCORS(t *testing.T) {
if ClusterType == "traefik" || ClusterType == "nginx" {
t.Skip()