mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-28 14:45:49 +08:00
matchers: query
now ANDs multiple keys (#6054)
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
This commit is contained in:
@ -763,6 +763,42 @@ func TestQueryMatcher(t *testing.T) {
|
||||
input: "/?somekey=1",
|
||||
expect: true,
|
||||
},
|
||||
{
|
||||
scenario: "do not match when not all query params are present",
|
||||
match: MatchQuery{"debug": []string{"1"}, "foo": []string{"bar"}},
|
||||
input: "/?debug=1",
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
scenario: "match when all query params are present",
|
||||
match: MatchQuery{"debug": []string{"1"}, "foo": []string{"bar"}},
|
||||
input: "/?debug=1&foo=bar",
|
||||
expect: true,
|
||||
},
|
||||
{
|
||||
scenario: "do not match when the value of a query param does not match",
|
||||
match: MatchQuery{"debug": []string{"1"}, "foo": []string{"bar"}},
|
||||
input: "/?debug=2&foo=bar",
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
scenario: "do not match when all the values the query params do not match",
|
||||
match: MatchQuery{"debug": []string{"1"}, "foo": []string{"bar"}},
|
||||
input: "/?debug=2&foo=baz",
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
scenario: "match against two values for the same key",
|
||||
match: MatchQuery{"debug": []string{"1"}},
|
||||
input: "/?debug=1&debug=2",
|
||||
expect: true,
|
||||
},
|
||||
{
|
||||
scenario: "match against two values for the same key",
|
||||
match: MatchQuery{"debug": []string{"2", "1"}},
|
||||
input: "/?debug=2&debug=1",
|
||||
expect: true,
|
||||
},
|
||||
} {
|
||||
|
||||
u, _ := url.Parse(tc.input)
|
||||
|
Reference in New Issue
Block a user