@Test public void testValidateSecurityZoneWitoutServicesAdminUserAdminUserGroupAuditUserAuditUserGroupForCreateThrowsError() throws Exception{ RangerSecurityZone suppliedSecurityZone = getRangerSecurityZone(); suppliedSecurityZone.setAdminUserGroups(null); suppliedSecurityZone.setAdminUsers(null); suppliedSecurityZone.setAuditUserGroups(null); suppliedSecurityZone.setAuditUsers(null); suppliedSecurityZone.setServices(null); Mockito.when(_store.getSecurityZone("MyZone")).thenReturn(null); try { rangerSecurityZoneValidator.validate(suppliedSecurityZone, RangerValidator.Action.CREATE); } catch (Exception ex) { Assert.assertEquals( ex.getMessage(), "(0) Validation failure: error code[3044], reason[No services specified for security-zone:[MyZone]], field[services], subfield[null], type[missing] (1) Validation failure: error code[3038], reason[both users and user-groups collections for the security zone were null/empty], field[security zone admin users/user-groups], subfield[null], type[missing] (2) Validation failure: error code[3038], reason[both users and user-groups collections for the security zone were null/empty], field[security zone audit users/user-groups], subfield[null], type[missing] "); } }
public void validate(RangerSecurityZone securityZone, Action action) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } List<ValidationFailureDetails> failures = new ArrayList<>(); boolean valid = isValid(securityZone, action, failures); String message; try { if (!valid) { message = serializeFailures(failures); throw new Exception(message); } } finally { if (LOG.isDebugEnabled()) { LOG.debug(String.format("<== RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } } }
RangerSecurityZoneValidator extends RangerValidator { public void validate(RangerSecurityZone securityZone, Action action) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } List<ValidationFailureDetails> failures = new ArrayList<>(); boolean valid = isValid(securityZone, action, failures); String message; try { if (!valid) { message = serializeFailures(failures); throw new Exception(message); } } finally { if (LOG.isDebugEnabled()) { LOG.debug(String.format("<== RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } } } }
RangerSecurityZoneValidator extends RangerValidator { public void validate(RangerSecurityZone securityZone, Action action) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } List<ValidationFailureDetails> failures = new ArrayList<>(); boolean valid = isValid(securityZone, action, failures); String message; try { if (!valid) { message = serializeFailures(failures); throw new Exception(message); } } finally { if (LOG.isDebugEnabled()) { LOG.debug(String.format("<== RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } } } RangerSecurityZoneValidator(ServiceStore store, SecurityZoneStore securityZoneStore); }
RangerSecurityZoneValidator extends RangerValidator { public void validate(RangerSecurityZone securityZone, Action action) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } List<ValidationFailureDetails> failures = new ArrayList<>(); boolean valid = isValid(securityZone, action, failures); String message; try { if (!valid) { message = serializeFailures(failures); throw new Exception(message); } } finally { if (LOG.isDebugEnabled()) { LOG.debug(String.format("<== RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } } } RangerSecurityZoneValidator(ServiceStore store, SecurityZoneStore securityZoneStore); void validate(RangerSecurityZone securityZone, Action action); }
RangerSecurityZoneValidator extends RangerValidator { public void validate(RangerSecurityZone securityZone, Action action) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } List<ValidationFailureDetails> failures = new ArrayList<>(); boolean valid = isValid(securityZone, action, failures); String message; try { if (!valid) { message = serializeFailures(failures); throw new Exception(message); } } finally { if (LOG.isDebugEnabled()) { LOG.debug(String.format("<== RangerPolicyValidator.validate(%s, %s)", securityZone, action)); } } } RangerSecurityZoneValidator(ServiceStore store, SecurityZoneStore securityZoneStore); void validate(RangerSecurityZone securityZone, Action action);  }