Search in sources :

Example 6 with SecretKeySelector

use of io.stackgres.common.crd.SecretKeySelector in project stackgres by ongres.

the class ClusterConstraintValidatorTest method validScriptFromConfigMapAndSecret_shouldFail.

@Test
void validScriptFromConfigMapAndSecret_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().setInitData(new StackGresClusterInitData());
    review.getRequest().getObject().getSpec().getInitData().setScripts(new ArrayList<>());
    review.getRequest().getObject().getSpec().getInitData().getScripts().add(new StackGresClusterScriptEntry());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).setScriptFrom(new StackGresClusterScriptFrom());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().setConfigMapKeyRef(new ConfigMapKeySelector());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getConfigMapKeyRef().setName("test");
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getConfigMapKeyRef().setKey("test");
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().setSecretKeyRef(new SecretKeySelector());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getSecretKeyRef().setName("test");
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getSecretKeyRef().setKey("test");
    checkErrorCause(StackGresClusterScriptFrom.class, new String[] { "spec.initData.scripts[0].scriptFrom.secretKeyRef", "spec.initData.scripts[0].scriptFrom.configMapKeyRef" }, "isSecretKeySelectorAndConfigMapKeySelectorMutuallyExclusiveAndRequired", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterScriptEntry(io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry) StackGresClusterInitData(io.stackgres.common.crd.sgcluster.StackGresClusterInitData) StackGresClusterScriptFrom(io.stackgres.common.crd.sgcluster.StackGresClusterScriptFrom) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) ConfigMapKeySelector(io.stackgres.common.crd.ConfigMapKeySelector) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with SecretKeySelector

use of io.stackgres.common.crd.SecretKeySelector in project stackgres by ongres.

the class ClusterConstraintValidatorTest method scriptFromSecretWithEmptyKey_shouldFail.

@Test
void scriptFromSecretWithEmptyKey_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().setInitData(new StackGresClusterInitData());
    review.getRequest().getObject().getSpec().getInitData().setScripts(new ArrayList<>());
    review.getRequest().getObject().getSpec().getInitData().getScripts().add(new StackGresClusterScriptEntry());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).setScriptFrom(new StackGresClusterScriptFrom());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().setSecretKeyRef(new SecretKeySelector());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getSecretKeyRef().setName("test");
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getSecretKeyRef().setKey("");
    checkErrorCause(SecretKeySelector.class, "spec.initData.scripts[0].scriptFrom.secretKeyRef.key", "isKeyNotEmpty", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterScriptEntry(io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry) StackGresClusterInitData(io.stackgres.common.crd.sgcluster.StackGresClusterInitData) StackGresClusterScriptFrom(io.stackgres.common.crd.sgcluster.StackGresClusterScriptFrom) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with SecretKeySelector

use of io.stackgres.common.crd.SecretKeySelector in project stackgres by ongres.

the class ClusterConstraintValidatorTest method sslPrivateKeySecretWithEmptyName_shouldFail.

@Test
void sslPrivateKeySecretWithEmptyName_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPostgres().setSsl(new StackGresClusterSsl());
    review.getRequest().getObject().getSpec().getPostgres().getSsl().setEnabled(true);
    review.getRequest().getObject().getSpec().getPostgres().getSsl().setCertificateSecretKeySelector(new SecretKeySelector("test", "test"));
    review.getRequest().getObject().getSpec().getPostgres().getSsl().setPrivateKeySecretKeySelector(new SecretKeySelector("test", null));
    checkErrorCause(SecretKeySelector.class, "spec.postgres.ssl.privateKeySecretKeySelector.name", "isNameNotEmpty", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterSsl(io.stackgres.common.crd.sgcluster.StackGresClusterSsl) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with SecretKeySelector

use of io.stackgres.common.crd.SecretKeySelector in project stackgres by ongres.

the class ClusterConstraintValidatorTest method scriptFromSecretWithEmptyName_shouldFail.

@Test
void scriptFromSecretWithEmptyName_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().setInitData(new StackGresClusterInitData());
    review.getRequest().getObject().getSpec().getInitData().setScripts(new ArrayList<>());
    review.getRequest().getObject().getSpec().getInitData().getScripts().add(new StackGresClusterScriptEntry());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).setScriptFrom(new StackGresClusterScriptFrom());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().setSecretKeyRef(new SecretKeySelector());
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getSecretKeyRef().setName("");
    review.getRequest().getObject().getSpec().getInitData().getScripts().get(0).getScriptFrom().getSecretKeyRef().setKey("test");
    checkErrorCause(SecretKeySelector.class, "spec.initData.scripts[0].scriptFrom.secretKeyRef.name", "isNameNotEmpty", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterScriptEntry(io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry) StackGresClusterInitData(io.stackgres.common.crd.sgcluster.StackGresClusterInitData) StackGresClusterScriptFrom(io.stackgres.common.crd.sgcluster.StackGresClusterScriptFrom) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with SecretKeySelector

use of io.stackgres.common.crd.SecretKeySelector in project stackgres by ongres.

the class ClusterConstraintValidatorTest method sslCertificateSecretWithEmptyName_shouldFail.

@Test
void sslCertificateSecretWithEmptyName_shouldFail() {
    StackGresClusterReview review = getValidReview();
    review.getRequest().getObject().getSpec().getPostgres().setSsl(new StackGresClusterSsl());
    review.getRequest().getObject().getSpec().getPostgres().getSsl().setEnabled(true);
    review.getRequest().getObject().getSpec().getPostgres().getSsl().setCertificateSecretKeySelector(new SecretKeySelector("test", null));
    review.getRequest().getObject().getSpec().getPostgres().getSsl().setPrivateKeySecretKeySelector(new SecretKeySelector("test", "test"));
    checkErrorCause(SecretKeySelector.class, "spec.postgres.ssl.certificateSecretKeySelector.name", "isNameNotEmpty", review, AssertTrue.class);
}
Also used : StackGresClusterReview(io.stackgres.operator.common.StackGresClusterReview) StackGresClusterSsl(io.stackgres.common.crd.sgcluster.StackGresClusterSsl) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SecretKeySelector (io.stackgres.common.crd.SecretKeySelector)21 Test (org.junit.jupiter.api.Test)12 StackGresClusterScriptFrom (io.stackgres.common.crd.sgcluster.StackGresClusterScriptFrom)9 StackGresClusterScriptEntry (io.stackgres.common.crd.sgcluster.StackGresClusterScriptEntry)8 StackGresClusterReview (io.stackgres.operator.common.StackGresClusterReview)8 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 ClusterScriptEntry (io.stackgres.apiweb.dto.cluster.ClusterScriptEntry)7 ClusterScriptFrom (io.stackgres.apiweb.dto.cluster.ClusterScriptFrom)7 StackGresClusterInitData (io.stackgres.common.crd.sgcluster.StackGresClusterInitData)5 StackGresClusterSsl (io.stackgres.common.crd.sgcluster.StackGresClusterSsl)5 Secret (io.fabric8.kubernetes.api.model.Secret)4 AwsSecretKeySelector (io.stackgres.common.crd.storages.AwsSecretKeySelector)4 AzureBlobSecretKeySelector (io.stackgres.common.crd.storages.AzureBlobSecretKeySelector)4 BackupStorage (io.stackgres.common.crd.storages.BackupStorage)4 GoogleCloudSecretKeySelector (io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector)4 Metadata (io.stackgres.apiweb.dto.Metadata)3 ConfigMapKeySelector (io.stackgres.common.crd.ConfigMapKeySelector)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2