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

Refactor policy validation on create and update, including tests #824

Open
viccuad opened this issue Jul 23, 2024 · 0 comments
Open

Refactor policy validation on create and update, including tests #824

viccuad opened this issue Jul 23, 2024 · 0 comments

Comments

@viccuad
Copy link
Member

viccuad commented Jul 23, 2024

We need to refactor and cleanup webhooks validation, as we realized that we could increase readability and test coverage

Acceptance criteria

  • The file api/policies/v1/policy_validation_matchconditions.go was copy-pasted from k8s.io/kubernetes (see license, copyright, comment at its beginning). We tried to import as-is, but it makes more sense to own it instead. For that:
    • Enable linter in the file (check golangci-lint.yml).
    • Consider moving its functions into api/policies/v1/policy_validation.go and perform any cleanup necessary.
  • Factories should be refactored with the builder pattern.
  • Add integration tests for the webhooks methods: ValidateCreate, ValidateDelete, and ValidateUpdate.
    ATM We test each validator in isolation (see policy_validation_test.go), however, we do not test that the validators are correctly integrated into the webhooks. We could for instance add just a couple of test cases: one with a valid resource and one with a resource that all fields in an invalid state, so that we are sure we are passing through the right validators.
@viccuad viccuad modified the milestone: 1.18 Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant