Search in sources :

Example 16 with CredentialResponse

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

the class EnvironmentServiceIntegrationTest method testCredentialGetByCrn.

@Test
public void testCredentialGetByCrn() {
    credentialRepository.save(credential);
    CredentialResponse results = client.credentialV1Endpoint().getByResourceCrn(credential.getResourceCrn());
    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 17 with CredentialResponse

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

the class EnvironmentServiceIntegrationTest method testCredentialDeleteByCrn.

@Test
public void testCredentialDeleteByCrn() {
    credentialRepository.save(credential);
    CredentialResponse results = client.credentialV1Endpoint().deleteByResourceCrn(credential.getResourceCrn());
    assertTrue(results.getName().startsWith(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 18 with CredentialResponse

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

the class EnvironmentServiceIntegrationTest method testCredentialCreateAws.

@Test
public void testCredentialCreateAws() throws InterruptedException {
    credentialRequest.setAws(getAwsKeyBasedCredentialParameters(false, "yyy", "zzzz"));
    credentialRequest.setCloudPlatform("AWS");
    credentialRequest.setName("testcredential");
    when(requestProvider.getResourceDefinitionRequest(any(), any())).thenReturn(resourceDefinitionRequest);
    when(requestProvider.getCredentialVerificationRequest(any(), any(), anyBoolean())).thenAnswer(invocation -> new CredentialVerificationMockRequest(invocation.getArgument(0), invocation.getArgument(1)));
    when(resourceDefinitionRequest.await()).thenReturn(new ResourceDefinitionResult(1L, DEFINITION_AWS));
    CredentialResponse response = client.credentialV1Endpoint().post(credentialRequest);
    assertTrue(response.getName().equals(credentialRequest.getName()), " not saved, or response is different");
    assertTrue(credentialRepository.findByNameAndAccountId(credentialRequest.getName(), TEST_ACCOUNT_ID, List.of("AWS"), ENVIRONMENT).isPresent());
}
Also used : CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) InteractiveCredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse) ResourceDefinitionResult(com.sequenceiq.cloudbreak.cloud.event.platform.ResourceDefinitionResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with CredentialResponse

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

the class StackToTemplatePreparationObjectConverterTest method setUp.

@BeforeEach
public void setUp() throws IOException, TransactionService.TransactionExecutionException {
    MockitoAnnotations.initMocks(this);
    doAnswer(invocation -> {
        invocation.getArgument(0, Runnable.class).run();
        return null;
    }).when(transactionService).required(any(Runnable.class));
    User user = new User();
    user.setUserName("applebob@apple.com");
    user.setUserCrn("user-crn");
    Tenant tenant = new Tenant();
    tenant.setId(1L);
    tenant.setName("account");
    user.setTenant(tenant);
    when(stackMock.getCreator()).thenReturn(user);
    when(stackMock.getEnvironmentCrn()).thenReturn("env");
    when(stackMock.getCloudPlatform()).thenReturn(TEST_CLOUD_PLATFORM);
    when(stackMock.cloudPlatform()).thenReturn(TEST_CLOUD_PLATFORM);
    when(stackMock.getType()).thenReturn(StackType.DATALAKE);
    when(stackMock.getRegion()).thenReturn(REGION);
    when(stackMock.getAvailabilityZone()).thenReturn(AVAILABILITY_ZONE);
    when(stackMock.getName()).thenReturn("stackname");
    when(sourceCluster.getId()).thenReturn(TEST_CLUSTER_ID);
    when(cluster.getId()).thenReturn(TEST_CLUSTER_ID);
    when(instanceGroupMetadataCollector.collectMetadata(stackMock)).thenReturn(groupInstances);
    when(cluster.getBlueprint()).thenReturn(blueprint);
    when(blueprint.getBlueprintText()).thenReturn(TEST_BLUEPRINT_TEXT);
    when(blueprint.getStackVersion()).thenReturn("7.2.11");
    when(stackMock.getInputs()).thenReturn(stackInputs);
    when(stackInputs.get(StackInputs.class)).thenReturn(null);
    when(stackMock.getEnvironmentCrn()).thenReturn(TestConstants.CRN);
    when(stackMock.getCluster()).thenReturn(sourceCluster);
    when(sourceCluster.getCustomConfigurations()).thenReturn(customConfigurations);
    when(customConfigurations.getCrn()).thenReturn("test-custom-configs-crn");
    when(stackMock.getResourceCrn()).thenReturn("crn:cdp:datahub:us-west-1:account:cluster:cluster");
    when(clusterService.findOneWithCustomConfigurations(anyLong())).thenReturn(sourceCluster);
    when(accountTagClientService.list()).thenReturn(new HashMap<>());
    when(entitlementService.internalTenant(anyString())).thenReturn(true);
    when(loadBalancerConfigService.getLoadBalancerUserFacingFQDN(anyLong())).thenReturn(null);
    Credential credential = Credential.builder().crn("aCredentialCRN").attributes(new Json("")).build();
    DetailedEnvironmentResponse environmentResponse = DetailedEnvironmentResponse.builder().withIdBrokerMappingSource(IdBrokerMappingSource.MOCK).withCredential(new CredentialResponse()).withAdminGroupName(ADMIN_GROUP_NAME).withCrn(TestConstants.CRN).build();
    when(credentialToCloudCredentialConverter.convert(credential)).thenReturn(cloudCredential);
    when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
    when(credentialConverter.convert(any(CredentialResponse.class))).thenReturn(credential);
    when(awsMockAccountMappingService.getGroupMappings(REGION, cloudCredential, ADMIN_GROUP_NAME)).thenReturn(MOCK_GROUP_MAPPINGS);
    when(awsMockAccountMappingService.getUserMappings(REGION, cloudCredential)).thenReturn(MOCK_USER_MAPPINGS);
    when(ldapConfigService.get(anyString(), anyString())).thenReturn(Optional.empty());
    when(clusterService.getById(anyLong())).thenReturn(cluster);
    when(customConfigurationsService.getByNameOrCrn(any(NameOrCrn.class))).thenReturn(customConfigurations);
    when(exposedServiceCollector.getAllKnoxExposed(any())).thenReturn(Set.of());
    when(resourceService.getAllByStackId(anyLong())).thenReturn(Collections.EMPTY_LIST);
    IdBroker idbroker = idBrokerConverterUtil.generateIdBrokerSignKeys(cluster);
    when(idBrokerService.getByCluster(any(Cluster.class))).thenReturn(idbroker);
    when(idBrokerService.save(any(IdBroker.class))).thenReturn(idbroker);
    when(grpcUmsClient.listServicePrincipalCloudIdentities(anyString(), anyString(), any(Optional.class))).thenReturn(Collections.EMPTY_LIST);
    when(dbCertificateProvider.getSslCertsFilePath()).thenReturn(SSL_CERTS_FILE_PATH);
    when(stackMock.getId()).thenReturn(1L);
    when(generalClusterConfigsProvider.generalClusterConfigs(any(Stack.class), any(Cluster.class))).thenReturn(new GeneralClusterConfigs());
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) User(com.sequenceiq.cloudbreak.workspace.model.User) Optional(java.util.Optional) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Json(com.sequenceiq.cloudbreak.common.json.Json) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 20 with CredentialResponse

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

the class StackToStackV4ResponseConverterTest method setUp.

@Before
public void setUp() throws CloudbreakImageNotFoundException {
    underTest = new StackToStackV4ResponseConverter();
    MockitoAnnotations.initMocks(this);
    when(imageService.getImage(anyLong())).thenReturn(new Image("cb-centos66-amb200-2015-05-25", Collections.emptyMap(), "redhat6", "redhat6", "", "default", "default-id", new HashMap<>()));
    when(componentConfigProviderService.getCloudbreakDetails(anyLong())).thenReturn(new CloudbreakDetails("version"));
    when(componentConfigProviderService.getStackTemplate(anyLong())).thenReturn(new StackTemplate("{}", "version"));
    when(componentConfigProviderService.getTelemetry(anyLong())).thenReturn(new Telemetry());
    Mockito.doAnswer(answer -> {
        StackV4Response result = answer.getArgument(1, StackV4Response.class);
        result.setSharedService(new SharedServiceV4Response());
        return null;
    }).when(datalakeService).addSharedServiceResponse(any(Stack.class), any(StackV4Response.class));
    when(serviceEndpointCollector.filterByStackType(any(StackType.class), any(List.class))).thenReturn(new ArrayList());
    credentialResponse = new CredentialResponse();
    credentialResponse.setName("cred-name");
    credentialResponse.setCrn("crn");
    when(loadBalancerService.findByStackId(any())).thenReturn(Set.of());
}
Also used : HashMap(java.util.HashMap) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) ArrayList(java.util.ArrayList) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) StackToStackV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.StackToStackV4ResponseConverter) StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) List(java.util.List) ArrayList(java.util.ArrayList) Before(org.junit.Before)

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