mirror of
https://github.com/valitydev/org-manager.git
synced 2024-11-06 00:15:23 +00:00
bump tomcat core
This commit is contained in:
parent
c946d65778
commit
6155882f39
@ -2,4 +2,7 @@ package com.rbkmoney.orgmanager.exception;
|
||||
|
||||
public class BouncerException extends RuntimeException {
|
||||
|
||||
public BouncerException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.rbkmoney.orgmanager.exception;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
@ -7,6 +8,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
|
||||
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class RestExceptionHandler extends ResponseEntityExceptionHandler {
|
||||
|
||||
@ -26,6 +28,7 @@ public class RestExceptionHandler extends ResponseEntityExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = {BouncerException.class})
|
||||
protected ResponseEntity<Object> handleBouncerException(BouncerException ex, WebRequest request) {
|
||||
log.error(ex.getMessage(), ex.getCause());
|
||||
return ResponseEntity
|
||||
.status(HttpStatus.FAILED_DEPENDENCY)
|
||||
.build();
|
||||
|
@ -9,11 +9,9 @@ import com.rbkmoney.orgmanager.config.properties.BouncerProperties;
|
||||
import com.rbkmoney.orgmanager.exception.BouncerException;
|
||||
import com.rbkmoney.orgmanager.service.dto.BouncerContextDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.thrift.TException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BouncerServiceImpl implements BouncerService {
|
||||
@ -30,11 +28,9 @@ public class BouncerServiceImpl implements BouncerService {
|
||||
Resolution resolution = judge.getResolution();
|
||||
return resolution.isSetAllowed();
|
||||
} catch (UserNotFound e) {
|
||||
log.error("Error while build bouncer context", e);
|
||||
throw new BouncerException();
|
||||
throw new BouncerException("Error while build bouncer context", e);
|
||||
} catch (TException e) {
|
||||
log.error("Error while call bouncer", e);
|
||||
throw new BouncerException();
|
||||
throw new BouncerException("Error while call bouncer", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class OrgsControllerTest extends AbstractControllerTest {
|
||||
|
||||
@Test
|
||||
void expelOrgMemberWithErrorCallBouncer() throws Exception {
|
||||
doThrow(new BouncerException()).when(resourceAccessService)
|
||||
doThrow(new BouncerException("Error bouncer", new RuntimeException())).when(resourceAccessService)
|
||||
.checkMemberRights(ORGANIZATION_ID, MEMBER_ID);
|
||||
|
||||
mockMvc.perform(delete(String.format("/orgs/%s/members/%s", ORGANIZATION_ID, MEMBER_ID))
|
||||
|
@ -13,6 +13,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@ -44,6 +46,7 @@ class BouncerServiceImplTest {
|
||||
|
||||
var exception = assertThrows(BouncerException.class, () -> bouncerService.havePrivileges(bouncerContext));
|
||||
|
||||
assertThat(exception.getMessage(), containsString("Error while build bouncer context"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -53,6 +56,8 @@ class BouncerServiceImplTest {
|
||||
when(bouncerClient.judge(anyString(), any(Context.class))).thenThrow(new RulesetNotFound());
|
||||
|
||||
var exception = assertThrows(BouncerException.class, () -> bouncerService.havePrivileges(bouncerContext));
|
||||
|
||||
assertThat(exception.getMessage(), containsString("Error while call bouncer"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user