karmada/pkg/webhook/resourcedeletionprotection
Mohamed Awnallah fa4a077865 pkg: test ResourceDeletionProtection valid webhook
In this commit, we add unit tests for the `ValidatingAdmission` validation webhook
specifically for the resource deletion protection feature. These tests ensure
that the webhook correctly handles various admission scenarios:

- Tests the behavior when decoding the request object fails, verifying that admission
is denied with an appropriate error message.
- Ensures that resources labeled with `DeletionProtectionAlways` are denied deletion,
validating that the error message is returned.
- Confirms that resources without the deletion protection label are allowed to be deleted
without errors.
- Validates that resources with other labels are not impacted and are allowed to be deleted.
- Confirms that non-delete operations (e.g., create) are allowed by default.

Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
2024-09-09 03:56:52 +03:00
..
validating.go Adopt controller-runtime braking changes: generics support PR2783 2024-07-13 16:49:01 +08:00
validating_test.go pkg: test ResourceDeletionProtection valid webhook 2024-09-09 03:56:52 +03:00