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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good work!
src/main/java/teammates/ui/webapi/action/GetStudentProfileAction.java
Outdated
Show resolved
Hide resolved
src/test/java/teammates/test/cases/webapi/GetStudentProfileActionTest.java
Show resolved
Hide resolved
There was a problem hiding this 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.
src/main/java/teammates/ui/webapi/action/GetStudentProfileAction.java
Outdated
Show resolved
Hide resolved
src/main/java/teammates/ui/webapi/action/GetStudentProfileAction.java
Outdated
Show resolved
Hide resolved
src/main/java/teammates/ui/webapi/action/GetStudentProfileAction.java
Outdated
Show resolved
Hide resolved
src/test/java/teammates/test/cases/webapi/GetStudentProfileActionTest.java
Outdated
Show resolved
Hide resolved
src/test/java/teammates/test/cases/webapi/GetStudentProfileActionTest.java
Show resolved
Hide resolved
There was a problem hiding this 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.
src/main/java/teammates/ui/webapi/action/GetStudentProfileAction.java
Outdated
Show resolved
Hide resolved
src/web/app/pages-student/student-profile-page/student-profile-page.component.ts
Outdated
Show resolved
Hide resolved
0879196
to
fad5d7d
Compare
close and reopen PR to solve "Failed to read manifest file" problem |
There was a problem hiding this 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.
src/main/java/teammates/ui/webapi/action/GetStudentProfileAction.java
Outdated
Show resolved
Hide resolved
src/test/java/teammates/test/cases/webapi/GetStudentProfileActionTest.java
Show resolved
Hide resolved
.build(); | ||
typicalBundle.students.put("unregisteredStudentInCourse1", unregisteredStudentInCourse1); | ||
removeAndRestoreTypicalDataBundle(); | ||
removeAndRestoreDataBundle(typicalBundle); |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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/test/java/teammates/test/cases/webapi/GetStudentProfileActionTest.java
Outdated
Show resolved
Hide resolved
src/test/java/teammates/test/cases/webapi/GetStudentProfileActionTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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:
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); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Hi @ChooJeremy, I think using the
That's what my thought. |
There was a problem hiding this 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:
- 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.
- 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 asdifferent 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. - 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Part of #9564
Outline of Solution
The access control is following:
Case 1 requires no parameter.
Case 2, 3 require
studentEmail
andcourseId
as parameters.updated: the profile page e2e test is updated because /student/profile endpoint is changed