Search in sources :

Example 6 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig 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 7 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class EnvironmentCreationService method initializeEnvironment.

private Environment initializeEnvironment(EnvironmentCreationDto creationDto) {
    Environment environment = environmentDtoConverter.creationDtoToEnvironment(creationDto);
    environment.setResourceCrn(creationDto.getCrn());
    Credential credential = environmentResourceService.getCredentialFromRequest(creationDto.getCredential(), creationDto.getAccountId());
    environment.setCredential(credential);
    Optional<ProxyConfig> proxyConfig = environmentResourceService.getProxyConfig(creationDto.getProxyConfigName(), creationDto.getAccountId());
    proxyConfig.ifPresent(pc -> environment.setProxyConfig(pc));
    environment.setCloudPlatform(credential.getCloudPlatform());
    environment.setAuthentication(authenticationDtoConverter.dtoToAuthentication(creationDto.getAuthentication()));
    environment.setEnvironmentServiceVersion(environmentServiceVersion);
    LOGGER.info("Environment is initialized for creation.");
    return environment;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) Environment(com.sequenceiq.environment.environment.domain.Environment) ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig)

Example 8 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyTestSource method getProxyConfig.

public static ProxyConfig getProxyConfig() {
    ProxyConfig testSource = new ProxyConfig();
    testSource.setPassword(PASSWORD);
    testSource.setUserName(USERNAME);
    testSource.setName(NAME);
    testSource.setDescription(DESCRIPTION);
    testSource.setAccountId(ACCOUNT_ID);
    testSource.setCreator(CREATOR);
    testSource.setId(ID);
    testSource.setProtocol(PROTOCOL);
    testSource.setServerHost(SERVER_HOST);
    testSource.setResourceCrn(RESCRN);
    testSource.setServerPort(SERVER_PORT);
    testSource.setNoProxyHosts(NO_PROXY_HOSTS);
    return testSource;
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig)

Example 9 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigToProxyResponseConverterTest method convertEncodedProxyConfig.

private ProxyResponse convertEncodedProxyConfig() {
    ProxyConfig source = mock(ProxyConfig.class);
    when(source.getPasswordSecret()).thenReturn(ProxyTestSource.PASSWORD);
    when(source.getUserNameSecret()).thenReturn(ProxyTestSource.USERNAME);
    return underTest.convert(source);
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig)

Example 10 with ProxyConfig

use of com.sequenceiq.environment.proxy.domain.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyController method post.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public ProxyResponse post(ProxyRequest request) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    String creator = ThreadBasedUserCrnProvider.getUserCrn();
    ProxyConfig proxyConfig = proxyRequestToProxyConfigConverter.convert(request);
    notify(ResourceEvent.PROXY_CONFIG_CREATED);
    return proxyConfigToProxyResponseConverter.convert(proxyConfigService.create(proxyConfig, accountId, creator));
}
Also used : ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Aggregations

ProxyConfig (com.sequenceiq.environment.proxy.domain.ProxyConfig)12 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)4 Test (org.junit.jupiter.api.Test)2 ProxyRequest (com.sequenceiq.environment.api.v1.proxy.model.request.ProxyRequest)1 ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)1 Credential (com.sequenceiq.environment.credential.domain.Credential)1 Environment (com.sequenceiq.environment.environment.domain.Environment)1 ProxyTestSource.getProxyConfig (com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyConfig)1 ProxyTestSource.getProxyRequest (com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyRequest)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1