diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/authorization/cedar_authorizer_test.rs | 18 | ||||
| -rw-r--r-- | tests/authorization/check_service_test.rs | 4 |
2 files changed, 12 insertions, 10 deletions
diff --git a/tests/authorization/cedar_authorizer_test.rs b/tests/authorization/cedar_authorizer_test.rs index 317ef67f..ccf8a1f8 100644 --- a/tests/authorization/cedar_authorizer_test.rs +++ b/tests/authorization/cedar_authorizer_test.rs @@ -5,16 +5,18 @@ mod tests { use envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest; use std::collections::HashMap; + fn subject() -> authzd::CedarAuthorizer { + build_cedar_authorizer() + } + #[test] fn test_cedar_authorizer_allows_valid_token() { - let request = build_request(|item: &mut HttpRequest| { + assert!(subject().authorize(build_request(|item: &mut HttpRequest| { item.headers = build_headers(vec![( "authorization".to_string(), "Bearer valid-token".to_string(), )]); - }); - - assert!(build_cedar_authorizer().authorize(request)); + }))); } #[test] @@ -26,7 +28,7 @@ mod tests { )]); }); - assert!(!build_cedar_authorizer().authorize(request)); + assert!(!subject().authorize(request)); } #[test] @@ -35,7 +37,7 @@ mod tests { item.headers = HashMap::new(); }); - assert!(!build_cedar_authorizer().authorize(request)); + assert!(!subject().authorize(request)); } #[test] @@ -55,7 +57,7 @@ mod tests { ]); }); - assert!(build_cedar_authorizer().authorize(request)); + assert!(subject().authorize(request)); } #[test] @@ -75,6 +77,6 @@ mod tests { ]); }); - assert!(build_cedar_authorizer().authorize(request)); + assert!(subject().authorize(request)); } } diff --git a/tests/authorization/check_service_test.rs b/tests/authorization/check_service_test.rs index 5ea0cb95..a32f2a2c 100644 --- a/tests/authorization/check_service_test.rs +++ b/tests/authorization/check_service_test.rs @@ -224,13 +224,13 @@ mod tests { "GET", "/dashboard", "sparkle.staging.runway.gitlab.net", - tonic::Code::PermissionDenied, + tonic::Code::Unauthenticated, ), ( "POST", "/sparkles", "sparkle.staging.runway.gitlab.net", - tonic::Code::PermissionDenied, + tonic::Code::Unauthenticated, ), ]; |
