Search in sources :

Example 11 with AccountAttributes

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");
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) Test(org.testng.annotations.Test)

Example 12 with AccountAttributes

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());
    }
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException)

Example 13 with AccountAttributes

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();
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes)

Example 14 with AccountAttributes

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());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InstructorCourseJoinEmailWorkerAction(teammates.ui.automated.InstructorCourseJoinEmailWorkerAction) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper) Test(org.testng.annotations.Test)

Example 15 with AccountAttributes

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());
}
Also used : AjaxResult(teammates.ui.controller.AjaxResult) ErrorUserReportLogAction(teammates.ui.controller.ErrorUserReportLogAction) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Aggregations

AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)84 Test (org.testng.annotations.Test)53 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)28 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)16 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)15 ArrayList (java.util.ArrayList)13 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)11 HashMap (java.util.HashMap)7 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)6 InvalidParametersException (teammates.common.exception.InvalidParametersException)6 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)5 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)4 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)4 EmailWrapper (teammates.common.util.EmailWrapper)4 RedirectResult (teammates.ui.controller.RedirectResult)4 List (java.util.List)3 EmailGenerator (teammates.logic.api.EmailGenerator)3 AccountsDb (teammates.storage.api.AccountsDb)3 Account (teammates.storage.entity.Account)3 ShowPageResult (teammates.ui.controller.ShowPageResult)3