@Test public void testCheckRight() { when(grpcUmsClient.hasRights(anyString(), anyString(), any(), any())).thenReturn(Lists.newArrayList(Boolean.TRUE, Boolean.FALSE)); CheckRightV4Request rightReq = new CheckRightV4Request(); rightReq.setRights(Lists.newArrayList(RightV4.ENV_CREATE, RightV4.DISTROX_READ)); CheckRightV4Response rightResult = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.getRightResult(rightReq)); rightResult.getResponses().stream().forEach(checkRightV4SingleResponse -> { if (checkRightV4SingleResponse.getRight().equals(RightV4.ENV_CREATE)) { assertTrue(checkRightV4SingleResponse.getResult()); } if (checkRightV4SingleResponse.getRight().equals(RightV4.DISTROX_READ)) { assertFalse(checkRightV4SingleResponse.getResult()); } }); verify(grpcUmsClient, times(1)).hasRights(anyString(), anyString(), any(), any()); }
public CheckRightV4Response getRightResult(CheckRightV4Request rightReq) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); List<AuthorizationProto.RightCheck> rightChecks = rightReq.getRights().stream() .map(rightV4 -> createRightCheckObject(umsRightProvider.getRight(rightV4.getAction()), null)) .collect(Collectors.toList()); List<Boolean> results = grpcUmsClient.hasRights(userCrn, userCrn, rightChecks, MDCUtils.getRequestId()); return new CheckRightV4Response(rightReq.getRights().stream() .map(rightV4 -> new CheckRightV4SingleResponse(rightV4, results.get(rightReq.getRights().indexOf(rightV4)))) .collect(Collectors.toList())); }
UtilAuthorizationService { public CheckRightV4Response getRightResult(CheckRightV4Request rightReq) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); List<AuthorizationProto.RightCheck> rightChecks = rightReq.getRights().stream() .map(rightV4 -> createRightCheckObject(umsRightProvider.getRight(rightV4.getAction()), null)) .collect(Collectors.toList()); List<Boolean> results = grpcUmsClient.hasRights(userCrn, userCrn, rightChecks, MDCUtils.getRequestId()); return new CheckRightV4Response(rightReq.getRights().stream() .map(rightV4 -> new CheckRightV4SingleResponse(rightV4, results.get(rightReq.getRights().indexOf(rightV4)))) .collect(Collectors.toList())); } }
UtilAuthorizationService { public CheckRightV4Response getRightResult(CheckRightV4Request rightReq) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); List<AuthorizationProto.RightCheck> rightChecks = rightReq.getRights().stream() .map(rightV4 -> createRightCheckObject(umsRightProvider.getRight(rightV4.getAction()), null)) .collect(Collectors.toList()); List<Boolean> results = grpcUmsClient.hasRights(userCrn, userCrn, rightChecks, MDCUtils.getRequestId()); return new CheckRightV4Response(rightReq.getRights().stream() .map(rightV4 -> new CheckRightV4SingleResponse(rightV4, results.get(rightReq.getRights().indexOf(rightV4)))) .collect(Collectors.toList())); }  }
UtilAuthorizationService { public CheckRightV4Response getRightResult(CheckRightV4Request rightReq) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); List<AuthorizationProto.RightCheck> rightChecks = rightReq.getRights().stream() .map(rightV4 -> createRightCheckObject(umsRightProvider.getRight(rightV4.getAction()), null)) .collect(Collectors.toList()); List<Boolean> results = grpcUmsClient.hasRights(userCrn, userCrn, rightChecks, MDCUtils.getRequestId()); return new CheckRightV4Response(rightReq.getRights().stream() .map(rightV4 -> new CheckRightV4SingleResponse(rightV4, results.get(rightReq.getRights().indexOf(rightV4)))) .collect(Collectors.toList())); }  CheckRightV4Response getRightResult(CheckRightV4Request rightReq); CheckResourceRightsV4Response getResourceRightsResult(CheckResourceRightsV4Request checkResourceRightsV4Request); }
UtilAuthorizationService { public CheckRightV4Response getRightResult(CheckRightV4Request rightReq) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); List<AuthorizationProto.RightCheck> rightChecks = rightReq.getRights().stream() .map(rightV4 -> createRightCheckObject(umsRightProvider.getRight(rightV4.getAction()), null)) .collect(Collectors.toList()); List<Boolean> results = grpcUmsClient.hasRights(userCrn, userCrn, rightChecks, MDCUtils.getRequestId()); return new CheckRightV4Response(rightReq.getRights().stream() .map(rightV4 -> new CheckRightV4SingleResponse(rightV4, results.get(rightReq.getRights().indexOf(rightV4)))) .collect(Collectors.toList())); }  CheckRightV4Response getRightResult(CheckRightV4Request rightReq); CheckResourceRightsV4Response getResourceRightsResult(CheckResourceRightsV4Request checkResourceRightsV4Request);  }