use of teammates.ui.controller.StudentProfileEditSaveAction in project teammates by TEAMMATES.
the class StudentProfileEditSaveActionTest method testActionInMasqueradeMode.
private void testActionInMasqueradeMode(AccountAttributes student) {
______TS("Typical case: masquerade mode");
gaeSimulation.loginAsAdmin("admin.user");
String[] submissionParams = createValidParamsForProfile();
StudentProfileAttributes expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
expectedProfile.googleId = student.googleId;
StudentProfileEditSaveAction action = getAction(addUserIdToParams(student.googleId, submissionParams));
RedirectResult result = getRedirectResult(action);
assertFalse(result.isError);
assertEquals(Const.StatusMessages.STUDENT_PROFILE_EDITED, result.getStatusMessage());
AssertHelper.assertContains(getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, false, student.googleId), result.getDestinationWithParams());
verifyLogMessage(student, action, expectedProfile, true);
}
use of teammates.ui.controller.StudentProfileEditSaveAction in project teammates by TEAMMATES.
the class StudentCourseDetailsPageActionTest method testTeamMemberDetailsOnViewTeamPage.
@Test
public void testTeamMemberDetailsOnViewTeamPage() {
AccountAttributes student = typicalBundle.accounts.get("student1InCourse1");
String[] submissionParams = createValidParamsForProfile();
StudentProfileAttributes expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
gaeSimulation.loginAsStudent(student.googleId);
// adding profile picture for student1InCourse1
StudentProfileEditSaveAction action = getStudentProfileEditSaveAction(submissionParams);
RedirectResult result = getRedirectResult(action);
expectedProfile.googleId = student.googleId;
assertFalse(result.isError);
StudentAttributes student1 = typicalBundle.students.get("student1InCourse1");
gaeSimulation.logoutUser();
gaeSimulation.loginAsStudent(typicalBundle.accounts.get("student2InCourse1").googleId);
String[] submissionParam = new String[] { Const.ParamsNames.COURSE_ID, student1.course };
StudentCourseDetailsPageAction pageAction = getAction(submissionParam);
ShowPageResult pageResult = getShowPageResult(pageAction);
StudentCourseDetailsPageData pageData = (StudentCourseDetailsPageData) pageResult.data;
List<StudentAttributes> actualStudentsList = pageData.getStudentCourseDetailsPanel().getTeammates();
boolean isStudentDisplayedOnViewTeam = false;
for (StudentAttributes stud : actualStudentsList) {
if (student1.email.equals(stud.email) && student1.name.equals(stud.name) && student1.getPublicProfilePictureUrl().equals(stud.getPublicProfilePictureUrl())) {
isStudentDisplayedOnViewTeam = true;
}
}
assertTrue(isStudentDisplayedOnViewTeam);
}
use of teammates.ui.controller.StudentProfileEditSaveAction in project teammates by TEAMMATES.
the class StudentProfileEditSaveActionTest method testActionSuccess.
private void testActionSuccess(AccountAttributes student, String caseDescription) {
String[] submissionParams = createValidParamsForProfile();
StudentProfileAttributes expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
gaeSimulation.loginAsStudent(student.googleId);
______TS(caseDescription);
StudentProfileEditSaveAction action = getAction(submissionParams);
RedirectResult result = getRedirectResult(action);
expectedProfile.googleId = student.googleId;
assertFalse(result.isError);
AssertHelper.assertContains(getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, false, student.googleId), result.getDestinationWithParams());
assertEquals(Const.StatusMessages.STUDENT_PROFILE_EDITED, result.getStatusMessage());
verifyLogMessage(student, action, expectedProfile, false);
}
use of teammates.ui.controller.StudentProfileEditSaveAction in project teammates by TEAMMATES.
the class StudentProfileEditSaveActionTest method testActionWithInvalidParameters.
private void testActionWithInvalidParameters(AccountAttributes student) throws Exception {
gaeSimulation.loginAsStudent(student.googleId);
______TS("Failure case: invalid parameters");
String[] submissionParams = createInvalidParamsForProfile();
StudentProfileAttributes expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
expectedProfile.googleId = student.googleId;
StudentProfileEditSaveAction action = getAction(submissionParams);
RedirectResult result = getRedirectResult(action);
assertTrue(result.isError);
AssertHelper.assertContains(getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, true, student.googleId), result.getDestinationWithParams());
List<String> expectedErrorMessages = new ArrayList<>();
expectedErrorMessages.add(getPopulatedErrorMessage(FieldValidator.INVALID_NAME_ERROR_MESSAGE, submissionParams[1], FieldValidator.PERSON_NAME_FIELD_NAME, FieldValidator.REASON_START_WITH_NON_ALPHANUMERIC_CHAR, FieldValidator.PERSON_NAME_MAX_LENGTH));
expectedErrorMessages.add(getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, submissionParams[3], FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.EMAIL_MAX_LENGTH));
AssertHelper.assertContains(expectedErrorMessages, result.getStatusMessage());
String expectedLogMessage = "TEAMMATESLOG|||studentProfileEditSave|||studentProfileEditSave" + "|||true|||Student|||" + student.name + "|||" + student.googleId + "|||" + student.email + "|||" + Const.ACTION_RESULT_FAILURE + " : " + result.getStatusMessage() + "|||/page/studentProfileEditSave";
AssertHelper.assertContainsRegex(expectedLogMessage, action.getLogMessage());
______TS("Failure case: invalid parameters with attempted script injection");
submissionParams = createInvalidParamsForProfileWithScriptInjection();
expectedProfile = getProfileAttributesFrom(student.googleId, submissionParams);
expectedProfile.googleId = student.googleId;
action = getAction(submissionParams);
result = getRedirectResult(action);
assertTrue(result.isError);
AssertHelper.assertContains(Const.ActionURIs.STUDENT_PROFILE_PAGE + "?error=true&user=" + student.googleId, result.getDestinationWithParams());
expectedErrorMessages = new ArrayList<>();
expectedErrorMessages.add(getPopulatedErrorMessage(FieldValidator.INVALID_NAME_ERROR_MESSAGE, SanitizationHelper.sanitizeForHtml(submissionParams[1]), FieldValidator.PERSON_NAME_FIELD_NAME, FieldValidator.REASON_CONTAINS_INVALID_CHAR, FieldValidator.PERSON_NAME_MAX_LENGTH));
expectedErrorMessages.add(getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, SanitizationHelper.sanitizeForHtml(submissionParams[3]), FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.EMAIL_MAX_LENGTH));
expectedErrorMessages.add(getPopulatedErrorMessage(FieldValidator.INVALID_NAME_ERROR_MESSAGE, SanitizationHelper.sanitizeForHtml(submissionParams[5]), FieldValidator.INSTITUTE_NAME_FIELD_NAME, FieldValidator.REASON_START_WITH_NON_ALPHANUMERIC_CHAR, FieldValidator.INSTITUTE_NAME_MAX_LENGTH));
expectedErrorMessages.add(String.format(FieldValidator.NATIONALITY_ERROR_MESSAGE, SanitizationHelper.sanitizeForHtml(submissionParams[7])));
expectedErrorMessages.add(String.format(FieldValidator.GENDER_ERROR_MESSAGE, SanitizationHelper.sanitizeForHtml(submissionParams[9])));
AssertHelper.assertContains(expectedErrorMessages, result.getStatusMessage());
expectedLogMessage = "TEAMMATESLOG|||studentProfileEditSave|||studentProfileEditSave" + "|||true|||Student|||" + student.name + "|||" + student.googleId + "|||" + student.email + "|||" + Const.ACTION_RESULT_FAILURE + " : " + result.getStatusMessage() + "|||/page/studentProfileEditSave";
AssertHelper.assertContainsRegex(expectedLogMessage, action.getLogMessage());
}
Aggregations