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()));
}
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()));
}
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());
}
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());
}
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());
}
Aggregations