Search in sources :

Example 1 with StorageUnitDownloadCredential

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));
}
Also used : StorageUnitDownloadCredential(org.finra.herd.model.api.xml.StorageUnitDownloadCredential) AwsCredential(org.finra.herd.model.api.xml.AwsCredential)

Example 2 with 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;
}
Also used : StorageUnitDownloadCredential(org.finra.herd.model.api.xml.StorageUnitDownloadCredential) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 3 with StorageUnitDownloadCredential

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());
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) StorageUnitDownloadCredential(org.finra.herd.model.api.xml.StorageUnitDownloadCredential) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 4 with StorageUnitDownloadCredential

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);
}
Also used : StorageUnitDownloadCredential(org.finra.herd.model.api.xml.StorageUnitDownloadCredential) BusinessObjectDataDownloadCredential(org.finra.herd.model.api.xml.BusinessObjectDataDownloadCredential) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) AwsCredential(org.finra.herd.model.api.xml.AwsCredential) Test(org.junit.Test)

Example 5 with StorageUnitDownloadCredential

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);
}
Also used : StorageUnitDownloadCredential(org.finra.herd.model.api.xml.StorageUnitDownloadCredential) Test(org.junit.Test)

Aggregations

StorageUnitDownloadCredential (org.finra.herd.model.api.xml.StorageUnitDownloadCredential)10 Test (org.junit.Test)8 AwsCredential (org.finra.herd.model.api.xml.AwsCredential)6 DownloaderInputManifestDto (org.finra.herd.model.dto.DownloaderInputManifestDto)5 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 StringEntity (org.apache.http.entity.StringEntity)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 BasicStatusLine (org.apache.http.message.BasicStatusLine)2 HttpClientOperations (org.finra.herd.dao.HttpClientOperations)2 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)2 S3KeyPrefixInformation (org.finra.herd.model.api.xml.S3KeyPrefixInformation)2 Storage (org.finra.herd.model.api.xml.Storage)2 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)2 RegServerAccessParamsDto (org.finra.herd.model.dto.RegServerAccessParamsDto)2 Objects (com.google.common.base.Objects)1 File (java.io.File)1 Path (java.nio.file.Path)1