Search in sources :

Example 16 with SpiFileSystem

use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.

the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageWhenLoggerResourceGroupScopeThenNoError.

@Test
public void testValidateObjectStorageWhenLoggerResourceGroupScopeThenNoError() {
    SpiFileSystem fileSystem = setupSpiFileSystem(false);
    new RoleASsignmentBuilder(client).withAssignment(ASSUMER_IDENTITY_PRINCIPAL_ID, SUBSCRIPTION_FULL_ID).withAssignment(LOG_IDENTITY_PRINCIPAL_ID, STORAGE_RESOURCE_GROUP_NAME);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
    ValidationResult validationResult = resultBuilder.build();
    assertFalse(validationResult.hasError());
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Example 17 with SpiFileSystem

use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.

the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageWhenLoggerSubscriptionScopeThenNoError.

@Test
public void testValidateObjectStorageWhenLoggerSubscriptionScopeThenNoError() {
    SpiFileSystem fileSystem = setupSpiFileSystem(false);
    new RoleASsignmentBuilder(client).withAssignment(ASSUMER_IDENTITY_PRINCIPAL_ID, SUBSCRIPTION_FULL_ID).withAssignment(LOG_IDENTITY_PRINCIPAL_ID, STORAGE_RESOURCE_GROUP_NAME);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
    ValidationResult validationResult = resultBuilder.build();
    assertFalse(validationResult.hasError());
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Example 18 with SpiFileSystem

use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.

the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageWithNoStorageAccountScopeRoleAssignment.

@Test
public void testValidateObjectStorageWithNoStorageAccountScopeRoleAssignment() {
    SpiFileSystem fileSystem = setupSpiFileSystem(false);
    new RoleASsignmentBuilder(client).withAssignment(ASSUMER_IDENTITY_PRINCIPAL_ID, SUBSCRIPTION_FULL_ID);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    underTest.validateObjectStorage(client, fileSystem, STORAGE_LOCATION_RANGER, 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("Identity with id %s has no role assignment on scope(s) [%s, %s, %s]. " + "Please check if you've used the correct Identity when setting up Logs-Storage and Audit.", LOG_IDENTITY, ABFS_STORAGE_ACCOUNT_NAME, STORAGE_RESOURCE_GROUP_NAME, SUBSCRIPTION_ID));
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Example 19 with SpiFileSystem

use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.

the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageNonExistingLoggerIdentity.

@Test
public void testValidateObjectStorageNonExistingLoggerIdentity() {
    SpiFileSystem fileSystem = setupSpiFileSystem(false);
    new RoleASsignmentBuilder(client).withAssignment(ASSUMER_IDENTITY_PRINCIPAL_ID, SUBSCRIPTION_FULL_ID);
    when(client.getIdentityById(LOG_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("Log Identity with id %s does not exist in the given Azure subscription. " + "Please check if you've used the correct Identity when setting up Logs-Storage and Audit.", LOG_IDENTITY));
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Example 20 with SpiFileSystem

use of com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem in project cloudbreak by hortonworks.

the class AzureIDBrokerObjectStorageValidatorTest method testValidateObjectStorageMappingCaseSensitivityCB6600.

@Test
public void testValidateObjectStorageMappingCaseSensitivityCB6600() {
    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);
    new RoleASsignmentBuilder(client).withAssignment(ASSUMER_IDENTITY_PRINCIPAL_ID, SUBSCRIPTION_FULL_ID).withAssignment(LOG_IDENTITY_PRINCIPAL_ID, STORAGE_RESOURCE_GROUP_NAME);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    underTest.validateObjectStorage(client, fileSystem, "", null, null, resultBuilder);
    ValidationResult validationResult = resultBuilder.build();
    assertFalse(validationResult.hasError());
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) Identity(com.microsoft.azure.management.msi.Identity) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test)

Aggregations

SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)28 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)16 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)16 Test (org.junit.Test)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)5 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)4 Identity (com.microsoft.azure.management.msi.Identity)3 AzureClient (com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient)3 Group (com.sequenceiq.cloudbreak.cloud.model.Group)3 GroupNetwork (com.sequenceiq.cloudbreak.cloud.model.GroupNetwork)3 Network (com.sequenceiq.cloudbreak.cloud.model.Network)3 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)3 List (java.util.List)3 PagedList (com.microsoft.azure.PagedList)2 RoleAssignmentInner (com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner)2 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)2 Subscription (com.microsoft.azure.management.resources.Subscription)2 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)2 AzureStorage (com.sequenceiq.cloudbreak.cloud.azure.AzureStorage)2