Search in sources :

Example 1 with EnvironmentEditRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest in project cloudbreak by hortonworks.

the class EnvironmentApiConverterTest method createEditEnvironmentRequest.

private EnvironmentEditRequest createEditEnvironmentRequest() {
    EnvironmentEditRequest request = new EnvironmentEditRequest();
    request.setDescription("Test description.");
    request.setNetwork(new EnvironmentNetworkRequest());
    request.setAuthentication(createAuthenticationRequest());
    request.setTelemetry(new TelemetryRequest());
    request.setSecurityAccess(createSecurityAccessRequest());
    request.setIdBrokerMappingSource(IdBrokerMappingSource.IDBMMS);
    request.setCloudStorageValidation(CloudStorageValidation.DISABLED);
    request.setAdminGroupName("cb-admin");
    request.setAws(createAwsRequest());
    return request;
}
Also used : TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) EnvironmentEditRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest)

Example 2 with EnvironmentEditRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest in project cloudbreak by hortonworks.

the class EnvironmentChangeAuthenticationAction method action.

@Override
public EnvironmentTestDto action(TestContext testContext, EnvironmentTestDto testDto, EnvironmentClient environmentClient) throws Exception {
    EnvironmentEditRequest request = new EnvironmentEditRequest();
    EnvironmentAuthenticationRequest environmentAuthenticationRequest = new EnvironmentAuthenticationRequest();
    environmentAuthenticationRequest.setPublicKey(testDto.getRequest().getAuthentication().getPublicKey());
    environmentAuthenticationRequest.setPublicKeyId(testDto.getRequest().getAuthentication().getPublicKeyId());
    request.setAuthentication(environmentAuthenticationRequest);
    testDto.setResponse(environmentClient.getDefaultClient().environmentV1Endpoint().editByCrn(testDto.getResponse().getCrn(), request));
    Log.when(LOGGER, "Environment edit authentication action posted");
    return testDto;
}
Also used : EnvironmentAuthenticationRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentAuthenticationRequest) EnvironmentEditRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest)

Example 3 with EnvironmentEditRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest in project cloudbreak by hortonworks.

the class EnvironmentApiConverterTest method testInitEditDto.

@Test
void testInitEditDto() {
    EnvironmentEditRequest request = createEditEnvironmentRequest();
    EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
    AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
    Features features = mock(Features.class);
    NetworkDto networkDto = mock(NetworkDto.class);
    when(accountTelemetry.getFeatures()).thenReturn(features);
    when(accountTelemetryService.getOrDefault(any())).thenReturn(accountTelemetry);
    when(telemetryApiConverter.convert(eq(request.getTelemetry()), any(), anyString())).thenReturn(environmentTelemetry);
    when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
    EnvironmentEditDto actual = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.initEditDto(request));
    assertEquals("test-aws", actual.getAccountId());
    assertEquals(request.getDescription(), actual.getDescription());
    assertEquals(environmentTelemetry, actual.getTelemetry());
    assertAuthentication(request.getAuthentication(), actual.getAuthentication());
    assertEquals(request.getAdminGroupName(), actual.getAdminGroupName());
    assertSecurityAccess(request.getSecurityAccess(), actual.getSecurityAccess());
    verify(accountTelemetry).getFeatures();
    verify(accountTelemetryService).getOrDefault(any());
    verify(telemetryApiConverter).convert(eq(request.getTelemetry()), any(), anyString());
    verify(networkRequestToDtoConverter).convert(request.getNetwork());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) AccountTelemetry(com.sequenceiq.environment.telemetry.domain.AccountTelemetry) Features(com.sequenceiq.common.api.telemetry.model.Features) ExperimentalFeatures(com.sequenceiq.environment.environment.domain.ExperimentalFeatures) EnvironmentEditRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest) EnvironmentEditDto(com.sequenceiq.environment.environment.dto.EnvironmentEditDto) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with EnvironmentEditRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest in project cloudbreak by hortonworks.

the class EnvironmentChangeSecurityAccessAction method action.

@Override
public EnvironmentTestDto action(TestContext testContext, EnvironmentTestDto testDto, EnvironmentClient environmentClient) throws Exception {
    EnvironmentEditRequest request = new EnvironmentEditRequest();
    SecurityAccessRequest securityAccess = testDto.getRequest().getSecurityAccess();
    SecurityAccessRequest clone = cloneSecurityAccessRequest(securityAccess);
    request.setSecurityAccess(clone);
    testDto.setResponse(environmentClient.getDefaultClient().environmentV1Endpoint().editByCrn(testDto.getResponse().getCrn(), request));
    Log.when(LOGGER, "Environment edit authentication action posted");
    return testDto;
}
Also used : SecurityAccessRequest(com.sequenceiq.environment.api.v1.environment.model.request.SecurityAccessRequest) EnvironmentEditRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest)

Aggregations

EnvironmentEditRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest)4 Features (com.sequenceiq.common.api.telemetry.model.Features)1 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)1 EnvironmentAuthenticationRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentAuthenticationRequest)1 EnvironmentNetworkRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest)1 SecurityAccessRequest (com.sequenceiq.environment.api.v1.environment.model.request.SecurityAccessRequest)1 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)1 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)1 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)1 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)1 AccountTelemetry (com.sequenceiq.environment.telemetry.domain.AccountTelemetry)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1