Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#9564] Consolidate GET Student Profile RESTFul API #9580

Merged
merged 3 commits into from Apr 7, 2019

Conversation

Adoby7
Copy link
Contributor

@Adoby7 Adoby7 commented Mar 19, 2019

Part of #9564
Outline of Solution

The access control is following:

  1. A student can view his own profile.
  2. A student can view his teammate's profile in the same class.
  3. An instructor can view profiles of students in his class.

Case 1 requires no parameter.
Case 2, 3 require studentEmail and courseId as parameters.

updated: the profile page e2e test is updated because /student/profile endpoint is changed

@Adoby7 Adoby7 added s.ToReview The PR is waiting for review(s) s.Ongoing The PR is being worked on by the author(s) and removed s.ToReview The PR is waiting for review(s) labels Mar 19, 2019
@Adoby7 Adoby7 added s.ToReview The PR is waiting for review(s) and removed s.Ongoing The PR is being worked on by the author(s) labels Mar 19, 2019
Copy link
Member

@junming403 junming403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good work!

@Adoby7 Adoby7 requested a review from junming403 March 20, 2019 16:08
Copy link
Contributor

@ChooJeremy ChooJeremy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rrtheonlyone is probably more appropriate to review this, especially since he's also working on profile API. Here are my initial thoughts, I'll do a more thorough check when I have time to download this branch and test out the front end.

Copy link
Contributor

@rrtheonlyone rrtheonlyone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good 👍 I just have some comments.

@Adoby7 Adoby7 removed the request for review from junming403 March 21, 2019 14:24
@Adoby7 Adoby7 force-pushed the student_profile branch 3 times, most recently from 0879196 to fad5d7d Compare March 21, 2019 16:39
@Adoby7
Copy link
Contributor Author

Adoby7 commented Mar 21, 2019

close and reopen PR to solve "Failed to read manifest file" problem

@Adoby7 Adoby7 closed this Mar 21, 2019
@Adoby7 Adoby7 reopened this Mar 21, 2019
Copy link
Contributor

@rrtheonlyone rrtheonlyone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I just have one small suggestion.

@Adoby7 Adoby7 requested review from xpdavid and removed request for junming403 and xpdavid March 29, 2019 05:57
.build();
typicalBundle.students.put("unregisteredStudentInCourse1", unregisteredStudentInCourse1);
removeAndRestoreTypicalDataBundle();
removeAndRestoreDataBundle(typicalBundle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use logic.createStudent().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the logic does not have this function, and I think it's unnecessary to create one just for testing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the creation of student is really weird.

StudentsLogic.inst().createStudent?

src/web/services/student-profile.service.ts Show resolved Hide resolved
Copy link
Contributor

@ChooJeremy ChooJeremy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test consolidation still needs more work. Do take a look through the methods in BaseActionTest and make use of them if possible. Update them if necessary; as long as they don't break anything else. Don't rely on me to find them.

}

@Test
public void testAccessControl_instructorAccessOtherCourse_shouldFail() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge this method with testAccessControl_instructorAccessProfileFromHisCourse_shouldPass.
They're both testing for the same thing but one for validity and one for invalidity. Instead of doing these tests, you can just do:

Suggested change
public void testAccessControl_instructorAccessOtherCourse_shouldFail() {
public void testAccessControl_onlyInstructorsOfTheSameCourse_shouldPass() {
StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
String[] submissionParams = new String[] {
Const.ParamsNames.COURSE_ID, student1InCourse1.getCourse(),
Const.ParamsNames.STUDENT_EMAIL, student1InCourse1.getEmail(),
};
verifyAccessibleForInstructorsOfTheSameCourse(submissionParams);
verifyInaccessibleForInstructorsOfOtherCourses(submissionParams);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to split the test cases as a good practice

}

@Test
public void testAccessControl_instructorWithoutViewStudentInSectionPrivilege_shouldFail() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use verifyInaccessibleWithoutViewStudentInSectionsPrivilege in BaseActionTest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because I need to specify which privilege is needed to be tested, see comments below

@Adoby7
Copy link
Contributor Author

Adoby7 commented Apr 2, 2019

Hi @ChooJeremy, I think using the BaseActionTest methods is not necessary in the following reasons:

  1. The method name of each test case has already self-explained the parameter and the result of this case. Therefore, even not using the BaseActionTest method, each case is described clearly and we can focus more on test case design.
  2. The BaseActionTest method may also confuse people. For example, the verifyAccessibleForInstructorInSameCourse simply uses instructor1InCourse1. Why this instructor is considered in the same course? How about I need to test other courses?
  3. Some testing will be designed improperly using the BaseActionTest method. For example, the testAccessControl_instructorWithoutViewStudentInSectionPrivilege_shouldFail() that you have commented. The verifyInaccessibleWithoutViewStudentInSectionsPrivilege simply uses a helper account to represent an instructor without privilege. The only invalid value that causes inaccessible is ViewStudentInSectionPrivilege, but the helper account has no privilege at all (i.e. too many invalid values), and this may disrupt the accuracy of testing. See here for test case design heuristic.

That's what my thought.

Copy link
Contributor

@ChooJeremy ChooJeremy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Adoby7
Here's my reasoning:

  1. While this is true, it is harder to see that everything is tested if everything is split up into multiple different test cases in methods. I think it's better to do some abstraction so that each methods tests related sections of the endpoint, such as a single method testing for instructors accessing from other courses, testing for both validity and invalidity. Without this abstraction it's harder to reason about the test cases.
  2. I agree, and this is a fault with the BaseActionTest that @rrtheonlyone also brought up at some point. The student tests in BaseAction tests also only test specifically for student1 and not any other students. Unfortunately while it is a fault, it's harder to have it adapt - it would have to read the parameters send in and decide which instructor is appropriate as same course and which is appropriate as different course, or add in new parameters to the method. Unfortunately it's likely just a design choice that we'll just have to follow, it's harder to fix it either way.
  3. This is kind of why I suggested editing the method if needed.

I see no other problems with your code, so I'll just approve this and pass it on the senior devs to let them give their look through. If they're OK with it, then sure.

Copy link
Member

@junming403 junming403 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@xpdavid xpdavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@xpdavid xpdavid added this to Ongoing in Front-end and RESTful back-end Migration via automation Apr 7, 2019
@xpdavid xpdavid requested a review from damithc April 7, 2019 09:29
@xpdavid xpdavid added s.FinalReview The PR is ready for final review and removed s.ToReview The PR is waiting for review(s) labels Apr 7, 2019
@Adoby7 Adoby7 added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging and removed s.FinalReview The PR is ready for final review labels Apr 7, 2019
@Adoby7 Adoby7 merged commit 6300b2f into TEAMMATES:master Apr 7, 2019
Front-end and RESTful back-end Migration automation moved this from Ongoing to Done Apr 7, 2019
@Adoby7 Adoby7 deleted the student_profile branch April 7, 2019 12:13
@wkurniawan07 wkurniawan07 added this to the V7.0.0-beta.0 milestone Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants