use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class AwsDataAccessRolePermissionValidatorTest method testGetStorageLocationBase.
@Test
@Override
public void testGetStorageLocationBase() {
String path = "testBucket/ranger/audit";
String expectedStorageLocationBase = "testBucket/ranger/audit";
StorageLocationBase location = new StorageLocationBase();
location.setValue(String.format("%s://%s", FileSystemType.S3.getProtocol(), path));
String storageLocationBase = awsDataAccessRolePermissionValidator.getStorageLocationBase(location);
assertThat(storageLocationBase).isEqualTo(expectedStorageLocationBase);
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class AwsRangerAuditRolePermissionValidatorTest method testGetStorageLocationBase.
@Test
@Override
public void testGetStorageLocationBase() {
String path = "testBucket/ranger/audit";
String expectedStorageLocationBase = "testBucket";
StorageLocationBase location = new StorageLocationBase();
location.setValue(String.format("%s://%s", FileSystemType.S3.getProtocol(), path));
String storageLocationBase = awsRangerAuditRolePermissionValidator.getStorageLocationBase(location);
assertThat(storageLocationBase).isEqualTo(expectedStorageLocationBase);
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class AwsRangerAuditRolePermissionValidatorTest method testCollectPolicies.
@Test
@Override
public void testCollectPolicies() {
ArgumentCaptor<Map<String, String>> replacementsCaptor = ArgumentCaptor.forClass(Map.class);
when(awsIamService.getPolicy(anyString(), replacementsCaptor.capture())).thenReturn(new Policy());
CloudS3View cloudFileSystem = new CloudS3View(CloudIdentityType.ID_BROKER);
cloudFileSystem.setInstanceProfile("arn:aws:iam::11111111111:instance-profile/instanceprofile");
StorageLocationBase storageLocationBase1 = new StorageLocationBase();
storageLocationBase1.setType(CloudStorageCdpService.RANGER_AUDIT);
storageLocationBase1.setValue("s3a://bucket/cluster/ranger/audit");
cloudFileSystem.setLocations(List.of(storageLocationBase1));
List<Policy> policies = getValidator().collectPolicies(cloudFileSystem, List.of("policyFile1", "policyFile2"));
assertEquals(2, policies.size());
Map<String, String> replacements = replacementsCaptor.getValue();
assertEquals("bucket/cluster", replacements.get("${STORAGE_LOCATION_BASE}"));
assertEquals("bucket", replacements.get("${DATALAKE_BUCKET}"));
assertEquals("", replacements.get("${DYNAMODB_TABLE_NAME}"));
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class AwsRangerAuditRolePermissionValidatorTest method testGetPolicyJsonReplacements.
@Test
@Override
public void testGetPolicyJsonReplacements() {
String storageLocationBaseStr = "bucket/cluster";
String bucket = "bucket";
String dynamodbTableName = "tableName";
Map<String, String> expectedPolicyJsonReplacements = Map.ofEntries(Map.entry("${ARN_PARTITION}", "aws"), Map.entry("${STORAGE_LOCATION_BASE}", storageLocationBaseStr), Map.entry("${DATALAKE_BUCKET}", bucket), Map.entry("${DYNAMODB_TABLE_NAME}", dynamodbTableName));
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setValue(storageLocationBaseStr);
CloudS3View cloudFileSystem = new CloudS3View(CloudIdentityType.ID_BROKER);
cloudFileSystem.setInstanceProfile("arn:aws:iam::11111111111:instance-profile/instanceprofile");
cloudFileSystem.setS3GuardDynamoTableName(dynamodbTableName);
Map<String, String> policyJsonReplacements = awsRangerAuditRolePermissionValidator.getPolicyJsonReplacements(storageLocationBase, cloudFileSystem);
assertThat(policyJsonReplacements).isEqualTo(expectedPolicyJsonReplacements);
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method getStorageLocation.
private List<StorageLocationBase> getStorageLocation() {
CloudStorageCdpService eStorageLocationType = CloudStorageCdpService.RANGER_AUDIT;
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(eStorageLocationType);
storageLocationBase.setValue(STORAGE_LOCATION_RANGER);
return List.of(storageLocationBase);
}
Aggregations