Commit Graph

2 Commits

Author SHA1 Message Date
Mohamed Awnallah 368b4b171d pkg/webhook: refactor propagation policy
In this commit, we refactor propagation policy names and check
on number of patches the mutation happens.

Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
2024-09-13 09:56:50 +03:00
Mohamed Awnallah e2a3f5942c pkg/webhook: test PropagationPolicy
In this commit, we introduce unit tests for both the `ValidatingAdmission`
and `MutatingAdmission` webhooks for the `PropagationPolicy` resource.

The tests include:

- Validation webhook tests:
  - Tests how the webhook responds when decoding the request object fails.
  - Ensures that updates to the `SchedulerName` field are denied, as it should remain immutable.
  - Validates that changes to the `PropagationPolicyPermanentIDLabel` label and its absence in creation requests are correctly handled.
  - Confirms that valid `PropagationPolicy` objects are allowed through without errors.

- Mutation webhook tests:
  - Handles decode errors and denies admission when decoding fails.
  - Provides full coverage of policy mutation with default values and patch application.

Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
2024-09-10 06:39:20 +03:00