use of org.finra.herd.model.api.xml.StorageUnitDownloadCredential in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method getStorageUnitDownloadCredentialResponse.
private void getStorageUnitDownloadCredentialResponse(MockCloseableHttpResponse response, URI uri) throws UnsupportedCharsetException, JAXBException {
StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential();
AwsCredential awsCredential = new AwsCredential();
awsCredential.setAwsAccessKey(uri.toString());
storageUnitDownloadCredential.setAwsCredential(awsCredential);
response.setEntity(getHttpEntity(storageUnitDownloadCredential));
}
use of org.finra.herd.model.api.xml.StorageUnitDownloadCredential in project herd by FINRAOS.
the class StorageUnitServiceImpl method getStorageUnitDownloadCredential.
@NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public StorageUnitDownloadCredential getStorageUnitDownloadCredential(BusinessObjectDataKey businessObjectDataKey, String storageName) {
StorageUnitDownloadCredential businessObjectDataDownloadCredential = new StorageUnitDownloadCredential();
businessObjectDataDownloadCredential.setAwsCredential(getBusinessObjectDataS3Credential(businessObjectDataKey, null, storageName, false));
return businessObjectDataDownloadCredential;
}
use of org.finra.herd.model.api.xml.StorageUnitDownloadCredential 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.StorageUnitDownloadCredential in project herd by FINRAOS.
the class BusinessObjectDataRestControllerTest method testGetBusinessObjectDataDownloadCredential.
@Test
public void testGetBusinessObjectDataDownloadCredential() {
// 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 an AWS credential.
AwsCredential awsCredential = new AwsCredential(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME);
// Create a storage unit download credential.
StorageUnitDownloadCredential storageUnitDownloadCredential = new StorageUnitDownloadCredential(awsCredential);
// Mock the external calls.
when(storageUnitService.getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME)).thenReturn(storageUnitDownloadCredential);
// Call the method under test.
BusinessObjectDataDownloadCredential result = businessObjectDataRestController.getBusinessObjectDataDownloadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, STORAGE_NAME, getDelimitedFieldValues(SUBPARTITION_VALUES));
// Verify the external calls.
verify(storageUnitService).getStorageUnitDownloadCredential(businessObjectDataKey, STORAGE_NAME);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(new BusinessObjectDataDownloadCredential(awsCredential), result);
}
use of org.finra.herd.model.api.xml.StorageUnitDownloadCredential in project herd by FINRAOS.
the class StorageUnitRestControllerTest method getStorageUnitDownloadCredential.
@Test
public void getStorageUnitDownloadCredential() {
String namespace = "namespace";
String businessObjectDefinitionName = "businessObjectDefinitionName";
String businessObjectFormatUsage = "businessObjectFormatUsage";
String businessObjectFormatFileType = "businessObjectFormatFileType";
Integer businessObjectFormatVersion = 1234;
String partitionValue = "partitionValue";
Integer businessObjectDataVersion = 2345;
String storageName = "storageName";
DelimitedFieldValues subPartitionValues = new DelimitedFieldValues();
subPartitionValues.setValues(Arrays.asList("a", "b", "c", "d"));
StorageUnitDownloadCredential expectedResult = new StorageUnitDownloadCredential();
when(storageUnitService.getStorageUnitDownloadCredential(any(), any())).thenReturn(expectedResult);
StorageUnitDownloadCredential actualResult = storageUnitRestController.getStorageUnitDownloadCredential(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, businessObjectDataVersion, storageName, subPartitionValues);
verify(storageUnitService).getStorageUnitDownloadCredential(businessObjectDataKeyEq(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, businessObjectDataVersion, subPartitionValues), eq(storageName));
verifyNoMoreInteractions(storageUnitService);
assertEquals(expectedResult, actualResult);
}
Aggregations