mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-14 16:52:58 +02:00
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:
parent
54ec88fb93
commit
2d04106e6d
13 changed files with 257 additions and 18 deletions
32
pkg/policy/criteria/http_method_test.go
Normal file
32
pkg/policy/criteria/http_method_test.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package criteria
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestHTTPMethod(t *testing.T) {
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
res, err := evaluate(t, `
|
||||
allow:
|
||||
and:
|
||||
- http_method:
|
||||
is: GET
|
||||
`, []dataBrokerRecord{}, Input{HTTP: InputHTTP{Method: "GET"}})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, A{true, A{ReasonHTTPMethodOK}, M{}}, res["allow"])
|
||||
require.Equal(t, A{false, A{}}, res["deny"])
|
||||
})
|
||||
t.Run("unauthorized", func(t *testing.T) {
|
||||
res, err := evaluate(t, `
|
||||
allow:
|
||||
and:
|
||||
- http_method:
|
||||
is: GET
|
||||
`, []dataBrokerRecord{}, Input{HTTP: InputHTTP{Method: "POST"}})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, A{false, A{ReasonHTTPMethodUnauthorized}, M{}}, res["allow"])
|
||||
require.Equal(t, A{false, A{}}, res["deny"])
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue