Search in sources :

Example 11 with StorageLocationBase

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);
}
Also used : StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 12 with StorageLocationBase

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);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 13 with StorageLocationBase

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}"));
}
Also used : Policy(com.amazonaws.auth.policy.Policy) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Map(java.util.Map) CloudS3View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 14 with StorageLocationBase

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);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudS3View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 15 with StorageLocationBase

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);
}
Also used : CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase)

Aggregations

StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)34 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)19 Test (org.junit.jupiter.api.Test)19 CloudStorageCdpService (com.sequenceiq.common.model.CloudStorageCdpService)10 StorageIdentityBase (com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)9 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)9 ArrayList (java.util.ArrayList)9 CloudS3View (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View)7 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)7 FileSystemType (com.sequenceiq.common.model.FileSystemType)7 List (java.util.List)7 ConfigQueryEntry (com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntry)6 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)6 CloudIdentityType (com.sequenceiq.common.model.CloudIdentityType)6 LinkedHashSet (java.util.LinkedHashSet)6 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)5 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)5 SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)5 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)5