In this commit, we introduce unit tests for the `MutatingAdmission`
webhook that mutates the `ClusterResourceBinding` resource. These tests
ensure correct behavior for various mutation scenarios and improve coverage:
- Testing the handling of decode errors and ensuring that admission is denied
when decoding fails.
- Full coverage testing of policy mutation, including setting default UUID
labels for the `ClusterResourceBinding`.
- Verifying that only the expected patch for the UUID label is applied, ensuring
no other unnecessary mutations.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we introduce unit tests for the `MutatingAdmission`
webhook that mutates the `ResourceBinding` resource. These tests ensure
correct behavior for various mutation scenarios and improve coverage:
- Testing the handling of decode errors and ensuring that admission
is denied when decoding fails.
- Full coverage testing of policy mutation, including setting default
UUID labels for the `ResourceBinding`.
- Verifying that only the expected patch for the UUID label is applied,
ensuring no other unnecessary mutations.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we introduce unit tests for both the `ValidationAdmission`
and `MutatingAdmission` webhooks specifically for the `OverridePolicy` resource.
- Validation webhook tests:
- Tests the behavior when decoding the request object fails, verifying
that admission is denied with an appropriate error message.
- Validates that the webhook denies admission when encountering invalid
label values in the `OverridePolicy` spec, ensuring proper error messaging.
- Confirms that valid `OverridePolicy` objects are admitted without errors.
- Mutation webhook tests:
- Handles decode errors and denies admission when decoding fails.
- Provides full coverage of policy mutation, including setting default
namespaces and validating no unnecessary patches.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we introduce unit tests for both the `ValidatingAdmission`
and `MutatingAdmission` webhooks for the `ClusterPropagationPolicy` resource.
The tests include:
- Validation webhook tests:
- Tests how the webhook responds when decoding the request object fails.
- Ensures updates to the `SchedulerName` field are denied, as it should remain immutable.
- Validates that changes to the `ClusterPropagationPolicyPermanentIDLabel` label and its absence in creation requests are correctly handled.
- Confirms that valid `ClusterPropagationPolicy` objects are allowed through without errors.
- Mutation webhook tests:
- Handles decode errors and denies admission when decoding fails.
- Provides full coverage of cluster policy mutation with default values and patch application.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
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>
Signed-off-by: Joe Nathan Abellard <contact@jabellard.com>
Initial structure
Signed-off-by: Joe Nathan Abellard <contact@jabellard.com>
Update api
Signed-off-by: Joe Nathan Abellard <contact@jabellard.com>
Update api
Signed-off-by: Joe Nathan Abellard <contact@jabellard.com>
In this commit, we introduce unit tests for the `MutatingAdmission`
webhook specifically for the `Work` resource. The mutation webhook
tests include the following:
- Handles decode errors and denies admission when decoding fails.
- Provides full coverage of policy mutation, including setting default
and validating no unnecessary patches.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we introduce unit tests for both the `ValidationAdmission`
and `MutatingAdmission` webooks specifically for the `MultiClusterService` resource.
- Validation webhook tests:
- Tests the behavior when decoding the request object fails, verifying
that admission is denied with an appropriate error message.
- Validates that the webhook denies admission when encountering invalid
values in the `MultiClusterService` spec, ensuring error messaging.
- Confirms that valid `MultiClusterService` objects are admitted without errors.
- Mutation webhook tests:
- Handles decode errors and denies admission when decoding fails.
- Provides full coverage of `MultiClusterService` object mutation,
including setting default namespaces and validating no unnecessary patches.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
In this commit, we log the mutating handlers for `OverridePolicy`,
`ClusterPropagationPolicy`, and `MultiClusterService`. Specifically, it logs
information about the mutation of these resources, including the namespace,
name, and the operation type from the admission request.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
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>
In this commit, we introduce unit tests for both the `MutatingAdmission`
and `ValidatingAdmission` webhooks specifically for the `FederatedHPA`
resource.
The tests include:
- Validation webhook tests:
- Verifies that admission is denied with an appropriate error message
when decoding the request object fails.
- Ensures admission is denied when the `FederatedHPA` spec contains
invalid values, such as a `minReplicas` set to zero, and the correct
error message is returned.
- Confirms that a valid `FederatedHPA` object is allowed through without
errors.
- Mutation webhook tests:
- Verifies that admission is denied when decoding the request object
fails, returning the appropriate error message.
- Ensures that the `FederatedHPA` object is correctly mutated when
provided with default values, including scale policies and CPU
utilization.
- Confirms that no patches are applied when the `FederatedHPA` object is
handled correctly and that admission is allowed for valid
`FederatedHPA` objects.
Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>