Search in sources :

Example 11 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class SubnetSelectorTest method testChooseEndpointGatewaySubnetFromEndpointSubnetst.

@Test
public void testChooseEndpointGatewaySubnetFromEndpointSubnetst() {
    EnvironmentNetworkResponse source = setupResponse();
    source.setSubnetMetas(Map.of("key", getCloudSubnet(AZ_1)));
    source.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
    source.setGatewayEndpointSubnetMetas(Map.of("public-key", getPublicCloudSubnet(PUBLIC_ID_1, AZ_1)));
    when(entitlementService.endpointGatewaySkipValidation(any())).thenReturn(false);
    Optional<CloudSubnet> subnet = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.chooseSubnetForEndpointGateway(source, PRIVATE_ID_1));
    assert subnet.isPresent();
    assertEquals(PUBLIC_ID_1, subnet.get().getId());
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.jupiter.api.Test) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest)

Example 12 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EnvironmentResponseConverterTest method testDtoToDetailedResponse.

@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE", "GCP" })
void testDtoToDetailedResponse(CloudPlatform cloudPlatform) {
    EnvironmentDto environment = createEnvironmentDto(cloudPlatform);
    CredentialResponse credentialResponse = mock(CredentialResponse.class);
    FreeIpaResponse freeIpaResponse = mock(FreeIpaResponse.class);
    CompactRegionResponse compactRegionResponse = mock(CompactRegionResponse.class);
    TelemetryResponse telemetryResponse = mock(TelemetryResponse.class);
    BackupResponse backupResponse = mock(BackupResponse.class);
    ProxyResponse proxyResponse = mock(ProxyResponse.class);
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    when(credentialConverter.convert(environment.getCredential())).thenReturn(credentialResponse);
    when(freeIpaConverter.convert(environment.getFreeIpaCreation())).thenReturn(freeIpaResponse);
    when(regionConverter.convertRegions(environment.getRegions())).thenReturn(compactRegionResponse);
    when(telemetryApiConverter.convert(environment.getTelemetry())).thenReturn(telemetryResponse);
    when(backupConverter.convert(environment.getBackup())).thenReturn(backupResponse);
    when(proxyConfigToProxyResponseConverter.convert((ProxyConfig) environment.getProxyConfig())).thenReturn(proxyResponse);
    when(networkDtoToResponseConverter.convert(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), true)).thenReturn(environmentNetworkResponse);
    DetailedEnvironmentResponse actual = underTest.dtoToDetailedResponse(environment);
    assertEquals(environment.getResourceCrn(), actual.getCrn());
    assertEquals(environment.getName(), actual.getName());
    assertEquals(environment.getOriginalName(), actual.getOriginalName());
    assertEquals(environment.getDescription(), actual.getDescription());
    assertEquals(environment.getCloudPlatform(), actual.getCloudPlatform());
    assertEquals(credentialResponse, actual.getCredential());
    assertEquals(environment.getStatus().getResponseStatus(), actual.getEnvironmentStatus());
    assertLocation(environment.getLocation(), actual.getLocation());
    assertTrue(actual.getCreateFreeIpa());
    assertEquals(freeIpaResponse, actual.getFreeIpa());
    assertEquals(compactRegionResponse, actual.getRegions());
    assertEquals(environment.getCreator(), actual.getCreator());
    assertAuthentication(environment.getAuthentication(), actual.getAuthentication());
    assertEquals(environment.getStatusReason(), actual.getStatusReason());
    assertEquals(environment.getCreated(), actual.getCreated());
    assertEquals(environment.getTags().getUserDefinedTags(), actual.getTags().getUserDefined());
    assertEquals(environment.getTags().getDefaultTags(), actual.getTags().getDefaults());
    assertEquals(telemetryResponse, actual.getTelemetry());
    assertEquals(environment.getExperimentalFeatures().getTunnel(), actual.getTunnel());
    assertEquals(environment.getExperimentalFeatures().getIdBrokerMappingSource(), actual.getIdBrokerMappingSource());
    assertEquals(environment.getExperimentalFeatures().getCloudStorageValidation(), actual.getCloudStorageValidation());
    assertEquals(environment.getExperimentalFeatures().getCcmV2TlsType(), actual.getCcmV2TlsType());
    assertEquals(environment.getAdminGroupName(), actual.getAdminGroupName());
    assertParameters(environment, actual, cloudPlatform);
    assertEquals(environment.getParentEnvironmentCrn(), actual.getParentEnvironmentCrn());
    assertEquals(environment.getParentEnvironmentName(), actual.getParentEnvironmentName());
    assertEquals(environment.getParentEnvironmentCloudPlatform(), actual.getParentEnvironmentCloudPlatform());
    assertEquals(proxyResponse, actual.getProxyConfig());
    assertEquals(environmentNetworkResponse, actual.getNetwork());
    assertSecurityAccess(environment.getSecurityAccess(), actual.getSecurityAccess());
    verify(credentialConverter).convert(environment.getCredential());
    verify(freeIpaConverter).convert(environment.getFreeIpaCreation());
    verify(regionConverter).convertRegions(environment.getRegions());
    verify(telemetryApiConverter).convert(environment.getTelemetry());
    verify(proxyConfigToProxyResponseConverter).convert(environment.getProxyConfig());
    verify(networkDtoToResponseConverter).convert(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), true);
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) BackupResponse(com.sequenceiq.common.api.backup.response.BackupResponse) FreeIpaResponse(com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EnvironmentResponseConverterTest method testDtoToSimpleResponse.

@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE" })
void testDtoToSimpleResponse(CloudPlatform cloudPlatform) {
    EnvironmentDto environmentDto = createEnvironmentDto(cloudPlatform);
    CredentialViewResponse credentialResponse = mock(CredentialViewResponse.class);
    FreeIpaResponse freeIpaResponse = mock(FreeIpaResponse.class);
    CompactRegionResponse compactRegionResponse = mock(CompactRegionResponse.class);
    TelemetryResponse telemetryResponse = mock(TelemetryResponse.class);
    ProxyViewResponse proxyResponse = mock(ProxyViewResponse.class);
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    when(credentialViewConverter.convertResponse(environmentDto.getCredential())).thenReturn(credentialResponse);
    when(freeIpaConverter.convert(environmentDto.getFreeIpaCreation())).thenReturn(freeIpaResponse);
    when(regionConverter.convertRegions(environmentDto.getRegions())).thenReturn(compactRegionResponse);
    when(telemetryApiConverter.convert(environmentDto.getTelemetry())).thenReturn(telemetryResponse);
    when(proxyConfigToProxyResponseConverter.convertToView(environmentDto.getProxyConfig())).thenReturn(proxyResponse);
    when(networkDtoToResponseConverter.convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false)).thenReturn(environmentNetworkResponse);
    SimpleEnvironmentResponse actual = underTest.dtoToSimpleResponse(environmentDto, true, true);
    assertEquals(environmentDto.getResourceCrn(), actual.getCrn());
    assertEquals(environmentDto.getName(), actual.getName());
    assertEquals(environmentDto.getOriginalName(), actual.getOriginalName());
    assertEquals(environmentDto.getDescription(), actual.getDescription());
    assertEquals(environmentDto.getCloudPlatform(), actual.getCloudPlatform());
    assertEquals(credentialResponse, actual.getCredential());
    assertEquals(environmentDto.getStatus().getResponseStatus(), actual.getEnvironmentStatus());
    assertEquals(environmentDto.getCreator(), actual.getCreator());
    assertLocation(environmentDto.getLocation(), actual.getLocation());
    assertTrue(actual.getCreateFreeIpa());
    assertEquals(freeIpaResponse, actual.getFreeIpa());
    assertEquals(environmentDto.getStatusReason(), actual.getStatusReason());
    assertEquals(environmentDto.getCreated(), actual.getCreated());
    assertEquals(environmentDto.getExperimentalFeatures().getTunnel(), actual.getTunnel());
    assertEquals(environmentDto.getExperimentalFeatures().getCcmV2TlsType(), actual.getCcmV2TlsType());
    assertEquals(environmentDto.getAdminGroupName(), actual.getAdminGroupName());
    assertEquals(environmentDto.getTags().getUserDefinedTags(), actual.getTags().getUserDefined());
    assertEquals(environmentDto.getTags().getDefaultTags(), actual.getTags().getDefaults());
    assertEquals(telemetryResponse, actual.getTelemetry());
    assertEquals(compactRegionResponse, actual.getRegions());
    assertParameters(environmentDto, actual, cloudPlatform);
    assertEquals(environmentDto.getParentEnvironmentName(), actual.getParentEnvironmentName());
    assertEquals(proxyResponse, actual.getProxyConfig());
    assertEquals(environmentNetworkResponse, actual.getNetwork());
    verify(credentialViewConverter).convertResponse(environmentDto.getCredential());
    verify(freeIpaConverter).convert(environmentDto.getFreeIpaCreation());
    verify(regionConverter).convertRegions(environmentDto.getRegions());
    verify(telemetryApiConverter).convert(environmentDto.getTelemetry());
    verify(proxyConfigToProxyResponseConverter).convertToView(environmentDto.getProxyConfig());
    verify(networkDtoToResponseConverter).convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false);
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) ProxyViewResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyViewResponse) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) FreeIpaResponse(com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class NetworkDtoToResponseConverterTest method testConvertWithAwsParams.

@Test
void testConvertWithAwsParams() {
    NetworkDto network = createNetworkDto().withAws(createAwsParams()).build();
    ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
    when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
    EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
    assertCommonFields(network, actual);
    assertEquals(network.getAws().getVpcId(), actual.getAws().getVpcId());
    assertNull(actual.getAzure());
    assertNull(actual.getYarn());
    assertNull(actual.getMock());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 15 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class NetworkDtoToResponseConverterTest method testConvertWithYarnParams.

@Test
void testConvertWithYarnParams() {
    NetworkDto network = createNetworkDto().withYarn(createYarnParams()).build();
    ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
    when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
    EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
    assertCommonFields(network, actual);
    assertEquals(network.getYarn().getQueue(), actual.getYarn().getQueue());
    assertEquals(network.getYarn().getLifetime(), actual.getYarn().getLifetime());
    assertNull(actual.getAws());
    assertNull(actual.getMock());
    assertNull(actual.getAzure());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Aggregations

EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)70 Test (org.junit.jupiter.api.Test)40 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)24 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)22 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)8 NetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request)8 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)7 Test (org.junit.Test)7 EnvironmentNetworkGcpParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams)6 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)5 Network (com.sequenceiq.cloudbreak.domain.Network)5 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)5 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)3 SubnetType (com.sequenceiq.cloudbreak.cloud.model.network.SubnetType)3 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)3 Tunnel (com.sequenceiq.common.api.type.Tunnel)3 EnvironmentNetworkAwsParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkAwsParams)3