@@ -27,13 +27,13 @@ import (
2727 "google.golang.org/protobuf/proto"
2828
2929 "github.com/open-policy-agent/opa-envoy-plugin/envoyauth"
30- "github.com/open-policy-agent/opa/ast"
31- "github.com/open-policy-agent/opa/plugins"
32- "github.com/open-policy-agent/opa/plugins/logs"
33- "github.com/open-policy-agent/opa/storage"
34- "github.com/open-policy-agent/opa/storage/inmem"
35- "github.com/open-policy-agent/opa/topdown"
36- "github.com/open-policy-agent/opa/util"
30+ "github.com/open-policy-agent/opa/v1/ ast"
31+ "github.com/open-policy-agent/opa/v1/ plugins"
32+ "github.com/open-policy-agent/opa/v1/ plugins/logs"
33+ "github.com/open-policy-agent/opa/v1/ storage"
34+ "github.com/open-policy-agent/opa/v1/ storage/inmem"
35+ "github.com/open-policy-agent/opa/v1/ topdown"
36+ "github.com/open-policy-agent/opa/v1/ util"
3737)
3838
3939const exampleAllowedRequest = `{
@@ -469,7 +469,7 @@ func TestCheckAllowWithLoggerNDBCache(t *testing.T) {
469469
470470 default allow = false
471471
472- allow {
472+ allow if {
473473 res := http.send({"url": "%s", "method": "GET"})
474474 res.status_code == 200
475475 }
@@ -952,7 +952,7 @@ func TestCheckAllowObjectDecisionWithBadReqHeadersToRemoveWithLogger(t *testing.
952952
953953 default allow = false
954954
955- allow {
955+ allow if {
956956 input.parsed_path = ["my", "test", "path"]
957957 }
958958
@@ -1150,7 +1150,7 @@ func TestCheckTwiceWithCachedBuiltinCall(t *testing.T) {
11501150 package envoy.authz
11511151
11521152 default allow = false
1153- allow {
1153+ allow if {
11541154 resp := http.send({"url": "%s", "method":"GET",
11551155 "force_cache": true, "force_cache_duration_seconds": 10})
11561156 resp.body.count == 1
@@ -1379,7 +1379,7 @@ func TestCheckAllowObjectDecisionDynamicMetadata(t *testing.T) {
13791379
13801380 default allow = false
13811381
1382- allow {
1382+ allow if {
13831383 input.parsed_path = ["my", "test", "path"]
13841384 }
13851385
@@ -1433,7 +1433,7 @@ func TestCheckAllowObjectDecisionDynamicMetadataDecisionID(t *testing.T) {
14331433
14341434 default allow = false
14351435
1436- allow {
1436+ allow if {
14371437 input.parsed_path = ["my", "test", "path"]
14381438 }
14391439
@@ -1469,7 +1469,7 @@ func TestCheckAllowBooleanDecisionDynamicMetadata(t *testing.T) {
14691469
14701470 default allow = false
14711471
1472- allow {
1472+ allow if {
14731473 input.parsed_path = ["my", "test", "path"]
14741474 }
14751475 `
@@ -1499,7 +1499,7 @@ func TestCheckAllowBooleanDecisionDynamicMetadataDecisionID(t *testing.T) {
14991499
15001500 default allow = false
15011501
1502- allow {
1502+ allow if {
15031503 input.parsed_path = ["my", "test", "path"]
15041504 }
15051505 `
@@ -1573,7 +1573,7 @@ func TestCheckAllowObjectDecisionReqHeadersToRemove(t *testing.T) {
15731573
15741574 default allow = false
15751575
1576- allow {
1576+ allow if {
15771577 input.parsed_path = ["my", "test", "path"]
15781578 }
15791579
@@ -1625,7 +1625,7 @@ func TestCheckAllowObjectDecisionResponseHeadersToAdd(t *testing.T) {
16251625
16261626 default allow = false
16271627
1628- allow {
1628+ allow if {
16291629 input.parsed_path = ["my", "test", "path"]
16301630 }
16311631
@@ -1677,7 +1677,7 @@ func TestCheckAllowObjectDecisionMultiValuedHeaders(t *testing.T) {
16771677
16781678 default allow = false
16791679
1680- allow {
1680+ allow if {
16811681 input.parsed_path = ["my", "test", "path"]
16821682 }
16831683
@@ -1976,34 +1976,34 @@ func testAuthzServer(customConfig *Config, customPluginFuncs ...customPluginFunc
19761976
19771977 default allow = false
19781978
1979- allow {
1979+ allow if {
19801980 roles_for_user[r]
19811981 required_roles[r]
19821982 }
19831983
1984- allow {
1984+ allow if {
19851985 input.parsed_path = ["my", "test", "path"]
19861986 input.parsed_query.a = ["1", "2"]
19871987 input.parsed_query.x = ["y"]
19881988 }
19891989
1990- allow {
1990+ allow if {
19911991 input.parsed_body.firstname == "foo"
19921992 input.parsed_body.lastname == "bar"
19931993 input.parsed_body.dept.it == "eng"
19941994 }
19951995
1996- roles_for_user[r] {
1996+ roles_for_user[r] if {
19971997 r := user_roles[user_name][_]
19981998 }
19991999
2000- required_roles[r] {
2000+ required_roles[r] if {
20012001 perm := role_perms[r][_]
20022002 perm.method = http_request.method
20032003 perm.path = http_request.path
20042004 }
20052005
2006- user_name = parsed {
2006+ user_name = parsed if {
20072007 [_, encoded] := split(http_request.headers.authorization, " ")
20082008 [parsed, _] := split(base64url.decode(encoded), ":")
20092009 }
@@ -2080,7 +2080,7 @@ func testAuthzServerWithObjectDecision(customConfig *Config, customPluginFuncs .
20802080 "dynamic_metadata": {"test": "foo", "bar": "baz"}
20812081 }
20822082
2083- allow = response {
2083+ allow = response if {
20842084 input.parsed_path = ["my", "test", "path"]
20852085 response := {
20862086 "allowed": true,
@@ -2098,7 +2098,7 @@ func testAuthzServerWithTruncatedBody(customConfig *Config, customPluginFuncs ..
20982098
20992099 default allow = false
21002100
2101- allow {
2101+ allow if {
21022102 not input.truncated_body
21032103 }
21042104 `
@@ -2197,7 +2197,7 @@ func TestVersionInfoInputV3(t *testing.T) {
21972197 module := `
21982198 package envoy.authz
21992199
2200- allow {
2200+ allow if {
22012201 input.version.ext_authz == "v3"
22022202 input.version.encoding == "protojson"
22032203 }
@@ -2224,7 +2224,7 @@ func TestVersionInfoInputV2(t *testing.T) {
22242224 module := `
22252225 package envoy.authz
22262226
2227- allow {
2227+ allow if {
22282228 input.version.ext_authz == "v2"
22292229 input.version.encoding == "encoding/json"
22302230 }
0 commit comments