use of org.apache.ranger.plugin.model.RangerSecurityZone in project ranger by apache.
the class RangerSecurityZoneValidatorTest method testIsValidSecurityZoneForDeleteWithWrongNameReturnFalse.
@Test
public void testIsValidSecurityZoneForDeleteWithWrongNameReturnFalse() throws Exception {
RangerSecurityZone suppliedSecurityZone = getRangerSecurityZone();
Mockito.when(_store.getSecurityZone(suppliedSecurityZone.getName())).thenReturn(null);
List<ValidationFailureDetails> failures = new ArrayList<ValidationFailureDetails>();
boolean isValid = rangerSecurityZoneValidator.isValid(suppliedSecurityZone.getName(), RangerValidator.Action.DELETE, failures);
Assert.assertFalse(isValid);
}
use of org.apache.ranger.plugin.model.RangerSecurityZone in project ranger by apache.
the class RangerSecurityZoneValidatorTest method testValidateSecurityZoneWithoutNameForCreate.
@Test
public void testValidateSecurityZoneWithoutNameForCreate() throws Exception {
RangerSecurityZone suppliedSecurityZone = new RangerSecurityZone();
suppliedSecurityZone.setName(null);
try {
rangerSecurityZoneValidator.validate(suppliedSecurityZone, RangerValidator.Action.CREATE);
} catch (Exception ex) {
Assert.assertEquals(ex.getMessage(), "(0) Validation failure: error code[3035], reason[Internal error: missing field[name]], field[name], subfield[null], type[missing] ");
}
}
use of org.apache.ranger.plugin.model.RangerSecurityZone in project ranger by apache.
the class RangerSecurityZoneValidatorTest method testIsValidSecurityZoneForDeleteWithWrongIdReturnFalse.
@Test
public void testIsValidSecurityZoneForDeleteWithWrongIdReturnFalse() throws Exception {
RangerSecurityZone suppliedSecurityZone = getRangerSecurityZone();
Mockito.when(_store.getSecurityZone(suppliedSecurityZone.getId())).thenReturn(null);
List<ValidationFailureDetails> failures = new ArrayList<ValidationFailureDetails>();
boolean isValid = rangerSecurityZoneValidator.isValid(suppliedSecurityZone.getId(), RangerValidator.Action.DELETE, failures);
Assert.assertFalse(isValid);
}
use of org.apache.ranger.plugin.model.RangerSecurityZone in project ranger by apache.
the class RangerSecurityZoneValidatorTest method testValidateSecurityZoneWitoutServicesAdminUserAdminUserGroupAuditUserAuditUserGroupForCreateThrowsError.
@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] ");
}
}
use of org.apache.ranger.plugin.model.RangerSecurityZone in project ranger by apache.
the class RangerSecurityZoneValidatorTest method testIsValidSecurityZoneIdForDeleteWithWrongActionTypeReturnFalse.
@Test
public void testIsValidSecurityZoneIdForDeleteWithWrongActionTypeReturnFalse() throws Exception {
RangerSecurityZone suppliedSecurityZone = getRangerSecurityZone();
List<ValidationFailureDetails> failures = new ArrayList<ValidationFailureDetails>();
boolean isValid = rangerSecurityZoneValidator.isValid(suppliedSecurityZone.getId(), RangerValidator.Action.UPDATE, failures);
Assert.assertFalse(isValid);
}
Aggregations