Search in sources :

Example 6 with ProxyResponse

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

the class ProxyController method deleteByCrn.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public ProxyResponse deleteByCrn(String crn) {
    ProxyResponse proxyResponse = proxyConfigToProxyResponseConverter.convert(proxyConfigService.deleteByCrnInAccount(crn, ThreadBasedUserCrnProvider.getAccountId()));
    notify(ResourceEvent.PROXY_CONFIG_DELETED);
    return proxyResponse;
}
Also used : ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 7 with ProxyResponse

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

the class ProxyConfigToProxyResponseConverter method convert.

public ProxyResponse convert(ProxyConfig source) {
    ProxyResponse response = new ProxyResponse();
    response.setCrn(source.getResourceCrn());
    response.setName(source.getName());
    response.setDescription(source.getDescription());
    response.setProtocol(source.getProtocol());
    response.setUserName(stringToSecretResponseConverter.convert(source.getUserNameSecret()));
    response.setPassword(stringToSecretResponseConverter.convert(source.getPasswordSecret()));
    response.setCreator(source.getCreator());
    response.setHost(source.getServerHost());
    response.setPort(source.getServerPort());
    response.setNoProxyHosts(source.getNoProxyHosts());
    return response;
}
Also used : ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)

Example 8 with ProxyResponse

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

the class EnvironmentServiceIntegrationTest method testProxyList.

@Test
public void testProxyList() {
    proxyConfigRepository.save(getProxyConfig());
    ProxyResponses results = client.proxyV1Endpoint().list();
    assertTrue(results.getResponses().stream().anyMatch(proxyResponse -> proxyResponse.getName().equals(getProxyConfig().getName())), String.format("Result set should have proxy with name: %s", getProxyConfig().getName()));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) CredentialVerificationRequest(com.sequenceiq.cloudbreak.cloud.event.credential.CredentialVerificationRequest) ResourceDefinitionResult(com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionResult) SecretService(com.sequenceiq.cloudbreak.service.secret.service.SecretService) ActiveProfiles(org.springframework.test.context.ActiveProfiles) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) NetworkService(com.sequenceiq.environment.network.NetworkService) Map(java.util.Map) ENVIRONMENT(com.sequenceiq.common.model.CredentialType.ENVIRONMENT) AzureCredentialRequestParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialRequestParameters) BadRequestException(javax.ws.rs.BadRequestException) RoleBasedRequest(com.sequenceiq.environment.api.v1.credential.model.parameters.azure.RoleBasedRequest) AwsDefaultRegionSelectionFailed(com.sequenceiq.cloudbreak.cloud.aws.common.exception.AwsDefaultRegionSelectionFailed) InteractiveLoginRequest(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginRequest) MockBean(org.springframework.boot.test.mock.mockito.MockBean) UmsResourceAuthorizationService(com.sequenceiq.authorization.service.UmsResourceAuthorizationService) AwsCredentialParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.AwsCredentialParameters) Set(java.util.Set) Mockito.doNothing(org.mockito.Mockito.doNothing) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) CredentialStatus(com.sequenceiq.cloudbreak.cloud.model.CredentialStatus) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test) ProxyResponses(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponses) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CloudCredentialStatus(com.sequenceiq.cloudbreak.cloud.model.CloudCredentialStatus) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) ProxyTestSource.getProxyConfig(com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyConfig) ProxyConfigRepository(com.sequenceiq.environment.proxy.repository.ProxyConfigRepository) InitCodeGrantFlowRequest(com.sequenceiq.cloudbreak.cloud.event.credential.InitCodeGrantFlowRequest) UmsAccountAuthorizationService(com.sequenceiq.authorization.service.UmsAccountAuthorizationService) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) Credential(com.sequenceiq.environment.credential.domain.Credential) ProxyRequest(com.sequenceiq.environment.api.v1.proxy.model.request.ProxyRequest) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) Mockito.lenient(org.mockito.Mockito.lenient) CredentialRepository(com.sequenceiq.environment.credential.repository.CredentialRepository) TestConfigurationForServiceIntegration(com.sequenceiq.environment.service.integration.testconfiguration.TestConfigurationForServiceIntegration) Inject(javax.inject.Inject) ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) CredentialRequest(com.sequenceiq.environment.api.v1.credential.model.request.CredentialRequest) FileReaderUtils(com.sequenceiq.cloudbreak.util.FileReaderUtils) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) RightCheck(com.cloudera.thunderhead.service.authorization.AuthorizationProto.RightCheck) EnvironmentServiceClientBuilder(com.sequenceiq.environment.client.EnvironmentServiceClientBuilder) ForbiddenException(javax.ws.rs.ForbiddenException) QuartzJobInitializer(com.sequenceiq.cloudbreak.quartz.configuration.QuartzJobInitializer) CredentialVerificationResult(com.sequenceiq.cloudbreak.cloud.event.credential.CredentialVerificationResult) ResourceDefinitionRequest(com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionRequest) Mockito.when(org.mockito.Mockito.when) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Maps(com.google.common.collect.Maps) GrpcUmsClient(com.sequenceiq.cloudbreak.auth.altus.GrpcUmsClient) KeyBasedParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.aws.KeyBasedParameters) LocalServerPort(org.springframework.boot.web.server.LocalServerPort) EnvironmentServiceCrnEndpoints(com.sequenceiq.environment.client.EnvironmentServiceCrnEndpoints) Collectors.toList(java.util.stream.Collectors.toList) AfterEach(org.junit.jupiter.api.AfterEach) ProxyTestSource.getProxyRequest(com.sequenceiq.environment.proxy.v1.ProxyTestSource.getProxyRequest) Assertions(org.junit.jupiter.api.Assertions) InteractiveCredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse) RequestProvider(com.sequenceiq.environment.credential.service.RequestProvider) InteractiveLoginResult(com.sequenceiq.cloudbreak.cloud.event.credential.InteractiveLoginResult) ProxyConfig(com.sequenceiq.environment.proxy.domain.ProxyConfig) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CredentialResponses(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponses) ProxyResponses(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponses) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with ProxyResponse

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

the class EnvironmentServiceIntegrationTest method testProxyGetByCrnName.

@Test
public void testProxyGetByCrnName() {
    proxyConfigRepository.save(getProxyConfig());
    ProxyResponse results = client.proxyV1Endpoint().getByResourceCrn(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 10 with ProxyResponse

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

the class EnvironmentServiceIntegrationTest method testProxyDeleteByName.

@Test
public void testProxyDeleteByName() {
    proxyConfigRepository.save(getProxyConfig());
    ProxyResponse results = client.proxyV1Endpoint().deleteByName(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)

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