use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class NoSqlTableCreationModeDeterminerServiceTest method determineCreationModeCreateNew.
@Test
void determineCreationModeCreateNew() {
NoSqlTableMetadataResponse metadataResponse = NoSqlTableMetadataResponse.builder().withStatus(ResponseStatus.RESOURCE_NOT_FOUND).build();
when(noSql.getNoSqlTableMetaData(any())).thenReturn(metadataResponse);
Credential credential = new Credential();
credential.setCloudPlatform("platform");
S3GuardTableCreation mode = underTest.determineCreationMode(LocationAwareCredential.builder().withLocation("location").withCredential(credential).build(), "tablename");
assertEquals(S3GuardTableCreation.CREATE_NEW, mode);
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class AwsEnvironmentSecurityGroupValidatorTest method getCredential.
private Credential getCredential() {
Credential credential = new Credential();
credential.setName("apple");
return credential;
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class NoSqlTableCreationModeDeterminerService method getNoSqlTableMetaData.
private NoSqlTableMetadataResponse getNoSqlTableMetaData(LocationAwareCredential locationAwareCredential, String dynamoDbTablename) {
Credential credential = locationAwareCredential.getCredential();
String cloudPlatform = credential.getCloudPlatform();
String location = locationAwareCredential.getLocation();
NoSqlConnector noSqlConnector = getNoSqlConnector(cloudPlatform);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
NoSqlTableMetadataRequest request = NoSqlTableMetadataRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
return noSqlConnector.getNoSqlTableMetaData(request);
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class CloudStorageValidator method validateCloudStorage.
public ObjectStorageValidateResponse validateCloudStorage(String accountId, EnvironmentCloudStorageValidationRequest environmentCloudStorageValidationRequest) {
Credential credential = credentialService.getByCrnForAccountId(environmentCloudStorageValidationRequest.getCredentialCrn(), accountId, ENVIRONMENT, false);
String attributes = credential.getAttributes();
CloudCredential cloudCredential = new CloudCredential(credential.getResourceCrn(), credential.getName(), new Json(attributes).getMap(), credential.getAccountId(), credential.isVerifyPermissions());
CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
TelemetryRequest telemetryRequest = environmentCloudStorageValidationRequest.getTelemetry();
boolean loggingConfigured = isLoggingConfigured(telemetryRequest);
if (loggingConfigured) {
LOGGER.debug("Cloud storage logging is enabled.");
addLogIdentity(cloudStorageRequest, telemetryRequest);
}
ObjectStorageValidateRequest.Builder objectStorageValidateBuilder = ObjectStorageValidateRequest.builder().withCloudPlatform(credential.getCloudPlatform()).withCredential(cloudCredential).withCloudStorageRequest(cloudStorageRequest);
if (loggingConfigured) {
objectStorageValidateBuilder.withLogsLocationBase(telemetryRequest.getLogging().getStorageLocation());
}
if (environmentCloudStorageValidationRequest.getBackup() != null) {
objectStorageValidateBuilder.withBackupLocationBase(environmentCloudStorageValidationRequest.getBackup().getStorageLocation());
}
ObjectStorageValidateRequest objectStorageValidateRequest = objectStorageValidateBuilder.build();
return ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> cloudProviderServicesV4Endpoint.validateObjectStorage(objectStorageValidateRequest));
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class FreeIpaCreationHandlerTest method testImageCatalogAndImageIdParemetersArePopulated.
@Test
public void testImageCatalogAndImageIdParemetersArePopulated() {
EnvironmentDto environmentDto = someEnvironmentWithFreeIpaCreation();
environmentDto.getFreeIpaCreation().setImageId(IMAGE_ID);
environmentDto.getFreeIpaCreation().setImageCatalog(IMAGE_CATALOG);
environmentDto.setCredential(new Credential());
Environment environment = new Environment();
environment.setCreateFreeIpa(true);
ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build();
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
when(supportedPlatforms.supportedPlatformForFreeIpa(environment.getCloudPlatform())).thenReturn(true);
when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(Optional.empty());
when(connectors.getDefault(any())).thenReturn(mock(CloudConnector.class));
when(freeIpaPollingService.pollWithTimeout(any(FreeIpaCreationRetrievalTask.class), any(FreeIpaPollerObject.class), anyLong(), anyInt(), anyInt())).thenReturn(extendedPollingResult);
victim.accept(new Event<>(environmentDto));
ArgumentCaptor<CreateFreeIpaRequest> freeIpaRequestCaptor = ArgumentCaptor.forClass(CreateFreeIpaRequest.class);
verify(freeIpaService).create(freeIpaRequestCaptor.capture());
CreateFreeIpaRequest freeIpaRequest = freeIpaRequestCaptor.getValue();
assertEquals(IMAGE_CATALOG, freeIpaRequest.getImage().getCatalog());
assertEquals(IMAGE_ID, freeIpaRequest.getImage().getId());
}
Aggregations