Search in sources :

Example 61 with Credential

use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.

the class CloudStorageValidatorTest method validateCloudStorageSkipLocationBaseWhenLoggingIsNotConfigured.

@Test
public void validateCloudStorageSkipLocationBaseWhenLoggingIsNotConfigured() {
    when(credentialService.getByCrnForAccountId(anyString(), anyString(), any(), anyBoolean())).thenReturn(new Credential());
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    EnvironmentCloudStorageValidationRequest request = new EnvironmentCloudStorageValidationRequest();
    request.setCredentialCrn("credential");
    ArgumentCaptor<ObjectStorageValidateRequest> requestCaptor = ArgumentCaptor.forClass(ObjectStorageValidateRequest.class);
    when(cloudProviderServicesV4Endpoint.validateObjectStorage(requestCaptor.capture())).thenReturn(ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).build());
    ObjectStorageValidateResponse response = underTest.validateCloudStorage("1234", request);
    assertEquals(ResponseStatus.OK, response.getStatus());
    assertNull(response.getError());
    assertNull(requestCaptor.getValue().getLogsLocationBase());
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) EnvironmentCloudStorageValidationRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentCloudStorageValidationRequest) ObjectStorageValidateResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse) ObjectStorageValidateRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateRequest) Test(org.junit.jupiter.api.Test)

Example 62 with Credential

use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.

the class NoSqlTableCreationModeDeterminerServiceTest method determineCreationModeExisting.

@Test
void determineCreationModeExisting() {
    NoSqlTableMetadataResponse metadataResponse = NoSqlTableMetadataResponse.builder().withId("id").withStatus(ResponseStatus.OK).withTableStatus("ACTIVE").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.USE_EXISTING, 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 63 with Credential

use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.

the class AzureEnvironmentSecurityGroupValidatorTest method getCredential.

private Credential getCredential() {
    Credential credential = new Credential();
    credential.setName("azure-credential");
    return credential;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential)

Example 64 with Credential

use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.

the class EnvironmentModificationServiceTest method changeCredentialByEnvironmentName.

@Test
void changeCredentialByEnvironmentName() {
    String credentialName = "credentialName";
    final Credential value = new Credential();
    EnvironmentChangeCredentialDto environmentChangeDto = EnvironmentChangeCredentialDto.EnvironmentChangeCredentialDtoBuilder.anEnvironmentChangeCredentialDto().withCredentialName(credentialName).build();
    when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(new Environment()));
    when(credentialService.getByNameForAccountId(eq(credentialName), eq(ACCOUNT_ID), eq(ENVIRONMENT))).thenReturn(value);
    environmentModificationServiceUnderTest.changeCredentialByEnvironmentName(ACCOUNT_ID, ENVIRONMENT_NAME, environmentChangeDto);
    ArgumentCaptor<Environment> environmentArgumentCaptor = ArgumentCaptor.forClass(Environment.class);
    verify(environmentService).save(environmentArgumentCaptor.capture());
    assertEquals(value, environmentArgumentCaptor.getValue().getCredential());
}
Also used : EnvironmentChangeCredentialDto(com.sequenceiq.environment.environment.dto.EnvironmentChangeCredentialDto) Credential(com.sequenceiq.environment.credential.domain.Credential) Environment(com.sequenceiq.environment.environment.domain.Environment) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 65 with Credential

use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.

the class EnvironmentResourceServiceTest method getCredentialFromRequest.

@Test
void getCredentialFromRequest() {
    Credential value = new Credential();
    when(credentialService.getByNameForAccountId(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID), any())).thenReturn(value);
    assertEquals(value, environmentResourceServiceUnderTest.getCredentialFromRequest(request, ACCOUNT_ID));
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Test(org.junit.jupiter.api.Test)

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