@@ -2,7 +2,7 @@ package opaauthorizerequest
2
2
3
3
import (
4
4
"fmt"
5
- opasdktest "github.com/open-policy-agent/opa/sdk/test"
5
+ opasdktest "github.com/open-policy-agent/opa/v1/ sdk/test"
6
6
"github.com/stretchr/testify/assert"
7
7
"github.com/stretchr/testify/require"
8
8
"github.com/zalando/skipper/eskip"
@@ -412,49 +412,51 @@ func TestAuthorizeRequestFilter(t *testing.T) {
412
412
"main.rego" : `
413
413
package envoy.authz
414
414
415
+ import rego.v1
416
+
415
417
default allow := false
416
418
default deny_with_query := false
417
419
418
- allow {
420
+ allow if {
419
421
input.parsed_path == [ "allow" ]
420
422
input.parsed_query == {}
421
423
}
422
424
423
- allow_with_http_path {
425
+ allow_with_http_path if {
424
426
input.attributes.request.http.path == "/some/api/path?q1=v1&msg=help%20me"
425
427
}
426
428
427
- allow_with_space_in_path {
429
+ allow_with_space_in_path if {
428
430
input.parsed_path == [ "my path" ]
429
431
}
430
432
431
- allow_with_path_having_empty_query {
433
+ allow_with_path_having_empty_query if {
432
434
input.parsed_path == [ "path-with-empty-query" ]
433
435
input.parsed_query == {}
434
436
}
435
437
436
- allow_with_query {
438
+ allow_with_query if {
437
439
input.parsed_path == [ "allow-with-query" ]
438
440
input.parsed_query.pass == ["yes"]
439
441
input.parsed_query.id == ["1", "2"]
440
442
input.parsed_query.msg == ["help me"]
441
443
}
442
444
443
- deny_with_query {
445
+ deny_with_query if {
444
446
input.attributes.request.http.path == "/allow-me?tofail=true"
445
447
not input.parsed_query.tofail == ["true"]
446
448
}
447
449
448
- allow_with_path_having_fragment {
450
+ allow_with_path_having_fragment if {
449
451
input.parsed_path == [ "path-with-empty-query" ]
450
452
input.attributes.request.http.path == "/path-with-empty-query"
451
453
}
452
454
453
- allow_context_extensions {
455
+ allow_context_extensions if {
454
456
input.attributes.contextExtensions["com.mycompany.myprop"] == "myvalue"
455
457
}
456
458
457
- allow_runtime_environment {
459
+ allow_runtime_environment if {
458
460
opa.runtime().config.labels.environment == "test"
459
461
}
460
462
@@ -465,7 +467,7 @@ func TestAuthorizeRequestFilter(t *testing.T) {
465
467
"http_status": 401
466
468
}
467
469
468
- allow_object := response {
470
+ allow_object := response if {
469
471
input.parsed_path == [ "allow", "structured" ]
470
472
response := {
471
473
"allowed": true,
@@ -497,13 +499,13 @@ func TestAuthorizeRequestFilter(t *testing.T) {
497
499
498
500
default allow_body := false
499
501
500
- allow_body {
502
+ allow_body if {
501
503
input.parsed_body.target_id == "123456"
502
504
}
503
505
504
506
decision_id := input.attributes.metadataContext.filterMetadata.open_policy_agent.decision_id
505
507
506
- allow_object_decision_id_in_header := response {
508
+ allow_object_decision_id_in_header := response if {
507
509
input.parsed_path = ["allow", "structured"]
508
510
decision_id
509
511
response := {
@@ -663,9 +665,11 @@ func TestAuthorizeRequestInputContract(t *testing.T) {
663
665
"main.rego" : `
664
666
package envoy.authz
665
667
668
+ import rego.v1
669
+
666
670
default allow = false
667
671
668
- allow {
672
+ allow if {
669
673
input.attributes.request.http.path == "/users/profile/amal?param=1"
670
674
input.parsed_path == ["users", "profile", "amal"]
671
675
input.parsed_query == {"param": ["1"]}
0 commit comments