Search in sources :

Example 6 with StorageUnitUploadCredential

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());
}
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 7 with StorageUnitUploadCredential

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());
}
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 8 with StorageUnitUploadCredential

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

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