use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackSubmissionEditPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("not enough parameters");
String[] paramsWithoutCourseId = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
String[] paramsWithoutFeedbackSessionName = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId() };
verifyAssumptionFailure(paramsWithoutCourseId);
verifyAssumptionFailure(paramsWithoutFeedbackSessionName);
______TS("Test null feedback session name parameter");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.USER_ID, instructor.googleId };
InstructorFeedbackSubmissionEditPageAction a;
ShowPageResult r;
try {
a = getAction(submissionParams);
r = getShowPageResult(a);
signalFailureToDetectException("Did not detect that parameters are null.");
} catch (NullPostParameterException e) {
assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.FEEDBACK_SESSION_NAME), e.getMessage());
}
______TS("Test null course id parameter");
submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
try {
a = getAction(submissionParams);
r = getShowPageResult(a);
signalFailureToDetectException("Did not detect that parameters are null.");
} catch (NullPostParameterException e) {
assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), e.getMessage());
}
______TS("Test insufficient authorization");
instructor = typicalBundle.instructors.get("helperOfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
try {
a = getAction(submissionParams);
r = getShowPageResult(a);
signalFailureToDetectException("Did not detect insufficient authorization.");
} catch (UnauthorizedAccessException e) {
assertEquals("Feedback session [First feedback session] is not accessible to instructor " + "[helper@course1.tmt] for this purpose", e.getMessage());
}
______TS("Test feedback session that does not exist");
instructor = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, "feedback session that does not exist", Const.ParamsNames.USER_ID, instructor.googleId };
a = getAction(submissionParams);
RedirectResult rr = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, false, instructor.googleId), rr.getDestinationWithParams());
assertFalse(rr.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SESSION_DELETED_NO_ACCESS, rr.getStatusMessage());
______TS("typical success case");
String[] params = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
a = getAction(params);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, r.getStatusMessage());
______TS("masquerade mode");
gaeSimulation.loginAsAdmin("admin.user");
a = getAction(params);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, r.getStatusMessage());
______TS("closed session case");
gaeSimulation.loginAsInstructor(instructor.googleId);
session = typicalBundle.feedbackSessions.get("closedSession");
params = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
a = getAction(params);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_NOT_OPEN, r.getStatusMessage());
______TS("private session case");
instructor = typicalBundle.instructors.get("instructor1OfCourse2");
session = typicalBundle.feedbackSessions.get("session1InCourse2");
gaeSimulation.loginAsInstructor(instructor.googleId);
params = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
a = getAction(params);
r = getShowPageResult(a);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, r.getStatusMessage());
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackSubmissionEditSaveActionTest method testGracePeriodAccessControlForInstructors.
private void testGracePeriodAccessControlForInstructors() throws Exception {
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("gracePeriodSession");
closeSession(fs);
assertFalse(fs.isOpened());
assertTrue(fs.isInGracePeriod());
assertFalse(fs.isClosed());
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
verifyOnlyInstructorsOfTheSameCourseCanAccess(submissionParams);
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackDeleteActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session2InCourse1");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
verifyUnaccessibleWithoutLogin(submissionParams);
verifyUnaccessibleForUnregisteredUsers(submissionParams);
verifyUnaccessibleForStudents(submissionParams);
verifyUnaccessibleForInstructorsOfOtherCourses(submissionParams);
verifyUnaccessibleWithoutModifySessionPrivilege(submissionParams);
verifyAccessibleForInstructorsOfTheSameCourse(submissionParams);
// recreate the entity
FeedbackSessionsLogic.inst().createFeedbackSession(fs);
verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackDeleteActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
FeedbackSessionsDb fsDb = new FeedbackSessionsDb();
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
assertNotNull(fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName()));
InstructorFeedbackDeleteAction a = getAction(submissionParams);
RedirectResult r = getRedirectResult(a);
assertNull(fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName()));
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertEquals(Const.StatusMessages.FEEDBACK_SESSION_DELETED, r.getStatusMessage());
assertFalse(r.isError);
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackEditCopyActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
String[] params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "Session with valid name", Const.ParamsNames.COPIED_COURSES_ID, "idOfTypicalCourse2", Const.ParamsNames.COPIED_COURSES_ID, "idOfSampleCourse-demo" };
verifyUnaccessibleWithoutViewSessionInSectionsPrivilege(params);
FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("openSession");
CourseAttributes course = dataBundle.courses.get("course");
______TS("Failure case: copying from course with insufficient permission");
InstructorAttributes instructor = dataBundle.instructors.get("teammates.test.instructor3");
String instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, course.getId() };
InstructorFeedbackEditCopyAction a = getAction(params);
try {
a.executeAndPostProcess();
signalFailureToDetectException();
} catch (UnauthorizedAccessException uae) {
String expectedString = "Course [FeedbackEditCopy.CS2104] is not accessible to instructor " + "[tmms.instr.cust@course.tmt] for privilege [canviewsessioninsection]";
assertEquals(expectedString, uae.getMessage());
}
gaeSimulation.logoutUser();
______TS("Failure case: copying to course with insufficient permission");
instructor = dataBundle.instructors.get("teammates.test.instructor2");
instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, "FeedbackEditCopy.CS2107" };
a = getAction(params);
try {
a.executeAndPostProcess();
signalFailureToDetectException();
} catch (UnauthorizedAccessException uae) {
String expectedString = "Course [FeedbackEditCopy.CS2107] is not accessible to instructor " + "[tmms.instr@course.tmt] for privilege [canmodifysession]";
assertEquals(expectedString, uae.getMessage());
}
}
Aggregations