Search in sources :

Example 11 with SecretKeySelector

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

the class ClusterConstraintValidatorTest method sslCertificateSecretNull_shouldFail.

@Test
void sslCertificateSecretNull_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().setPrivateKeySecretKeySelector(new SecretKeySelector("test", "test"));
    checkErrorCause(StackGresClusterSsl.class, "spec.postgres.ssl.certificateSecretKeySelector", "isNotEnabledCertificateSecretKeySelectorRequired", 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 12 with SecretKeySelector

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

the class BackupConfigSourceValidatorTest method setAzureBlobCredentials.

private void setAzureBlobCredentials(final BackupConfigReview review, String accountName, String accountKey, String accessKeyName, String accessKeyKey) {
    BackupStorage storage = review.getRequest().getObject().getSpec().getStorage();
    storage.setType("azureblob");
    storage.setAzureBlob(new AzureBlobStorage());
    storage.getAzureBlob().setAzureCredentials(new AzureBlobStorageCredentials());
    storage.getAzureBlob().getAzureCredentials().setSecretKeySelectors(new AzureBlobSecretKeySelector());
    AzureBlobSecretKeySelector azureBlobSecretKeySelector = storage.getAzureBlob().getAzureCredentials().getSecretKeySelectors();
    azureBlobSecretKeySelector.setAccount(new SecretKeySelector(accountKey, accountName));
    azureBlobSecretKeySelector.setAccessKey(new SecretKeySelector(accessKeyKey, accessKeyName));
}
Also used : AzureBlobSecretKeySelector(io.stackgres.common.crd.storages.AzureBlobSecretKeySelector) BackupStorage(io.stackgres.common.crd.storages.BackupStorage) AzureBlobStorageCredentials(io.stackgres.common.crd.storages.AzureBlobStorageCredentials) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) AzureBlobSecretKeySelector(io.stackgres.common.crd.storages.AzureBlobSecretKeySelector) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) GoogleCloudSecretKeySelector(io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector) AzureBlobStorage(io.stackgres.common.crd.storages.AzureBlobStorage)

Example 13 with SecretKeySelector

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

the class BackupConfigSourceValidatorTest method setGcsCredentials.

private void setGcsCredentials(final BackupConfigReview review, String serviceAccountJsonKeyName, String serviceAccountJsonKeyKey) {
    BackupStorage storage = review.getRequest().getObject().getSpec().getStorage();
    storage.setType("gcs");
    storage.setGcs(new GoogleCloudStorage());
    storage.getGcs().setCredentials(new GoogleCloudCredentials());
    storage.getGcs().getCredentials().setSecretKeySelectors(new GoogleCloudSecretKeySelector());
    GoogleCloudSecretKeySelector awsSecretKeySelector = storage.getGcs().getCredentials().getSecretKeySelectors();
    awsSecretKeySelector.setServiceAccountJsonKey(new SecretKeySelector(serviceAccountJsonKeyKey, serviceAccountJsonKeyName));
}
Also used : GoogleCloudSecretKeySelector(io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector) GoogleCloudStorage(io.stackgres.common.crd.storages.GoogleCloudStorage) BackupStorage(io.stackgres.common.crd.storages.BackupStorage) GoogleCloudCredentials(io.stackgres.common.crd.storages.GoogleCloudCredentials) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) AzureBlobSecretKeySelector(io.stackgres.common.crd.storages.AzureBlobSecretKeySelector) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) GoogleCloudSecretKeySelector(io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector)

Example 14 with SecretKeySelector

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

the class BackupConfigSourceValidatorTest method setS3Credentials.

private void setS3Credentials(final BackupConfigReview review, String accessKeyIdName, String accessKeyIdKey, String secretAccessKeyName, String secretAccessKeyKey) {
    BackupStorage storage = review.getRequest().getObject().getSpec().getStorage();
    storage.setType("s3");
    storage.setS3(new AwsS3Storage());
    storage.getS3().setAwsCredentials(new AwsCredentials());
    storage.getS3().getAwsCredentials().setSecretKeySelectors(new AwsSecretKeySelector());
    AwsSecretKeySelector awsSecretKeySelector = storage.getS3().getAwsCredentials().getSecretKeySelectors();
    awsSecretKeySelector.setAccessKeyId(new SecretKeySelector(accessKeyIdKey, accessKeyIdName));
    awsSecretKeySelector.setSecretAccessKey(new SecretKeySelector(secretAccessKeyKey, secretAccessKeyName));
}
Also used : AwsS3Storage(io.stackgres.common.crd.storages.AwsS3Storage) BackupStorage(io.stackgres.common.crd.storages.BackupStorage) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) AwsCredentials(io.stackgres.common.crd.storages.AwsCredentials) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) AzureBlobSecretKeySelector(io.stackgres.common.crd.storages.AzureBlobSecretKeySelector) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) GoogleCloudSecretKeySelector(io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector)

Example 15 with SecretKeySelector

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

the class BackupConfigSourceValidatorTest method setS3CompatibleCredentials.

private void setS3CompatibleCredentials(final BackupConfigReview review, String accessKeyIdName, String accessKeyIdKey, String secretAccessKeyName, String secretAccessKeyKey) {
    BackupStorage storage = review.getRequest().getObject().getSpec().getStorage();
    storage.setType("s3compatible");
    storage.setS3Compatible(new AwsS3CompatibleStorage());
    storage.getS3Compatible().setAwsCredentials(new AwsCredentials());
    storage.getS3Compatible().getAwsCredentials().setSecretKeySelectors(new AwsSecretKeySelector());
    AwsSecretKeySelector awsSecretKeySelector = storage.getS3Compatible().getAwsCredentials().getSecretKeySelectors();
    awsSecretKeySelector.setAccessKeyId(new SecretKeySelector(accessKeyIdKey, accessKeyIdName));
    awsSecretKeySelector.setSecretAccessKey(new SecretKeySelector(secretAccessKeyKey, secretAccessKeyName));
}
Also used : BackupStorage(io.stackgres.common.crd.storages.BackupStorage) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) AwsCredentials(io.stackgres.common.crd.storages.AwsCredentials) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) AzureBlobSecretKeySelector(io.stackgres.common.crd.storages.AzureBlobSecretKeySelector) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) GoogleCloudSecretKeySelector(io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector) AwsS3CompatibleStorage(io.stackgres.common.crd.storages.AwsS3CompatibleStorage)

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