Search in sources :

Example 31 with BackupConfigReview

use of io.stackgres.operator.common.BackupConfigReview in project stackgres by ongres.

the class BackupConfigConstraintValidationTest method givenStorageClass_shouldFail.

@ParameterizedTest
@ValueSource(strings = { "DEMO", "STANDARDIA", "reduced_redundancy" })
void givenStorageClass_shouldFail(String storageClass) {
    BackupConfigReview review = JsonUtil.readFromJson("backupconfig_allow_request/update.json", BackupConfigReview.class);
    review.getRequest().getObject().getSpec().getStorage().getS3Compatible().setStorageClass(storageClass);
    ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
        validator.validate(review);
    });
    String errorMessage = ex.getResult().getMessage();
    assertEquals("SGBackupConfig has invalid properties. " + "storageClass must be one of STANDARD, STANDARD_IA or REDUCED_REDUNDANCY.", errorMessage);
}
Also used : ValidationFailed(io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed) BackupConfigReview(io.stackgres.operator.common.BackupConfigReview) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BackupConfigReview (io.stackgres.operator.common.BackupConfigReview)31 Test (org.junit.jupiter.api.Test)25 ValidationFailed (io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed)17 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)4 JsonPatchOperation (com.github.fge.jsonpatch.JsonPatchOperation)1 StackGresBackupConfigSpec (io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfigSpec)1 AwsS3Storage (io.stackgres.common.crd.storages.AwsS3Storage)1 BackupStorage (io.stackgres.common.crd.storages.BackupStorage)1 DefaultValuesMutatorTest (io.stackgres.operator.mutation.DefaultValuesMutatorTest)1 Random (java.util.Random)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1