use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class StudentProfilePageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
AccountAttributes student = typicalBundle.accounts.get("student1InCourse1");
testActionSuccess(student, "Typical case");
testActionInMasquerade(student);
student = typicalBundle.accounts.get("student1InTestingSanitizationCourse");
// simulate sanitization that occurs before persistence
student.sanitizeForSaving();
testActionSuccess(student, "Typical case: attempted script injection");
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class StudentProfilePictureActionTest method testActionWithEmailAndCourseUnauthorisedInstructorOrStudentMasquerade.
private void testActionWithEmailAndCourseUnauthorisedInstructorOrStudentMasquerade() {
String[] submissionParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, StringHelper.encrypt(student.email), Const.ParamsNames.COURSE_ID, StringHelper.encrypt(student.course) };
______TS("Failure case: unauthorised student masqueraded as a student from same team");
AccountAttributes unauthStudent = typicalBundle.accounts.get("student1InArchivedCourse");
gaeSimulation.loginAsStudent(unauthStudent.googleId);
try {
getAction(addUserIdToParams(student.googleId, submissionParams));
signalFailureToDetectException();
} catch (UnauthorizedAccessException uae) {
assertEquals("User student1InArchivedCourse is trying to masquerade as" + " student1InCourse1 without admin permission.", uae.getMessage());
}
______TS("Failure case: unauthorised instructor masqueraded as an authorised instructor");
AccountAttributes unauthInstructor = typicalBundle.accounts.get("instructor1OfCourse2");
AccountAttributes instructor = typicalBundle.accounts.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(unauthInstructor.googleId);
try {
getAction(addUserIdToParams(instructor.googleId, submissionParams));
signalFailureToDetectException();
} catch (UnauthorizedAccessException uae) {
assertEquals("User idOfInstructor1OfCourse2 is trying to masquerade as" + " idOfInstructor1OfCourse1 without admin permission.", uae.getMessage());
}
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class StudentProfilePictureActionTest method testActionWithEmailAndCourse.
/**
* Tests the branch of the Action handling a request from an Instructor,
* where the parameters are the student's course and email.
*/
private void testActionWithEmailAndCourse() throws Exception {
AccountAttributes instructor = typicalBundle.accounts.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor("idOfInstructor1OfCourse1");
testActionWithEmailAndCourseSuccessTypical(instructor);
testActionWithEmailAndCourseNoStudent();
testActionWithEmailAndCourseForUnregStudent();
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class InstructorCourseJoinEmailWorkerActionTest method allTests.
@Test
public void allTests() {
CourseAttributes course1 = dataBundle.courses.get("typicalCourse1");
InstructorAttributes instr1InCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
AccountAttributes inviter = AccountsLogic.inst().getAccount("idOfInstructor2OfCourse1");
String[] submissionParams = new String[] { ParamsNames.COURSE_ID, course1.getId(), ParamsNames.INSTRUCTOR_EMAIL, instr1InCourse1.email, ParamsNames.INVITER_ID, inviter.googleId };
InstructorCourseJoinEmailWorkerAction action = getAction(submissionParams);
action.execute();
verifyNumberOfEmailsSent(action, 1);
EmailWrapper email = action.getEmailSender().getEmailsSent().get(0);
assertEquals(String.format(EmailType.INSTRUCTOR_COURSE_JOIN.getSubject(), course1.getName(), course1.getId()), email.getSubject());
assertEquals(instr1InCourse1.email, email.getRecipient());
}
use of teammates.common.datatransfer.attributes.AccountAttributes in project teammates by TEAMMATES.
the class ErrorUserReportLogActionTest method testExecuteAndPostProcess.
@Override
@Test
protected void testExecuteAndPostProcess() throws Exception {
InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
______TS("Typical Success Case");
final String testErrorReportSubject = "Test Error Subject";
final String testErrorReportContent = "This is a test user-submitted error report.";
final String testErrorReportRequestedUrl = "/page/testurl";
String[] params = new String[] { Const.ParamsNames.ERROR_FEEDBACK_URL_REQUESTED, testErrorReportRequestedUrl, Const.ParamsNames.ERROR_FEEDBACK_EMAIL_SUBJECT, testErrorReportSubject, Const.ParamsNames.ERROR_FEEDBACK_EMAIL_CONTENT, testErrorReportContent };
ErrorUserReportLogAction action = getAction(params);
AjaxResult result = getAjaxResult(action);
assertEquals(Const.StatusMessages.ERROR_FEEDBACK_SUBMIT_SUCCESS, result.getStatusMessage());
// getting basic AccountAttributes because ErrorUserReportLogAction only logs this.
AccountAttributes instructor1ofCourse1AccountAttributes = accountsLogic.getAccount(instructor1ofCourse1.googleId, false);
final String expectedLogMessage = "====== USER FEEDBACK ABOUT ERROR ====== \n" + "REQUESTED URL: " + testErrorReportRequestedUrl + "\n" + "ACCOUNT DETAILS: " + instructor1ofCourse1AccountAttributes.toString() + "\n" + "SUBJECT: " + testErrorReportSubject + "\n" + "FEEDBACK: " + testErrorReportContent;
assertEquals(expectedLogMessage, action.getUserErrorReportLogMessage());
}
Aggregations