@Test public void testCanNotGetAccessThroughDeniedCohort() throws Exception { helper.generateTeacherSchool(TEACHER_ID, ED_ORG_ID); String cohortId = helper.generateCohort(ED_ORG_ID).getEntityId(); helper.generateStaffCohort(TEACHER_ID, cohortId, false, false); for (int i = 0; i < 10; ++i) { helper.generateStudentCohort(i + "", cohortId, false); studentIds.add(i + ""); } assertFalse(validator.validate(EntityNames.STUDENT, studentIds).size() == studentIds.size()); }
@Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; } }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }  }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext(); }
TeacherToStudentValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityName, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STUDENT, entityName, ids)) { return Collections.emptySet(); } Set<String> idsToValidate = new HashSet<String>(ids); Set<String> validIds = new HashSet<String>(); Set<String> validWithSections = getValidatedWithSections(idsToValidate); idsToValidate.removeAll(validWithSections); validIds.addAll(validWithSections); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } Set<String> validWithPrograms = getValidatedWithPrograms(idsToValidate); idsToValidate.removeAll(validWithPrograms); validIds.addAll(validWithPrograms); if (idsToValidate.isEmpty()) { validIds.retainAll(ids); return validIds; } validIds.addAll(getValidatedWithCohorts(idsToValidate)); validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityName, Set<String> ids); @Override Set<String> getValid(String entityType, Set<String> ids); @Override void setRepo(PagingRepositoryDelegate<Entity> repo); @Override SecurityUtil.UserContext getContext();  }