use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageWhenLoggerStorageAccountScopeThenNoError.
@Test
public void testValidateObjectStorageWhenLoggerStorageAccountScopeThenNoError() {
SpiFileSystem fileSystem = setupSpiFileSystem(false);
new RoleASsignmentBuilder(client).withAssignment(ASSUMER_IDENTITY_PRINCIPAL_ID, SUBSCRIPTION_FULL_ID).withAssignment(LOG_IDENTITY_PRINCIPAL_ID, ABFS_STORAGE_ACCOUNT_NAME);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
ValidationResult validationResult = resultBuilder.build();
assertFalse(validationResult.hasError());
}
use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageWithSingleResourceGroupAndNoResourceGroupRoleAssignment.
@Test
public void testValidateObjectStorageWithSingleResourceGroupAndNoResourceGroupRoleAssignment() {
SpiFileSystem fileSystem = setupSpiFileSystem(false);
new RoleASsignmentBuilder(client).withAssignment(LOG_IDENTITY_PRINCIPAL_ID, STORAGE_RESOURCE_GROUP_NAME);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateObjectStorage(client, fileSystem, "", null, RESOURCE_GROUP_NAME, resultBuilder);
ValidationResult validationResult = resultBuilder.build();
verify(client, times(0)).listRoleAssignments();
verify(client, times(1)).listRoleAssignmentsByScopeInner(RESOURCE_GROUP_ID);
assertTrue(validationResult.hasError());
assertEquals(2, validationResult.getErrors().size());
assertEquals(validationResult.getErrors().get(1), String.format("Identity with id %s has no role assignment. " + "Please check if you've used the correct Identity when setting up Data Access.", ASSUMER_IDENTITY));
assertEquals(validationResult.getErrors().get(0), String.format("Identity with id %s has no role assignment on scope(s) [/subscriptions/%s, %s]. " + "Please check if you've used the correct Identity when setting up Data Access.", ASSUMER_IDENTITY, SUBSCRIPTION_ID, RESOURCE_GROUP_ID));
}
use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageNoMappedRoles.
@Test
public void testValidateObjectStorageNoMappedRoles() {
SpiFileSystem fileSystem = setupSpiFileSystem(true);
PagedList<Identity> identityPagedList = Mockito.spy(PagedList.class);
when(assumer.id()).thenReturn(USER_IDENTITY_1);
when(logger.id()).thenReturn(GROUP_IDENTITY_1);
identityPagedList.add(assumer);
identityPagedList.add(logger);
when(client.listIdentities()).thenReturn(identityPagedList);
final String wrongAssumerIdentityPrincipalid = "489e3729-aed1-4d54-a95b-b231b70d383f";
final String wrongLoggerIdentityPrincipalid = "61a70b9b-7331-4fa3-8717-2652fc70434e";
new RoleASsignmentBuilder(client).withAssignment(wrongAssumerIdentityPrincipalid, SUBSCRIPTION_FULL_ID).withAssignment(wrongLoggerIdentityPrincipalid, STORAGE_RESOURCE_GROUP_NAME);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateObjectStorage(client, fileSystem, STORAGE_LOCATION_RANGER, null, null, resultBuilder);
ValidationResult validationResult = resultBuilder.build();
assertTrue(validationResult.hasError());
assertEquals(5, validationResult.getErrors().size());
List<String> actual = validationResult.getErrors();
assertTrue(actual.stream().anyMatch(item -> item.contains(String.format("Identity with id %s has no role assignment.", USER_IDENTITY_1))));
assertTrue(actual.stream().anyMatch(item -> item.contains(String.format("Identity with id %s has no role assignment on scope", GROUP_IDENTITY_1))));
assertTrue(actual.stream().anyMatch(item -> item.contains(String.format("Identity with id %s has no role assignment on scope", USER_IDENTITY_1))));
}
use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageWithNoRoleAssignments.
@Test
public void testValidateObjectStorageWithNoRoleAssignments() {
SpiFileSystem fileSystem = setupSpiFileSystem(false);
new RoleASsignmentBuilder(client);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
ValidationResult validationResult = resultBuilder.build();
assertTrue(validationResult.hasError());
assertEquals(2, validationResult.getErrors().size());
assertEquals(validationResult.getErrors().get(1), "There are no role assignments for the given Azure subscription. " + "Please check if you've used the correct Identity when setting up Data Access.");
assertEquals(validationResult.getErrors().get(0), String.format("Identity with id %s has no role assignment. " + "Please check if you've used the correct Identity when setting up Data Access.", ASSUMER_IDENTITY));
}
use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageNonExistingAssumerIdentity.
@Test
public void testValidateObjectStorageNonExistingAssumerIdentity() {
SpiFileSystem fileSystem = setupSpiFileSystem(false);
new RoleASsignmentBuilder(client).withAssignment(LOG_IDENTITY_PRINCIPAL_ID, STORAGE_RESOURCE_GROUP_NAME);
when(client.getIdentityById(ASSUMER_IDENTITY)).thenReturn(null);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
ValidationResult validationResult = resultBuilder.build();
assertTrue(validationResult.hasError());
assertEquals(1, validationResult.getErrors().size());
String actual = validationResult.getErrors().get(0);
assertEquals(actual, String.format("Assumer Identity with id %s does not exist in the given Azure subscription. " + "Please check if you've used the correct Identity when setting up Data Access.", ASSUMER_IDENTITY));
}
Aggregations