Search in sources :

Example 26 with CredentialResponse

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

the class EnvironmentServiceIntegrationTest method testCredentialGetByName.

@Test
public void testCredentialGetByName() {
    credentialRepository.save(credential);
    CredentialResponse results = client.credentialV1Endpoint().getByName(credential.getName());
    assertTrue(results.getName().equals(credential.getName()), String.format("Result should have credential with name: %s", credential.getName()));
}
Also used : CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) InteractiveCredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with CredentialResponse

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

the class ClusterCreationEnvironmentValidatorTest method getEnvironmentResponse.

private DetailedEnvironmentResponse getEnvironmentResponse() {
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setCloudPlatform("AWS");
    environmentResponse.setCredential(new CredentialResponse());
    CompactRegionResponse compactRegionResponse = new CompactRegionResponse();
    compactRegionResponse.setNames(Lists.newArrayList("region1"));
    environmentResponse.setRegions(compactRegionResponse);
    return environmentResponse;
}
Also used : CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)

Example 28 with CredentialResponse

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

the class StackAwsEncryptionValidatorTest method setup.

@Before
public void setup() {
    CredentialResponse credentialResponse = new CredentialResponse();
    credentialResponse.setName("cred");
    when(subject.getEnvironmentCrn()).thenReturn(ENV_CRN);
    when(subject.getRegion()).thenReturn("region");
    when(subject.getResourceCrn()).thenReturn(ENV_CRN);
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setCredential(credentialResponse);
    environmentResponse.setCrn(ENV_CRN);
    when(entitlementService.awsNativeEnabled(anyString())).thenReturn(false);
    when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
    when(templateRequestValidator.validate(any())).thenReturn(ValidationResult.builder().build());
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Before(org.junit.Before)

Example 29 with CredentialResponse

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

the class EnvironmentServiceDecorator method prepareEnvironmentAndCredentialName.

public void prepareEnvironmentAndCredentialName(StackV4Response stackResponse) {
    try {
        DetailedEnvironmentResponse byCrn = environmentClientService.getByCrn(stackResponse.getEnvironmentCrn());
        stackResponse.setEnvironmentName(byCrn.getName());
        CredentialResponse credential = byCrn.getCredential();
        stackResponse.setGovCloud(credential.getGovCloud() == null ? false : credential.getGovCloud());
        stackResponse.setCredentialName(credential.getName());
        stackResponse.setCredentialCrn(credential.getCrn());
    } catch (Exception e) {
        LOGGER.warn("Environment deleted which had crn: {}.", stackResponse.getEnvironmentCrn());
    }
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)

Example 30 with CredentialResponse

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

the class EnvironmentServiceDecorator method prepareEnvironmentAndCredential.

public void prepareEnvironmentAndCredential(Set<StackViewV4Response> stackViewResponses, DetailedEnvironmentResponse detailedEnvironmentResponse) {
    for (StackViewV4Response stackViewResponse : stackViewResponses) {
        if (detailedEnvironmentResponse != null) {
            CredentialResponse credential = detailedEnvironmentResponse.getCredential();
            stackViewResponse.setGovCloud(credential.getGovCloud() == null ? false : credential.getGovCloud());
            stackViewResponse.setCredentialName(credential.getName());
            stackViewResponse.setEnvironmentName(detailedEnvironmentResponse.getName());
        }
    }
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)

Aggregations

CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)29 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)12 Test (org.junit.jupiter.api.Test)10 InteractiveCredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)5 CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)4 BadRequestException (javax.ws.rs.BadRequestException)4 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)3 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)3 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3 Before (org.junit.Before)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)2 Json (com.sequenceiq.cloudbreak.common.json.Json)2 Credential (com.sequenceiq.cloudbreak.dto.credential.Credential)2 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)2 BackupResponse (com.sequenceiq.common.api.backup.response.BackupResponse)2