@Test public void whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentityForGCS() { mockFileSystemResponseForCloudbreakClient(); SdxCluster sdxCluster = new SdxCluster(); SdxClusterRequest sdxClusterRequest = new SdxClusterRequest(); sdxCluster.setInitiatorUserCrn(USER_CRN); sdxCluster.setClusterName("sdx-cluster"); SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest(); cloudStorageRequest.setBaseLocation("gs: cloudStorageRequest.setFileSystemType(FileSystemType.GCS); GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters(); gcsCloudStorageV1Parameters.setServiceAccountEmail(EMAIL); cloudStorageRequest.setGcs(gcsCloudStorageV1Parameters); sdxClusterRequest.setCloudStorage(cloudStorageRequest); DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse(); environment.setCloudPlatform("GCP"); TelemetryResponse telemetryResponse = new TelemetryResponse(); LoggingResponse loggingResponse = new LoggingResponse(); loggingResponse.setGcs(gcsCloudStorageV1Parameters); telemetryResponse.setLogging(loggingResponse); GcpEnvironmentParameters gcpEnvironmentParameters = GcpEnvironmentParameters.builder().build(); environment.setGcp(gcpEnvironmentParameters); environment.setTelemetry(telemetryResponse); ClusterV4Request clusterV4Request = new ClusterV4Request(); clusterV4Request.setBlueprintName(exampleBlueprintName); CloudStorageRequest cloudStorageConfigReq = underTest.initCloudStorageRequest(environment, clusterV4Request, sdxCluster, sdxClusterRequest); StorageLocationBase singleRequest = cloudStorageConfigReq.getLocations().iterator().next(); assertEquals(2, cloudStorageConfigReq.getIdentities().size()); assertEquals(1, cloudStorageConfigReq.getIdentities() .stream() .filter(r -> r.getType().equals(CloudIdentityType.ID_BROKER)) .collect(Collectors.toSet()).size()); assertEquals(1, cloudStorageConfigReq.getIdentities() .stream() .filter(r -> r.getType().equals(CloudIdentityType.LOG)) .collect(Collectors.toSet()).size()); assertEquals(2, cloudStorageConfigReq.getIdentities() .stream() .filter(r -> r.getGcs().getServiceAccountEmail().equals(EMAIL)) .collect(Collectors.toSet()).size()); assertEquals(1, cloudStorageConfigReq.getLocations().size()); assertEquals(CloudStorageCdpService.RANGER_AUDIT, singleRequest.getType()); assertEquals("ranger/example-path", singleRequest.getValue()); }
public CloudStorageRequest initCloudStorageRequest(DetailedEnvironmentResponse environment, ClusterV4Request clusterRequest, SdxCluster sdxCluster, SdxClusterRequest sdxClusterRequest) { CloudStorageRequest cloudStorageRequest = null; boolean anyCloudStorageIsConfigured = isCloudStorageConfigured(sdxClusterRequest) || isInternalCloudStorageConfigured(clusterRequest); boolean loggingConfigured = isLoggingConfigured(environment); if (isCloudStorageConfigured(sdxClusterRequest)) { LOGGER.debug("Cloud storage configurations found in SDX cluster request."); cloudStorageRequest = initSdxCloudStorageRequest(environment, clusterRequest.getBlueprintName(), sdxCluster, sdxClusterRequest); } else if (isInternalCloudStorageConfigured(clusterRequest)) { LOGGER.debug("Cloud storage configurations found in internal SDX stack request."); cloudStorageRequest = clusterRequest.getCloudStorage(); } if (loggingConfigured) { LOGGER.debug("Cloud storage logging is enabled."); if (!anyCloudStorageIsConfigured) { LOGGER.debug("Creating cloud storage request only for logging identity."); cloudStorageRequest = new CloudStorageRequest(); } addLogIdentity(cloudStorageRequest, environment); } if (loggingConfigured || anyCloudStorageIsConfigured) { addS3Guard(cloudStorageRequest, environment); } return cloudStorageRequest; }
CloudStorageManifester { public CloudStorageRequest initCloudStorageRequest(DetailedEnvironmentResponse environment, ClusterV4Request clusterRequest, SdxCluster sdxCluster, SdxClusterRequest sdxClusterRequest) { CloudStorageRequest cloudStorageRequest = null; boolean anyCloudStorageIsConfigured = isCloudStorageConfigured(sdxClusterRequest) || isInternalCloudStorageConfigured(clusterRequest); boolean loggingConfigured = isLoggingConfigured(environment); if (isCloudStorageConfigured(sdxClusterRequest)) { LOGGER.debug("Cloud storage configurations found in SDX cluster request."); cloudStorageRequest = initSdxCloudStorageRequest(environment, clusterRequest.getBlueprintName(), sdxCluster, sdxClusterRequest); } else if (isInternalCloudStorageConfigured(clusterRequest)) { LOGGER.debug("Cloud storage configurations found in internal SDX stack request."); cloudStorageRequest = clusterRequest.getCloudStorage(); } if (loggingConfigured) { LOGGER.debug("Cloud storage logging is enabled."); if (!anyCloudStorageIsConfigured) { LOGGER.debug("Creating cloud storage request only for logging identity."); cloudStorageRequest = new CloudStorageRequest(); } addLogIdentity(cloudStorageRequest, environment); } if (loggingConfigured || anyCloudStorageIsConfigured) { addS3Guard(cloudStorageRequest, environment); } return cloudStorageRequest; } }
CloudStorageManifester { public CloudStorageRequest initCloudStorageRequest(DetailedEnvironmentResponse environment, ClusterV4Request clusterRequest, SdxCluster sdxCluster, SdxClusterRequest sdxClusterRequest) { CloudStorageRequest cloudStorageRequest = null; boolean anyCloudStorageIsConfigured = isCloudStorageConfigured(sdxClusterRequest) || isInternalCloudStorageConfigured(clusterRequest); boolean loggingConfigured = isLoggingConfigured(environment); if (isCloudStorageConfigured(sdxClusterRequest)) { LOGGER.debug("Cloud storage configurations found in SDX cluster request."); cloudStorageRequest = initSdxCloudStorageRequest(environment, clusterRequest.getBlueprintName(), sdxCluster, sdxClusterRequest); } else if (isInternalCloudStorageConfigured(clusterRequest)) { LOGGER.debug("Cloud storage configurations found in internal SDX stack request."); cloudStorageRequest = clusterRequest.getCloudStorage(); } if (loggingConfigured) { LOGGER.debug("Cloud storage logging is enabled."); if (!anyCloudStorageIsConfigured) { LOGGER.debug("Creating cloud storage request only for logging identity."); cloudStorageRequest = new CloudStorageRequest(); } addLogIdentity(cloudStorageRequest, environment); } if (loggingConfigured || anyCloudStorageIsConfigured) { addS3Guard(cloudStorageRequest, environment); } return cloudStorageRequest; }  }
CloudStorageManifester { public CloudStorageRequest initCloudStorageRequest(DetailedEnvironmentResponse environment, ClusterV4Request clusterRequest, SdxCluster sdxCluster, SdxClusterRequest sdxClusterRequest) { CloudStorageRequest cloudStorageRequest = null; boolean anyCloudStorageIsConfigured = isCloudStorageConfigured(sdxClusterRequest) || isInternalCloudStorageConfigured(clusterRequest); boolean loggingConfigured = isLoggingConfigured(environment); if (isCloudStorageConfigured(sdxClusterRequest)) { LOGGER.debug("Cloud storage configurations found in SDX cluster request."); cloudStorageRequest = initSdxCloudStorageRequest(environment, clusterRequest.getBlueprintName(), sdxCluster, sdxClusterRequest); } else if (isInternalCloudStorageConfigured(clusterRequest)) { LOGGER.debug("Cloud storage configurations found in internal SDX stack request."); cloudStorageRequest = clusterRequest.getCloudStorage(); } if (loggingConfigured) { LOGGER.debug("Cloud storage logging is enabled."); if (!anyCloudStorageIsConfigured) { LOGGER.debug("Creating cloud storage request only for logging identity."); cloudStorageRequest = new CloudStorageRequest(); } addLogIdentity(cloudStorageRequest, environment); } if (loggingConfigured || anyCloudStorageIsConfigured) { addS3Guard(cloudStorageRequest, environment); } return cloudStorageRequest; }  CloudStorageRequest initCloudStorageRequest(DetailedEnvironmentResponse environment,
            ClusterV4Request clusterRequest, SdxCluster sdxCluster, SdxClusterRequest sdxClusterRequest); }
CloudStorageManifester { public CloudStorageRequest initCloudStorageRequest(DetailedEnvironmentResponse environment, ClusterV4Request clusterRequest, SdxCluster sdxCluster, SdxClusterRequest sdxClusterRequest) { CloudStorageRequest cloudStorageRequest = null; boolean anyCloudStorageIsConfigured = isCloudStorageConfigured(sdxClusterRequest) || isInternalCloudStorageConfigured(clusterRequest); boolean loggingConfigured = isLoggingConfigured(environment); if (isCloudStorageConfigured(sdxClusterRequest)) { LOGGER.debug("Cloud storage configurations found in SDX cluster request."); cloudStorageRequest = initSdxCloudStorageRequest(environment, clusterRequest.getBlueprintName(), sdxCluster, sdxClusterRequest); } else if (isInternalCloudStorageConfigured(clusterRequest)) { LOGGER.debug("Cloud storage configurations found in internal SDX stack request."); cloudStorageRequest = clusterRequest.getCloudStorage(); } if (loggingConfigured) { LOGGER.debug("Cloud storage logging is enabled."); if (!anyCloudStorageIsConfigured) { LOGGER.debug("Creating cloud storage request only for logging identity."); cloudStorageRequest = new CloudStorageRequest(); } addLogIdentity(cloudStorageRequest, environment); } if (loggingConfigured || anyCloudStorageIsConfigured) { addS3Guard(cloudStorageRequest, environment); } return cloudStorageRequest; }  CloudStorageRequest initCloudStorageRequest(DetailedEnvironmentResponse environment,
            ClusterV4Request clusterRequest, SdxCluster sdxCluster, SdxClusterRequest sdxClusterRequest);  }