@Test public void validateS3() { when(environmentLogging.getS3()).thenReturn(s3); when(s3.getType()).thenReturn(FileSystemType.S3); ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder() .withCloudPlatform(CLOUD_PLATFORM) .withCredential(CLOUD_CREDENTIAL) .withObjectStoragePath(BUCKET_NAME) .build(); ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build(); when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response); ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder(); underTest.validate(S3_OBJECT_PATH, environment, validationResultBuilder); assertFalse(validationResultBuilder.build().hasError()); }
public void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder) { Optional<FileSystemType> fileSystemType = getFileSystemType(environment); String bucketName = getBucketName(fileSystemType, storageLocation); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environment.getCredential()); ObjectStorageMetadataRequest request = createObjectStorageMetadataRequest(environment.getCloudPlatform(), cloudCredential, bucketName); ObjectStorageMetadataResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(() -> cloudProviderServicesV4Endopint.getObjectStorageMetaData(request)); resultBuilder.ifError(() -> response.getStatus() == ResponseStatus.OK && !environment.getLocation().equals(response.getRegion()), String.format("Object storage location [%s] of bucket '%s' must match environment location [%s]", response.getRegion(), bucketName, environment.getLocation())); }
CloudStorageLocationValidator { public void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder) { Optional<FileSystemType> fileSystemType = getFileSystemType(environment); String bucketName = getBucketName(fileSystemType, storageLocation); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environment.getCredential()); ObjectStorageMetadataRequest request = createObjectStorageMetadataRequest(environment.getCloudPlatform(), cloudCredential, bucketName); ObjectStorageMetadataResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(() -> cloudProviderServicesV4Endopint.getObjectStorageMetaData(request)); resultBuilder.ifError(() -> response.getStatus() == ResponseStatus.OK && !environment.getLocation().equals(response.getRegion()), String.format("Object storage location [%s] of bucket '%s' must match environment location [%s]", response.getRegion(), bucketName, environment.getLocation())); } }
CloudStorageLocationValidator { public void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder) { Optional<FileSystemType> fileSystemType = getFileSystemType(environment); String bucketName = getBucketName(fileSystemType, storageLocation); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environment.getCredential()); ObjectStorageMetadataRequest request = createObjectStorageMetadataRequest(environment.getCloudPlatform(), cloudCredential, bucketName); ObjectStorageMetadataResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(() -> cloudProviderServicesV4Endopint.getObjectStorageMetaData(request)); resultBuilder.ifError(() -> response.getStatus() == ResponseStatus.OK && !environment.getLocation().equals(response.getRegion()), String.format("Object storage location [%s] of bucket '%s' must match environment location [%s]", response.getRegion(), bucketName, environment.getLocation())); } CloudStorageLocationValidator(CloudProviderServicesV4Endopint cloudProviderServicesV4Endopint,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter); }
CloudStorageLocationValidator { public void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder) { Optional<FileSystemType> fileSystemType = getFileSystemType(environment); String bucketName = getBucketName(fileSystemType, storageLocation); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environment.getCredential()); ObjectStorageMetadataRequest request = createObjectStorageMetadataRequest(environment.getCloudPlatform(), cloudCredential, bucketName); ObjectStorageMetadataResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(() -> cloudProviderServicesV4Endopint.getObjectStorageMetaData(request)); resultBuilder.ifError(() -> response.getStatus() == ResponseStatus.OK && !environment.getLocation().equals(response.getRegion()), String.format("Object storage location [%s] of bucket '%s' must match environment location [%s]", response.getRegion(), bucketName, environment.getLocation())); } CloudStorageLocationValidator(CloudProviderServicesV4Endopint cloudProviderServicesV4Endopint,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter); void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder); }
CloudStorageLocationValidator { public void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder) { Optional<FileSystemType> fileSystemType = getFileSystemType(environment); String bucketName = getBucketName(fileSystemType, storageLocation); CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(environment.getCredential()); ObjectStorageMetadataRequest request = createObjectStorageMetadataRequest(environment.getCloudPlatform(), cloudCredential, bucketName); ObjectStorageMetadataResponse response = ThreadBasedUserCrnProvider.doAsInternalActor(() -> cloudProviderServicesV4Endopint.getObjectStorageMetaData(request)); resultBuilder.ifError(() -> response.getStatus() == ResponseStatus.OK && !environment.getLocation().equals(response.getRegion()), String.format("Object storage location [%s] of bucket '%s' must match environment location [%s]", response.getRegion(), bucketName, environment.getLocation())); } CloudStorageLocationValidator(CloudProviderServicesV4Endopint cloudProviderServicesV4Endopint,
            CredentialToCloudCredentialConverter credentialToCloudCredentialConverter); void validate(String storageLocation, Environment environment, ValidationResultBuilder resultBuilder);  }