@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, 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 does not exist in the given Azure subscription.", ASSUMER_IDENTITY)); }
public ValidationResult validateObjectStorage(AzureClient client, SpiFileSystem spiFileSystem, ValidationResultBuilder resultBuilder) { LOGGER.info("Validating Azure identities..."); List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems(); if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) { PagedList<RoleAssignmentInner> roleAssignments = client.listRoleAssignments(); for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) { CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) cloudFileSystemView; String managedIdentityId = cloudFileSystem.getManagedIdentity(); Identity identity = client.getIdentityById(managedIdentityId); if (identity != null) { CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType(); if (CloudIdentityType.ID_BROKER.equals(cloudIdentityType)) { validateIDBroker(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } else if (CloudIdentityType.LOG.equals(cloudIdentityType)) { validateLog(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } } else { addError(resultBuilder, String.format("Identity with id %s does not exist in the given Azure subscription.", managedIdentityId)); } } } return resultBuilder.build(); }
AzureIDBrokerObjectStorageValidator { public ValidationResult validateObjectStorage(AzureClient client, SpiFileSystem spiFileSystem, ValidationResultBuilder resultBuilder) { LOGGER.info("Validating Azure identities..."); List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems(); if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) { PagedList<RoleAssignmentInner> roleAssignments = client.listRoleAssignments(); for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) { CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) cloudFileSystemView; String managedIdentityId = cloudFileSystem.getManagedIdentity(); Identity identity = client.getIdentityById(managedIdentityId); if (identity != null) { CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType(); if (CloudIdentityType.ID_BROKER.equals(cloudIdentityType)) { validateIDBroker(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } else if (CloudIdentityType.LOG.equals(cloudIdentityType)) { validateLog(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } } else { addError(resultBuilder, String.format("Identity with id %s does not exist in the given Azure subscription.", managedIdentityId)); } } } return resultBuilder.build(); } }
AzureIDBrokerObjectStorageValidator { public ValidationResult validateObjectStorage(AzureClient client, SpiFileSystem spiFileSystem, ValidationResultBuilder resultBuilder) { LOGGER.info("Validating Azure identities..."); List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems(); if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) { PagedList<RoleAssignmentInner> roleAssignments = client.listRoleAssignments(); for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) { CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) cloudFileSystemView; String managedIdentityId = cloudFileSystem.getManagedIdentity(); Identity identity = client.getIdentityById(managedIdentityId); if (identity != null) { CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType(); if (CloudIdentityType.ID_BROKER.equals(cloudIdentityType)) { validateIDBroker(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } else if (CloudIdentityType.LOG.equals(cloudIdentityType)) { validateLog(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } } else { addError(resultBuilder, String.format("Identity with id %s does not exist in the given Azure subscription.", managedIdentityId)); } } } return resultBuilder.build(); }  }
AzureIDBrokerObjectStorageValidator { public ValidationResult validateObjectStorage(AzureClient client, SpiFileSystem spiFileSystem, ValidationResultBuilder resultBuilder) { LOGGER.info("Validating Azure identities..."); List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems(); if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) { PagedList<RoleAssignmentInner> roleAssignments = client.listRoleAssignments(); for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) { CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) cloudFileSystemView; String managedIdentityId = cloudFileSystem.getManagedIdentity(); Identity identity = client.getIdentityById(managedIdentityId); if (identity != null) { CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType(); if (CloudIdentityType.ID_BROKER.equals(cloudIdentityType)) { validateIDBroker(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } else if (CloudIdentityType.LOG.equals(cloudIdentityType)) { validateLog(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } } else { addError(resultBuilder, String.format("Identity with id %s does not exist in the given Azure subscription.", managedIdentityId)); } } } return resultBuilder.build(); }  ValidationResult validateObjectStorage(AzureClient client,
            SpiFileSystem spiFileSystem,
            ValidationResultBuilder resultBuilder); }
AzureIDBrokerObjectStorageValidator { public ValidationResult validateObjectStorage(AzureClient client, SpiFileSystem spiFileSystem, ValidationResultBuilder resultBuilder) { LOGGER.info("Validating Azure identities..."); List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems(); if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) { PagedList<RoleAssignmentInner> roleAssignments = client.listRoleAssignments(); for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) { CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) cloudFileSystemView; String managedIdentityId = cloudFileSystem.getManagedIdentity(); Identity identity = client.getIdentityById(managedIdentityId); if (identity != null) { CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType(); if (CloudIdentityType.ID_BROKER.equals(cloudIdentityType)) { validateIDBroker(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } else if (CloudIdentityType.LOG.equals(cloudIdentityType)) { validateLog(client, roleAssignments, identity, cloudFileSystem, resultBuilder); } } else { addError(resultBuilder, String.format("Identity with id %s does not exist in the given Azure subscription.", managedIdentityId)); } } } return resultBuilder.build(); }  ValidationResult validateObjectStorage(AzureClient client,
            SpiFileSystem spiFileSystem,
            ValidationResultBuilder resultBuilder);  }