@Test public final void test_getPoliciesForResourceSignature() throws Exception { String hexSignature = "aSignature"; String serviceName = "service-name"; boolean isPolicyEnabled = true; when(_store.getPoliciesByResourceSignature(serviceName, hexSignature, isPolicyEnabled)).thenReturn(null); Assert.assertNull(_validator.getPoliciesForResourceSignature(serviceName, hexSignature)); when(_store.getPoliciesByResourceSignature(serviceName, hexSignature, isPolicyEnabled)).thenThrow(new Exception()); Assert.assertNull(_validator.getPoliciesForResourceSignature(serviceName, hexSignature)); hexSignature = "anotherSignature"; List<RangerPolicy> policies = new ArrayList<>(); RangerPolicy policy1 = mock(RangerPolicy.class); policies.add(policy1); RangerPolicy policy2 = mock(RangerPolicy.class); policies.add(policy2); when(_store.getPoliciesByResourceSignature(serviceName, hexSignature, isPolicyEnabled)).thenReturn(policies); List<RangerPolicy> result = _validator.getPoliciesForResourceSignature(serviceName, hexSignature); Assert.assertTrue(result.contains(policy1) && result.contains(policy2)); }
List<RangerPolicy> getPoliciesForResourceSignature(String serviceName, String policySignature) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerValidator.getPoliciesForResourceSignature(%s, %s)", serviceName, policySignature)); } List<RangerPolicy> policies = null; try { policies = _store.getPoliciesByResourceSignature(serviceName, policySignature, true); } catch (Exception e) { LOG.debug("Encountred exception while retrieving policies from service store!", e); } if(LOG.isDebugEnabled()) { int count = policies == null ? 0 : policies.size(); LOG.debug(String.format("<== RangerValidator.getPoliciesForResourceSignature(%s, %s): count[%d], %s", serviceName, policySignature, count, policies)); } return policies; }
RangerValidator { List<RangerPolicy> getPoliciesForResourceSignature(String serviceName, String policySignature) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerValidator.getPoliciesForResourceSignature(%s, %s)", serviceName, policySignature)); } List<RangerPolicy> policies = null; try { policies = _store.getPoliciesByResourceSignature(serviceName, policySignature, true); } catch (Exception e) { LOG.debug("Encountred exception while retrieving policies from service store!", e); } if(LOG.isDebugEnabled()) { int count = policies == null ? 0 : policies.size(); LOG.debug(String.format("<== RangerValidator.getPoliciesForResourceSignature(%s, %s): count[%d], %s", serviceName, policySignature, count, policies)); } return policies; } }
RangerValidator { List<RangerPolicy> getPoliciesForResourceSignature(String serviceName, String policySignature) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerValidator.getPoliciesForResourceSignature(%s, %s)", serviceName, policySignature)); } List<RangerPolicy> policies = null; try { policies = _store.getPoliciesByResourceSignature(serviceName, policySignature, true); } catch (Exception e) { LOG.debug("Encountred exception while retrieving policies from service store!", e); } if(LOG.isDebugEnabled()) { int count = policies == null ? 0 : policies.size(); LOG.debug(String.format("<== RangerValidator.getPoliciesForResourceSignature(%s, %s): count[%d], %s", serviceName, policySignature, count, policies)); } return policies; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); }
RangerValidator { List<RangerPolicy> getPoliciesForResourceSignature(String serviceName, String policySignature) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerValidator.getPoliciesForResourceSignature(%s, %s)", serviceName, policySignature)); } List<RangerPolicy> policies = null; try { policies = _store.getPoliciesByResourceSignature(serviceName, policySignature, true); } catch (Exception e) { LOG.debug("Encountred exception while retrieving policies from service store!", e); } if(LOG.isDebugEnabled()) { int count = policies == null ? 0 : policies.size(); LOG.debug(String.format("<== RangerValidator.getPoliciesForResourceSignature(%s, %s): count[%d], %s", serviceName, policySignature, count, policies)); } return policies; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); void validate(Long id, Action action); void validate(String name, Action action); static String serializeFailures(List<ValidationFailureDetails> failures); }
RangerValidator { List<RangerPolicy> getPoliciesForResourceSignature(String serviceName, String policySignature) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerValidator.getPoliciesForResourceSignature(%s, %s)", serviceName, policySignature)); } List<RangerPolicy> policies = null; try { policies = _store.getPoliciesByResourceSignature(serviceName, policySignature, true); } catch (Exception e) { LOG.debug("Encountred exception while retrieving policies from service store!", e); } if(LOG.isDebugEnabled()) { int count = policies == null ? 0 : policies.size(); LOG.debug(String.format("<== RangerValidator.getPoliciesForResourceSignature(%s, %s): count[%d], %s", serviceName, policySignature, count, policies)); } return policies; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); void validate(Long id, Action action); void validate(String name, Action action); static String serializeFailures(List<ValidationFailureDetails> failures);  }