Search in sources :

Example 96 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAwsAndNoInstanceGroups.

@Test
void setupInstanceVolumeEncryptionTestWhenAwsAndNoInstanceGroups() {
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setCloudPlatform(CloudPlatform.AWS.name());
    List<InstanceGroupV4Request> instanceGroups = new ArrayList<>();
    when(stackV4Request.getInstanceGroups()).thenReturn(instanceGroups);
    underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
    assertThat(instanceGroups).isEmpty();
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ArrayList(java.util.ArrayList) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 97 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAwsAndCustomEncryptionParameters.

@Test
void setupInstanceVolumeEncryptionTestWhenAwsAndCustomEncryptionParameters() {
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setCloudPlatform(CloudPlatform.AWS.name());
    envResponse.setAws(AwsEnvironmentParameters.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn(AWS_ENCRYPTION_KEY).build()).build());
    InstanceGroupV4Request instanceGroupV4Request = createInstanceGroupV4Request();
    when(stackV4Request.getInstanceGroups()).thenReturn(List.of(instanceGroupV4Request));
    underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
    verifyAwsEncryption(instanceGroupV4Request.getTemplate(), EncryptionType.CUSTOM, AWS_ENCRYPTION_KEY);
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 98 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAzureAndDiskEncryptionSetIdAndNoEncryptionParameters.

@Test
void setupInstanceVolumeEncryptionTestWhenAzureAndDiskEncryptionSetIdAndNoEncryptionParameters() {
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setCloudPlatform(CloudPlatform.AZURE.name());
    envResponse.setAzure(AzureEnvironmentParameters.builder().withResourceEncryptionParameters(AzureResourceEncryptionParameters.builder().withDiskEncryptionSetId(DISK_ENCRYPTION_SET_ID).withEncryptionKeyUrl(ENCRYPTION_KEY).build()).build());
    InstanceGroupV4Request instanceGroupV4Request = createInstanceGroupV4Request();
    InstanceTemplateV4Request instanceTemplateV4Request = instanceGroupV4Request.getTemplate();
    instanceTemplateV4Request.createAzure();
    when(stackV4Request.getInstanceGroups()).thenReturn(List.of(instanceGroupV4Request));
    underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
    verifyAzureEncryption(instanceTemplateV4Request, EncryptionType.CUSTOM, DISK_ENCRYPTION_SET_ID, ENCRYPTION_KEY);
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 99 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAwsAndNoInstanceTemplateParameters.

@Test
void setupInstanceVolumeEncryptionTestWhenAwsAndNoInstanceTemplateParameters() {
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setCloudPlatform(CloudPlatform.AWS.name());
    InstanceGroupV4Request instanceGroupV4Request = createInstanceGroupV4Request();
    when(stackV4Request.getInstanceGroups()).thenReturn(List.of(instanceGroupV4Request));
    underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
    verifyAwsEncryption(instanceGroupV4Request.getTemplate(), EncryptionType.DEFAULT);
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 100 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAwsAndEncryptionParameters.

@ParameterizedTest(name = "{0}")
@MethodSource("encryptionTypeDataProvider")
void setupInstanceVolumeEncryptionTestWhenAwsAndEncryptionParameters(String testCaseName, EncryptionType encryptionType, String encryptionKey, EncryptionType encryptionTypeExpected, String encryptionKeyExpected) {
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setCloudPlatform(CloudPlatform.AWS.name());
    InstanceGroupV4Request instanceGroupV4Request = createInstanceGroupV4Request();
    InstanceTemplateV4Request instanceTemplateV4Request = instanceGroupV4Request.getTemplate();
    if (encryptionKey == null) {
        instanceTemplateV4Request.createAws().setEncryption(createAwsEncryptionV4Parameters(encryptionType));
    } else {
        instanceTemplateV4Request.createAws().setEncryption(createAwsEncryptionV4Parameters(encryptionType, encryptionKey));
    }
    when(stackV4Request.getInstanceGroups()).thenReturn(List.of(instanceGroupV4Request));
    underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
    if (encryptionKeyExpected == null) {
        verifyAwsEncryption(instanceTemplateV4Request, encryptionTypeExpected);
    } else {
        verifyAwsEncryption(instanceTemplateV4Request, encryptionTypeExpected, encryptionKeyExpected);
    }
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)105 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)66 Test (org.junit.jupiter.api.Test)58 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)52 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)36 Test (org.junit.Test)36 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)34 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)33 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)32 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)31 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)17 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)14 Map (java.util.Map)13 Set (java.util.Set)13 Optional (java.util.Optional)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)11 HashMap (java.util.HashMap)11 List (java.util.List)11