use of io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed in project stackgres by ongres.
the class BackupConfigSourceValidatorTest method givenNonExistentSecretAccessKeySecretForS3StorageCredentialsOnCreation_shouldFail.
@Test
void givenNonExistentSecretAccessKeySecretForS3StorageCredentialsOnCreation_shouldFail() throws ValidationFailed {
final BackupConfigReview review = getEmptyReview();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
String accessKeyIdName = "secret1";
String accessKeyIdKey = "key1";
String secretAccessKeyName = "secret2";
String secretAccessKeyKey = "key2";
setS3Credentials(review, accessKeyIdName, accessKeyIdKey, secretAccessKeyName, secretAccessKeyKey);
when(secretFinder.findByNameAndNamespace(accessKeyIdName, namespace)).thenReturn(Optional.of(new SecretBuilder(secret).withData(ImmutableMap.of(accessKeyIdKey, ResourceUtil.encodeSecret("accessKeyId"))).build()));
ValidationFailed ex = ValidationUtils.assertErrorType(ErrorType.INVALID_SECRET, () -> validator.validate(review));
assertEquals("Invalid backup configuration, secret " + secretAccessKeyName + " for secretAccessKey of s3 credentials not found", ex.getResult().getMessage());
verify(secretFinder).findByNameAndNamespace(eq(accessKeyIdName), eq(namespace));
}
use of io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed in project stackgres by ongres.
the class BackupConfigSourceValidatorTest method givenNonExistentServiceAccountJsonKeySecretForGcsStorageCredentialsOnCreation_shouldFail.
@Test
void givenNonExistentServiceAccountJsonKeySecretForGcsStorageCredentialsOnCreation_shouldFail() throws ValidationFailed {
final BackupConfigReview review = getEmptyReview();
String serviceAccountJsonKeyName = "secret1";
String serviceAccountJsonKeyKey = "key1";
setGcsCredentials(review, serviceAccountJsonKeyName, serviceAccountJsonKeyKey);
ValidationFailed ex = ValidationUtils.assertErrorType(ErrorType.INVALID_SECRET, () -> validator.validate(review));
assertEquals("Invalid backup configuration, secret " + serviceAccountJsonKeyName + " for serviceAccountJsonKey of gcs credentials not found", ex.getResult().getMessage());
}
use of io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed in project stackgres by ongres.
the class BackupConfigSourceValidatorTest method givenNonExistentAccessKeyIdKeyForS3StorageCredentialsOnCreation_shouldFail.
@Test
void givenNonExistentAccessKeyIdKeyForS3StorageCredentialsOnCreation_shouldFail() throws ValidationFailed {
final BackupConfigReview review = getEmptyReview();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
String accessKeyIdName = "secret1";
String accessKeyIdKey = "key1";
String secretAccessKeyName = "secret2";
String secretAccessKeyKey = "key2";
setS3Credentials(review, accessKeyIdName, accessKeyIdKey, secretAccessKeyName, secretAccessKeyKey);
when(secretFinder.findByNameAndNamespace(accessKeyIdName, namespace)).thenReturn(Optional.of(new SecretBuilder(secret).withData(ImmutableMap.of(accessKeyIdKey + "-wrong", ResourceUtil.encodeSecret("accessKeyId"))).build()));
ValidationFailed ex = ValidationUtils.assertErrorType(ErrorType.INVALID_SECRET, () -> validator.validate(review));
assertEquals("Invalid backup configuration, key " + accessKeyIdKey + " of secret " + accessKeyIdName + " for accessKeyId of s3 credentials not found", ex.getResult().getMessage());
verify(secretFinder).findByNameAndNamespace(eq(accessKeyIdName), eq(namespace));
}
use of io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed in project stackgres by ongres.
the class BackupConfigSourceValidatorTest method givenNonExistentAccessKeyIdSecretForS3CompatibleStorageCredentialsOnCreation_shouldFail.
@Test
void givenNonExistentAccessKeyIdSecretForS3CompatibleStorageCredentialsOnCreation_shouldFail() throws ValidationFailed {
final BackupConfigReview review = getEmptyReview();
String accessKeyIdName = "secret1";
String accessKeyIdKey = "key1";
String secretAccessKeyName = "secret2";
String secretAccessKeyKey = "key2";
setS3CompatibleCredentials(review, accessKeyIdName, accessKeyIdKey, secretAccessKeyName, secretAccessKeyKey);
ValidationFailed ex = ValidationUtils.assertErrorType(ErrorType.INVALID_SECRET, () -> validator.validate(review));
assertEquals("Invalid backup configuration, secret " + accessKeyIdName + " for accessKeyId of s3compatible credentials not found", ex.getResult().getMessage());
}
use of io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed in project stackgres by ongres.
the class BackupConfigSourceValidatorTest method givenNonExistentSecretAccessKeyKeyForS3CompatibleStorageCredentialsKeyOnCreation_shouldFail.
@Test
void givenNonExistentSecretAccessKeyKeyForS3CompatibleStorageCredentialsKeyOnCreation_shouldFail() throws ValidationFailed {
final BackupConfigReview review = getEmptyReview();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
String accessKeyIdName = "secret1";
String accessKeyIdKey = "key1";
String secretAccessKeyName = "secret2";
String secretAccessKeyKey = "key2";
setS3CompatibleCredentials(review, accessKeyIdName, accessKeyIdKey, secretAccessKeyName, secretAccessKeyKey);
when(secretFinder.findByNameAndNamespace(accessKeyIdName, namespace)).thenReturn(Optional.of(new SecretBuilder(secret).withData(ImmutableMap.of(accessKeyIdKey, ResourceUtil.encodeSecret("accessKeyId"))).build()));
when(secretFinder.findByNameAndNamespace(secretAccessKeyName, namespace)).thenReturn(Optional.of(new SecretBuilder(secret).withData(ImmutableMap.of(secretAccessKeyKey + "-wrong", ResourceUtil.encodeSecret("secretAccessKey"))).build()));
ValidationFailed ex = ValidationUtils.assertErrorType(ErrorType.INVALID_SECRET, () -> validator.validate(review));
assertEquals("Invalid backup configuration, key " + secretAccessKeyKey + " of secret " + secretAccessKeyName + " for secretAccessKey of s3compatible credentials not found", ex.getResult().getMessage());
verify(secretFinder).findByNameAndNamespace(eq(accessKeyIdName), eq(namespace));
verify(secretFinder).findByNameAndNamespace(eq(secretAccessKeyName), eq(namespace));
}
Aggregations