use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverterTest method setupForEndpointGateway.
private StackV4Request setupForEndpointGateway(boolean enabled) {
initMocks();
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
StackV4Request request = getRequest("stack-datalake-with-instancegroups.json");
EnvironmentNetworkResponse networkResponse = new EnvironmentNetworkResponse();
networkResponse.setPublicEndpointAccessGateway(enabled ? PublicEndpointAccessGateway.ENABLED : PublicEndpointAccessGateway.DISABLED);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCredential(credentialResponse);
environmentResponse.setCloudPlatform("AWS");
environmentResponse.setTunnel(Tunnel.DIRECT);
environmentResponse.setTags(new TagResponse());
environmentResponse.setNetwork(networkResponse);
when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
given(credentialClientService.getByCrn(anyString())).willReturn(credential);
given(credentialClientService.getByName(anyString())).willReturn(credential);
given(providerParameterCalculator.get(request)).willReturn(getMappable());
given(clusterV4RequestToClusterConverter.convert(any(ClusterV4Request.class))).willReturn(new Cluster());
given(telemetryConverter.convert(null, StackType.DATALAKE)).willReturn(new Telemetry());
given(loadBalancerConfigService.getKnoxGatewayGroups(any(Stack.class))).willReturn(Set.of("master"));
return request;
}
use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverterTest method setUp.
@BeforeEach
void setUp() {
when(restRequestThreadLocalService.getCloudbreakUser()).thenReturn(cloudbreakUser);
when(cloudbreakUser.getUsername()).thenReturn("username");
when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(1L);
when(workspaceService.getForCurrentUser()).thenReturn(workspace);
when(workspace.getId()).thenReturn(1L);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCredential(credentialResponse);
environmentResponse.setCloudPlatform("AWS");
environmentResponse.setTunnel(Tunnel.DIRECT);
environmentResponse.setTags(new TagResponse());
when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
when(kerberosConfigService.get(anyString(), anyString())).thenReturn(Optional.empty());
when(costTagging.mergeTags(any(CDPTagMergeRequest.class))).thenReturn(new HashMap<>());
when(datalakeService.getDatalakeCrn(any(), any())).thenReturn("crn");
when(targetedUpscaleSupportService.isUnboundEliminationSupported(anyString())).thenReturn(Boolean.FALSE);
credential = Credential.builder().cloudPlatform("AWS").build();
}
use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse in project cloudbreak by hortonworks.
the class EnvironmentServiceDecoratorTest method testPrepareEnvironmentsAndCredentialNameWhenEnvironmentCrnProvidedThenShouldCallGetEnvironmentByCrn.
@Test
void testPrepareEnvironmentsAndCredentialNameWhenEnvironmentCrnProvidedThenShouldCallGetEnvironmentByCrn() {
DetailedEnvironmentResponse detailedEnvironmentResponse = mock(DetailedEnvironmentResponse.class);
CredentialResponse credentialResponse = mock(CredentialResponse.class);
NameOrCrn nameOrCrn = mock(NameOrCrn.class);
Set<StackViewV4Response> stackViewResponses = Set.of(new StackViewV4Response());
when(nameOrCrn.hasCrn()).thenReturn(true);
when(nameOrCrn.getCrn()).thenReturn("crn");
when(detailedEnvironmentResponse.getCredential()).thenReturn(credentialResponse);
when(credentialResponse.getName()).thenReturn("credential-name");
when(detailedEnvironmentResponse.getName()).thenReturn("env-name");
when(environmentClientService.getByCrn(any())).thenReturn(detailedEnvironmentResponse);
underTest.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
verify(environmentClientService, times(1)).getByCrn(any());
assertEquals(stackViewResponses.iterator().next().getEnvironmentName(), "env-name");
assertEquals(stackViewResponses.iterator().next().getCredentialName(), "credential-name");
assertEquals(stackViewResponses.iterator().next().isGovCloud(), false);
}
use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse in project cloudbreak by hortonworks.
the class EnvironmentServiceDecoratorTest method testPrepareEnvironmentsAndCredentialEnvironmentNameWhenNameProvidedThenShouldCallGetEnvironmentByName.
@Test
void testPrepareEnvironmentsAndCredentialEnvironmentNameWhenNameProvidedThenShouldCallGetEnvironmentByName() {
DetailedEnvironmentResponse detailedEnvironmentResponse = mock(DetailedEnvironmentResponse.class);
CredentialResponse credentialResponse = mock(CredentialResponse.class);
NameOrCrn nameOrCrn = mock(NameOrCrn.class);
Set<StackViewV4Response> stackViewResponses = Set.of(new StackViewV4Response());
when(nameOrCrn.hasCrn()).thenReturn(false);
when(nameOrCrn.hasName()).thenReturn(true);
when(nameOrCrn.getName()).thenReturn("name");
when(detailedEnvironmentResponse.getCredential()).thenReturn(credentialResponse);
when(credentialResponse.getName()).thenReturn("credential-name");
when(detailedEnvironmentResponse.getName()).thenReturn("env-name");
when(environmentClientService.getByName(any())).thenReturn(detailedEnvironmentResponse);
underTest.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
verify(environmentClientService, times(1)).getByName(any());
assertEquals(stackViewResponses.iterator().next().getEnvironmentName(), "env-name");
assertEquals(stackViewResponses.iterator().next().getCredentialName(), "credential-name");
assertEquals(stackViewResponses.iterator().next().isGovCloud(), false);
}
use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse in project cloudbreak by hortonworks.
the class EnvironmentServiceIntegrationTest method testCredentialList.
@Test
public void testCredentialList() {
credentialRepository.save(credential);
CredentialResponses results = client.credentialV1Endpoint().list();
assertTrue(results.getResponses().stream().anyMatch(credentialResponse -> credentialResponse.getName().equals(credential.getName())), String.format("Result set should have credential with name: %s", credential.getName()));
}
Aggregations