use of org.finra.herd.model.api.xml.StorageUnitUploadCredential in project herd by FINRAOS.
the class StorageUnitServiceGetCredentialTest method getStorageUnitUploadCredentialWithKmsId.
@Test
public void getStorageUnitUploadCredentialWithKmsId() {
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));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "test"));
storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes);
StorageUnitUploadCredential storageUnitUploadCredential = storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, createNewVersion, storageName);
assertNotNull(storageUnitUploadCredential);
assertNotNull(storageUnitUploadCredential.getAwsCredential());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsAccessKey());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSecretKey());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionToken());
assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionExpirationTime());
assertEquals("test", storageUnitUploadCredential.getAwsKmsKeyId());
}
use of org.finra.herd.model.api.xml.StorageUnitUploadCredential in project herd by FINRAOS.
the class StorageUnitServiceGetCredentialTest method getStorageUnitUploadCredentialWithBdataVersion.
@Test
public void getStorageUnitUploadCredentialWithBdataVersion() {
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 = false;
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, storageName);
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.StorageUnitUploadCredential in project herd by FINRAOS.
the class StorageUnitServiceImpl method getStorageUnitUploadCredential.
@NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public StorageUnitUploadCredential getStorageUnitUploadCredential(BusinessObjectDataKey businessObjectDataKey, Boolean createNewVersion, String storageName) {
StorageUnitUploadCredential businessObjectDataUploadCredential = new StorageUnitUploadCredential();
businessObjectDataUploadCredential.setAwsCredential(getBusinessObjectDataS3Credential(businessObjectDataKey, createNewVersion, storageName, true));
businessObjectDataUploadCredential.setAwsKmsKeyId(getStorageKmsKeyId(storageDaoHelper.getStorageEntity(storageName.trim())));
return businessObjectDataUploadCredential;
}
Aggregations