use of com.sequenceiq.environment.credential.exception.CredentialVerificationException in project cloudbreak by hortonworks.
the class SearchCauseExceptionMapperTest method testGetResponseStatusWhenHasTwoDepthsCause.
@Test
public void testGetResponseStatusWhenHasTwoDepthsCause() {
Response.Status actual = underTest.getResponseStatus(new CredentialVerificationException("", new RuntimeException(new NotFoundException())));
Assertions.assertEquals(Response.Status.NOT_FOUND, actual);
}
use of com.sequenceiq.environment.credential.exception.CredentialVerificationException in project cloudbreak by hortonworks.
the class SearchCauseExceptionMapperTest method testGetResponseStatusWhenTheCauseIsTheRealException.
@Test
public void testGetResponseStatusWhenTheCauseIsTheRealException() {
Response.Status actual = underTest.getResponseStatus(new CredentialVerificationException("", new NotFoundException(new Exception())));
Assertions.assertEquals(Response.Status.NOT_FOUND, actual);
}
use of com.sequenceiq.environment.credential.exception.CredentialVerificationException in project cloudbreak by hortonworks.
the class SearchCauseExceptionMapperTest method testGetResponseStatusWhenNoCause.
@Test
public void testGetResponseStatusWhenNoCause() {
Response.Status actual = underTest.getResponseStatus(new CredentialVerificationException(""));
Assertions.assertEquals(Response.Status.BAD_REQUEST, actual);
}
use of com.sequenceiq.environment.credential.exception.CredentialVerificationException in project cloudbreak by hortonworks.
the class SearchCauseExceptionMapperTest method testGetResponseStatusWhenTheExceptionIsTheFirstCause.
@Test
public void testGetResponseStatusWhenTheExceptionIsTheFirstCause() {
Response.Status actual = underTest.getResponseStatus(new CredentialVerificationException("", new Exception(new NotFoundException())));
Assertions.assertEquals(Response.Status.NOT_FOUND, actual);
}
use of com.sequenceiq.environment.credential.exception.CredentialVerificationException in project cloudbreak by hortonworks.
the class ServiceProviderCredentialAdapter method verify.
public CredentialVerification verify(Credential credential, String accountId, boolean creationVerification) {
boolean changed = false;
credential = credentialPrerequisiteService.decorateCredential(credential);
CloudContext cloudContext = CloudContext.Builder.builder().withId(credential.getId()).withName(credential.getName()).withCrn(credential.getResourceCrn()).withPlatform(credential.getCloudPlatform()).withVariant(credential.getCloudPlatform()).withAccountId(accountId).build();
CloudCredential cloudCredential = credentialConverter.convert(credential);
CredentialVerificationRequest request = requestProvider.getCredentialVerificationRequest(cloudContext, cloudCredential, creationVerification);
LOGGER.debug("Triggering event: {}", request);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
try {
CredentialVerificationResult res = request.await();
String message = FAILED_CREDETIAL_VERIFICATION_MESSAGE;
LOGGER.debug("Result: {}", res);
if (res.getStatus() != EventStatus.OK) {
LOGGER.info(message, res.getErrorDetails());
throw new CredentialVerificationException(message + res.getErrorDetails(), res.getErrorDetails());
}
CloudCredentialStatus cloudCredentialStatus = res.getCloudCredentialStatus();
if (CredentialStatus.FAILED.equals(cloudCredentialStatus.getStatus())) {
return new CredentialVerification(credential, setNewStatusText(credential, cloudCredentialStatus));
}
changed = setNewStatusText(credential, cloudCredentialStatus);
CloudCredential cloudCredentialResponse = cloudCredentialStatus.getCloudCredential();
if (cloudCredentialStatus.isDefaultRegionChanged()) {
changed = mergeCloudProviderParameters(credential, cloudCredentialResponse, Collections.singleton(SMART_SENSE_ID));
}
changed = changed || mergeCloudProviderParameters(credential, cloudCredentialResponse, Collections.singleton(SMART_SENSE_ID));
} catch (InterruptedException e) {
LOGGER.error("Error while executing credential verification", e);
throw new OperationException(e);
}
return new CredentialVerification(credential, changed);
}
Aggregations