Unit testing istio AuthorizationPolicy?

Hello,

AuthorizationPolic-ies carry a non-negligible complexity. Does anyone has a good approach to write unit tests to validate their behavior?

Ideally, I’m looking to write unit tests that would look like:

policy = istio.load_policy("authz-policy.yaml")
policy.when(Request(
    method="POST",
    path="/etc/blah/foo",
    source="cluster.ns.local/sa/my-microservice-sa",
    headers={'My-Header': 'foo'})
).then(expectResponse(HTTP_UNAUTHORIZED))

Any input welcome!
Thanks

1 Like