Search in sources :

Example 1 with StorageUnitUploadCredential

use of org.finra.herd.model.api.xml.StorageUnitUploadCredential in project herd by FINRAOS.

the class StorageUnitRestControllerTest method getStorageUnitUploadCredential.

@Test
public void getStorageUnitUploadCredential() {
    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"));
    StorageUnitUploadCredential expectedResult = new StorageUnitUploadCredential();
    when(storageUnitService.getStorageUnitUploadCredential(any(), any(), any())).thenReturn(expectedResult);
    StorageUnitUploadCredential actualResult = storageUnitRestController.getStorageUnitUploadCredential(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, businessObjectDataVersion, storageName, subPartitionValues);
    verify(storageUnitService).getStorageUnitUploadCredential(businessObjectDataKeyEq(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType, businessObjectFormatVersion, partitionValue, businessObjectDataVersion, subPartitionValues), isNull(Boolean.class), eq(storageName));
    verifyNoMoreInteractions(storageUnitService);
    assertEquals(expectedResult, actualResult);
}
Also used : StorageUnitUploadCredential(org.finra.herd.model.api.xml.StorageUnitUploadCredential) Test(org.junit.Test)

Example 2 with StorageUnitUploadCredential

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

Example 3 with StorageUnitUploadCredential

use of org.finra.herd.model.api.xml.StorageUnitUploadCredential in project herd by FINRAOS.

the class BusinessObjectDataRestControllerTest method testGetBusinessObjectDataUploadCredential.

@Test
public void testGetBusinessObjectDataUploadCredential() {
    // 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.
    StorageUnitUploadCredential storageUnitUploadCredential = new StorageUnitUploadCredential(awsCredential, AWS_KMS_KEY_ID);
    // Mock the external calls.
    when(storageUnitService.getStorageUnitUploadCredential(businessObjectDataKey, CREATE_NEW_VERSION, STORAGE_NAME)).thenReturn(storageUnitUploadCredential);
    // Call the method under test.
    BusinessObjectDataUploadCredential result = businessObjectDataRestController.getBusinessObjectDataUploadCredential(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, CREATE_NEW_VERSION, STORAGE_NAME, getDelimitedFieldValues(SUBPARTITION_VALUES));
    // Verify the external calls.
    verify(storageUnitService).getStorageUnitUploadCredential(businessObjectDataKey, CREATE_NEW_VERSION, STORAGE_NAME);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(new BusinessObjectDataUploadCredential(awsCredential, AWS_KMS_KEY_ID), result);
}
Also used : BusinessObjectDataUploadCredential(org.finra.herd.model.api.xml.BusinessObjectDataUploadCredential) StorageUnitUploadCredential(org.finra.herd.model.api.xml.StorageUnitUploadCredential) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) AwsCredential(org.finra.herd.model.api.xml.AwsCredential) Test(org.junit.Test)

Example 4 with StorageUnitUploadCredential

use of org.finra.herd.model.api.xml.StorageUnitUploadCredential in project herd by FINRAOS.

the class StorageUnitServiceGetCredentialTest method getStorageUnitUploadCredentialUseStorageAttributeDuration.

@Test
public void getStorageUnitUploadCredentialUseStorageAttributeDuration() {
    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));
    attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_SESSION_DURATION_SECS), "12345"));
    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());
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) StorageUnitUploadCredential(org.finra.herd.model.api.xml.StorageUnitUploadCredential) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 5 with StorageUnitUploadCredential

use of org.finra.herd.model.api.xml.StorageUnitUploadCredential in project herd by FINRAOS.

the class StorageUnitServiceGetCredentialTest method getStorageUnitUploadCredentialWithCreateNewVersion.

@Test
public void getStorageUnitUploadCredentialWithCreateNewVersion() {
    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, storageName);
    assertNotNull(storageUnitUploadCredential);
    assertNotNull(storageUnitUploadCredential.getAwsCredential());
    assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsAccessKey());
    assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSecretKey());
    assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionToken());
    assertNotNull(storageUnitUploadCredential.getAwsCredential().getAwsSessionExpirationTime());
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) StorageUnitUploadCredential(org.finra.herd.model.api.xml.StorageUnitUploadCredential) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

StorageUnitUploadCredential (org.finra.herd.model.api.xml.StorageUnitUploadCredential)8 Test (org.junit.Test)7 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)6 ArrayList (java.util.ArrayList)5 Attribute (org.finra.herd.model.api.xml.Attribute)5 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1 AwsCredential (org.finra.herd.model.api.xml.AwsCredential)1 BusinessObjectDataUploadCredential (org.finra.herd.model.api.xml.BusinessObjectDataUploadCredential)1