Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: help with the creation of fake requests for e2e testing of policies #640

Open
flavio opened this issue Nov 2, 2023 · 0 comments

Comments

@flavio
Copy link
Member

flavio commented Nov 2, 2023

Is your feature request related to a problem?

When testing a policy with a kwctl run, one needs to provide a pre-recorded admission request to be evaluated. The creation of this object is tedious. Currently there are two approaches:

  • Take an admission request created by someone else and change it. This is error prone
  • Use the echo policy to create a request object. This produces 100% accurate results, but it's time consuming. The user must have a Kubernetes cluster with Kubewarden running. Then deploy the echo policy with the proper configuration and then perform manually a kubernetes operation that triggers the echo policy (like creating a new object to obtain the recording of a CREATE request)

Solution you'd like

I think the majority of the policies focus on the CREATE event. I think we should prioritize a solution for that use case.

As a user, I would like to define the object about to be evaluated via a regular Kubernetes yaml definition. For example, assuming I'm writing a policy that validates PersistentVolume creation, I would write the definition of a PersistentVolume inside of a yml file. Then I would ask kwctl to fake the creation event of the resource defined inside of the file.

This is somehow similar to what the audit scanner does to create the fake evaluation requests.

Alternatives you've considered

The proposed solution describes from a really high POV what I would like to do. We have to decide whether this becomes a new dedicated kwctl subcommand or if we want to extend the run command to allow the generation of fake requests.

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants