Search in sources :

Example 11 with ProxyResponse

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

the class EnvironmentServiceIntegrationTest method testProxyCreate.

@Test
public void testProxyCreate() throws Exception {
    ProxyRequest request = getProxyRequest();
    request.setPort(8080);
    ProxyResponse result = client.proxyV1Endpoint().post(request);
    assertEquals(request.getName(), result.getName());
    Optional<ProxyConfig> saved = proxyConfigRepository.findByNameInAccount(request.getName(), TEST_ACCOUNT_ID);
    assertTrue(saved.isPresent());
}
Also used : ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) ProxyTestSource.getProxyConfig(com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyConfig) ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig) ProxyRequest(com.sequenceiq.environment.api.v1.proxy.model.request.ProxyRequest) ProxyTestSource.getProxyRequest(com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyRequest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with ProxyResponse

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

the class EnvironmentServiceIntegrationTest method testProxyDeleteByCrnName.

@Test
public void testProxyDeleteByCrnName() {
    proxyConfigRepository.save(getProxyConfig());
    ProxyResponse results = client.proxyV1Endpoint().deleteByCrn(getProxyConfig().getResourceCrn());
    assertTrue(results.getCrn().equals(getProxyConfig().getResourceCrn()), String.format("Result should have proxy with resource crn: %s", getProxyConfig().getResourceCrn()));
}
Also used : ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with ProxyResponse

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

the class ProxyConfigToProxyResponseConverterTest method testConvertCredentials.

@Test
void testConvertCredentials() {
    when(stringToSecretResponseConverter.convert(ProxyTestSource.USERNAME)).thenReturn(ProxyTestSource.USERNAME_SECRET);
    when(stringToSecretResponseConverter.convert(ProxyTestSource.PASSWORD)).thenReturn(ProxyTestSource.PASSWORD_SECRET);
    ProxyResponse result = convertEncodedProxyConfig();
    Assertions.assertEquals(ProxyTestSource.USERNAME, result.getUserName().getSecretPath());
    Assertions.assertEquals(ProxyTestSource.PASSWORD, result.getPassword().getSecretPath());
}
Also used : ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) Test(org.junit.jupiter.api.Test)

Example 14 with ProxyResponse

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

the class EnvironmentServiceIntegrationTest method testProxyGetByName.

@Test
public void testProxyGetByName() {
    proxyConfigRepository.save(getProxyConfig());
    ProxyResponse results = client.proxyV1Endpoint().getByName(getProxyRequest().getName());
    assertTrue(results.getName().equals(getProxyConfig().getName()), String.format("Result should have proxy with name: %s", getProxyConfig().getName()));
}
Also used : ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with ProxyResponse

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

the class ProxyConfigDtoServiceTest method testGetWhenProxyConfigUserPasswordEmpty.

@ParameterizedTest
@MethodSource("invalidUserPasswords")
void testGetWhenProxyConfigUserPasswordEmpty(String user, String password) {
    String name = "aProxyConfig";
    String host = "https://test.cloudera.com";
    Integer port = 8443;
    String decryptedSecretValue = "decrypted-secret-value";
    SecretResponse secretResponse = new SecretResponse();
    ProxyResponse proxyResponse = new ProxyResponse();
    proxyResponse.setName(name);
    proxyResponse.setHost(host);
    proxyResponse.setPort(port);
    proxyResponse.setUserName(secretResponse);
    proxyResponse.setPassword(secretResponse);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(environmentServiceCrnClient.withCrn(anyString()).proxyV1Endpoint()).thenReturn(proxyEndpoint);
    when(proxyEndpoint.getByResourceCrn(anyString())).thenReturn(proxyResponse);
    when(secretService.getByResponse(any(SecretResponse.class))).thenReturn(user).thenReturn(password);
    ProxyConfig proxyConfig = underTest.getByCrn("crn:cdp:environments:us-west-1:cloudera:proxyconfig:a2f0bee2-059e-433f-a9d0-2893c53419ad");
    assertFalse(proxyConfig.getProxyAuthentication().isPresent());
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)15 Test (org.junit.jupiter.api.Test)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 ProxyConfig (com.sequenceiq.cloudbreak.dto.ProxyConfig)3 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)3 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)2 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)2 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)2 CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)2 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)2 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)2 ProxyRequest (com.sequenceiq.environment.api.v1.proxy.model.request.ProxyRequest)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 ProxyConfig (com.sequenceiq.environment.proxy.domain.ProxyConfig)2 ProxyTestSource.getProxyConfig (com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyConfig)2 ProxyTestSource.getProxyRequest (com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyRequest)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2