Search in sources :

Example 1 with PgConfigReview

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

the class PgConfigDefaultValuesMutatorTest method getEmptyReview.

@Override
protected PgConfigReview getEmptyReview() {
    PgConfigReview review = JsonUtil.readFromJson("pgconfig_allow_request/valid_pgconfig.json", PgConfigReview.class);
    review.getRequest().getObject().getSpec().setPostgresqlConf(new HashMap<>());
    return review;
}
Also used : PgConfigReview(io.stackgres.operator.common.PgConfigReview)

Example 2 with PgConfigReview

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

the class BlocklistValidatorTest method givenValidConfigurationUpdate_shouldNotFail.

@Test
void givenValidConfigurationUpdate_shouldNotFail() throws ValidationFailed {
    PgConfigReview review = JsonUtil.readFromJson("pgconfig_allow_request/valid_pgconfig_update.json", PgConfigReview.class);
    validator.validate(review);
}
Also used : PgConfigReview(io.stackgres.operator.common.PgConfigReview) Test(org.junit.jupiter.api.Test)

Example 3 with PgConfigReview

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

the class BlocklistValidatorTest method givenUpdateWithBlocklistedProperties_shouldFail.

@Test
void givenUpdateWithBlocklistedProperties_shouldFail() {
    PgConfigReview review = JsonUtil.readFromJson("pgconfig_allow_request/valid_pgconfig_update.json", PgConfigReview.class);
    StackGresPostgresConfig pgConfig = review.getRequest().getObject();
    String[] blocklistedProperties = addBlocklistProperties(pgConfig);
    assertThrows(ValidationFailed.class, () -> {
        validator.validate(review);
    });
    ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
        validator.validate(review);
    });
    String errorMessage = ex.getResult().getMessage();
    assertEquals("Invalid postgres configuration, properties: " + String.join(", ", blocklistedProperties) + " cannot be settled", errorMessage);
}
Also used : PgConfigReview(io.stackgres.operator.common.PgConfigReview) ValidationFailed(io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) Test(org.junit.jupiter.api.Test)

Example 4 with PgConfigReview

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

the class PgConfigConstraintValidatorTest method getInvalidReview.

@Override
protected PgConfigReview getInvalidReview() {
    final PgConfigReview review = JsonUtil.readFromJson("pgconfig_allow_request/valid_pgconfig_update.json", PgConfigReview.class);
    review.getRequest().getObject().setSpec(null);
    return review;
}
Also used : PgConfigReview(io.stackgres.operator.common.PgConfigReview)

Example 5 with PgConfigReview

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

the class BlocklistValidatorTest method givenCreationWithBlocklistedProperties_shouldFail.

@Test
void givenCreationWithBlocklistedProperties_shouldFail() {
    PgConfigReview review = JsonUtil.readFromJson("pgconfig_allow_request/valid_pgconfig.json", PgConfigReview.class);
    StackGresPostgresConfig pgConfig = review.getRequest().getObject();
    String[] blocklistedProperties = addBlocklistProperties(pgConfig);
    ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
        validator.validate(review);
    });
    String errorMessage = ex.getResult().getMessage();
    assertEquals("Invalid postgres configuration, properties: " + String.join(", ", blocklistedProperties) + " cannot be settled", errorMessage);
}
Also used : PgConfigReview(io.stackgres.operator.common.PgConfigReview) ValidationFailed(io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) Test(org.junit.jupiter.api.Test)

Aggregations

PgConfigReview (io.stackgres.operator.common.PgConfigReview)11 Test (org.junit.jupiter.api.Test)7 StackGresPostgresConfig (io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig)2 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)2 ValidationFailed (io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed)2