Search in sources :

Example 11 with Credential

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);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) LocationAwareCredential(com.sequenceiq.environment.environment.domain.LocationAwareCredential) S3GuardTableCreation(com.sequenceiq.environment.parameter.dto.s3guard.S3GuardTableCreation) NoSqlTableMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataResponse) Test(org.junit.jupiter.api.Test)

Example 12 with Credential

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;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential)

Example 13 with 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);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) LocationAwareCredential(com.sequenceiq.environment.environment.domain.LocationAwareCredential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) NoSqlConnector(com.sequenceiq.cloudbreak.cloud.NoSqlConnector) NoSqlTableMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest)

Example 14 with Credential

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));
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Json(com.sequenceiq.cloudbreak.common.json.Json) ObjectStorageValidateRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateRequest)

Example 15 with Credential

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());
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Credential (com.sequenceiq.environment.credential.domain.Credential)102 Test (org.junit.jupiter.api.Test)49 Environment (com.sequenceiq.environment.environment.domain.Environment)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)13 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)10 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)9 EnvironmentAuthentication (com.sequenceiq.environment.environment.domain.EnvironmentAuthentication)9 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)9 BadRequestException (javax.ws.rs.BadRequestException)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)8 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)8 Set (java.util.Set)8 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)7 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)7 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)7 Map (java.util.Map)7 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)6 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)6