ppl: add support for http_path and http_method (#2813)

* ppl: add support for http_path and http_method

* fix import ordering
This commit is contained in:
Caleb Doxsey 2021-12-10 07:28:51 -07:00 committed by GitHub
parent 54ec88fb93
commit 2d04106e6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 257 additions and 18 deletions

View file

@ -90,15 +90,15 @@ func Test_getEvaluatorRequest(t *testing.T) {
Session: evaluator.RequestSession{
ID: "SESSION_ID",
},
HTTP: evaluator.RequestHTTP{
Method: "GET",
URL: "http://example.com/some/path?qs=1",
Headers: map[string]string{
HTTP: evaluator.NewRequestHTTP(
"GET",
mustParseURL("http://example.com/some/path?qs=1"),
map[string]string{
"Accept": "text/html",
"X-Forwarded-Proto": "https",
},
ClientCertificate: certPEM,
},
certPEM,
),
}
assert.Equal(t, expect, actual)
}
@ -296,15 +296,15 @@ func Test_getEvaluatorRequestWithPortInHostHeader(t *testing.T) {
expect := &evaluator.Request{
Policy: &a.currentOptions.Load().Policies[0],
Session: evaluator.RequestSession{},
HTTP: evaluator.RequestHTTP{
Method: "GET",
URL: "http://example.com/some/path?qs=1",
Headers: map[string]string{
HTTP: evaluator.NewRequestHTTP(
"GET",
mustParseURL("http://example.com/some/path?qs=1"),
map[string]string{
"Accept": "text/html",
"X-Forwarded-Proto": "https",
},
ClientCertificate: certPEM,
},
certPEM,
),
}
assert.Equal(t, expect, actual)
}
@ -414,3 +414,11 @@ func TestAuthorize_Check(t *testing.T) {
})
}
}
func mustParseURL(rawURL string) url.URL {
u, err := url.Parse(rawURL)
if err != nil {
panic(err)
}
return *u
}