use of org.finra.herd.model.api.xml.StoragePolicyCreateRequest in project herd by FINRAOS.
the class StoragePolicyServiceTest method testCreateStoragePolicyStoragePolicyFilterStorageBucketNameNotConfigured.
@Test
public void testCreateStoragePolicyStoragePolicyFilterStorageBucketNameNotConfigured() {
// Create and persist the relative database entities.
storagePolicyServiceTestHelper.createDatabaseEntitiesForStoragePolicyTesting();
// Create an S3 storage without any attributes.
storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3, StoragePlatformEntity.S3);
// Create a storage policy key.
StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
// Try to create a storage policy when storage policy filter storage has no S3 bucket name attribute configured.
StoragePolicyCreateRequest request = storagePolicyServiceTestHelper.createStoragePolicyCreateRequest(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME_3, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED);
try {
storagePolicyService.createStoragePolicy(request);
fail("Should throw an IllegalStateException when storage policy filter storage has no S3 bucket name attribute configured.");
} catch (IllegalStateException e) {
assertEquals(String.format("Attribute \"%s\" for \"%s\" storage must be configured.", configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), request.getStoragePolicyFilter().getStorageName()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StoragePolicyCreateRequest in project herd by FINRAOS.
the class StoragePolicyServiceTest method testCreateStoragePolicyStoragePolicyFilterStoragePathPrefixValidationNotEnabled.
@Test
public void testCreateStoragePolicyStoragePolicyFilterStoragePathPrefixValidationNotEnabled() {
// Create and persist the relative database entities.
storagePolicyServiceTestHelper.createDatabaseEntitiesForStoragePolicyTesting();
// Create an S3 storage with the bucket name configured, but without the S3 path prefix validation option configured.
storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3, StoragePlatformEntity.S3, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME);
StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
// Try to create a storage policy when storage policy filter storage has no S3 path prefix validation enabled.
StoragePolicyCreateRequest request = storagePolicyServiceTestHelper.createStoragePolicyCreateRequest(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME_3, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED);
try {
storagePolicyService.createStoragePolicy(request);
fail("Should throw an IllegalStateException when storage policy filter storage has no S3 path prefix validation enabled.");
} catch (IllegalStateException e) {
assertEquals(String.format("Path prefix validation must be enabled on \"%s\" storage.", request.getStoragePolicyFilter().getStorageName()), e.getMessage());
}
}
Aggregations