use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class StorageUnitServiceGetCredentialTest method getStorageUnitUploadCredentialAssertStorageNameTrim.
@Test
public void getStorageUnitUploadCredentialAssertStorageNameTrim() {
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setNamespace(NAMESPACE);
businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION);
businessObjectDataKey.setPartitionValue(PARTITION_VALUE);
Boolean createNewVersion = true;
String storageName = STORAGE_NAME;
createBusinessObjectFormatEntity(businessObjectDataKey);
// Create an S3 storage entity.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), "testRole"));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket"));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), S3_KEY_PREFIX_VELOCITY_TEMPLATE));
storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes);
StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, BLANK_TEXT + storageName + BLANK_TEXT);
assertNotNull(storageUnitUploadCredential);
assertNotNull(storageUnitUploadCredential.getAwsCredential());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsAccessKey());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSecretKey());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionToken());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionExpirationTime());
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class StorageUnitServiceGetCredentialTest method getStorageUnitUploadCredentialAssertBDataVersionAndCreateNewVersionExclusive.
@Test
public void getStorageUnitUploadCredentialAssertBDataVersionAndCreateNewVersionExclusive() {
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setNamespace(NAMESPACE);
businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION);
businessObjectDataKey.setPartitionValue(PARTITION_VALUE);
businessObjectDataKey.setBusinessObjectDataVersion(DATA_VERSION);
Boolean createNewVersion = true;
String storageName = STORAGE_NAME;
createBusinessObjectFormatEntity(businessObjectDataKey);
// Create an S3 storage entity.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), "testRole"));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket"));
storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes);
try {
storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName);
fail("Expected an IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("createNewVersion must be false or unspecified when businessObjectDataVersion is specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class StorageUnitServiceGetCredentialTest method getStorageUnitDownloadCredential.
@Test
public void getStorageUnitDownloadCredential() {
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setNamespace(NAMESPACE);
businessObjectDataKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataKey.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
businessObjectDataKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
businessObjectDataKey.setBusinessObjectFormatVersion(FORMAT_VERSION);
businessObjectDataKey.setPartitionValue(PARTITION_VALUE);
businessObjectDataKey.setBusinessObjectDataVersion(DATA_VERSION);
String storageName = STORAGE_NAME;
createBusinessObjectFormatEntity(businessObjectDataKey);
// Create an S3 storage entity.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_DOWNLOAD_ROLE_ARN), "testRole"));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucket"));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), S3_KEY_PREFIX_VELOCITY_TEMPLATE));
storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes);
StorageUnitDownloadCredential storageUnitDownloadCredential = storageUnitService.getStorageUnitDownloadCredential(businessObjectDataKey, storageName);
assertNotNull(storageUnitDownloadCredential);
assertNotNull(storageUnitDownloadCredential.getAwsCredential());
assertNotNull(storageUnitDownloadCredential.getAwsCredential().getAwsAccessKey());
assertNotNull(storageUnitDownloadCredential.getAwsCredential().getAwsSecretKey());
assertNotNull(storageUnitDownloadCredential.getAwsCredential().getAwsSessionToken());
assertNotNull(storageUnitDownloadCredential.getAwsCredential().getAwsSessionExpirationTime());
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class StoragePolicyProcessorHelperServiceTest method testInitiateStoragePolicyTransitionStoragePolicyFilterStoragePathPrefixValidationNotEnabled.
@Test
public void testInitiateStoragePolicyTransitionStoragePolicyFilterStoragePathPrefixValidationNotEnabled() {
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Create and persist a business object data entity.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
// Create a storage policy key.
StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
// Create and persist an S3 storage without an S3 path prefix validation option configured.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), Boolean.TRUE.toString()));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_PATH_PREFIX), Boolean.FALSE.toString()));
storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, attributes);
// Create and persist a storage policy entity with the storage policy filter storage having no S3 path prefix validation enabled.
storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET);
// Try to initiate a storage policy transition when storage policy filter storage has no S3 path prefix validation enabled.
try {
storagePolicyProcessorHelperService.initiateStoragePolicyTransition(new StoragePolicyTransitionParamsDto(), new StoragePolicySelection(businessObjectDataKey, storagePolicyKey, INITIAL_VERSION));
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. Storage policy: {%s}", STORAGE_NAME, storagePolicyServiceTestHelper.getExpectedStoragePolicyKeyAndVersionAsString(storagePolicyKey, INITIAL_VERSION)), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class StoragePolicyProcessorHelperServiceTest method testInitiateStoragePolicyTransitionStoragePolicyFilterStorageBucketNameNotConfigured.
@Test
public void testInitiateStoragePolicyTransitionStoragePolicyFilterStorageBucketNameNotConfigured() {
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Create and persist a business object data entity.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
// Create a storage policy key.
StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
// Create and persist an S3 storage entity without S3 bucket name configured.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_PATH_PREFIX), Boolean.TRUE.toString()));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), Boolean.TRUE.toString()));
storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, attributes);
// Create and persist a storage policy entity with storage policy filter storage has no S3 bucket name attribute configured.
storagePolicyDaoTestHelper.createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, StoragePolicyTransitionTypeEntity.GLACIER, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET);
// Try to initiate a storage policy transition when storage policy filter storage has no S3 bucket name attribute configured.
try {
storagePolicyProcessorHelperService.initiateStoragePolicyTransition(new StoragePolicyTransitionParamsDto(), new StoragePolicySelection(businessObjectDataKey, storagePolicyKey, INITIAL_VERSION));
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), STORAGE_NAME), e.getMessage());
}
}
Aggregations