-
Notifications
You must be signed in to change notification settings - Fork 14
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
#2370 - Institution Read-Only User Type - PR 2 #4214
#2370 - Institution Read-Only User Type - PR 2 #4214
Conversation
...ation-offering-change-request/application-offering-change-request.institutions.controller.ts
Show resolved
Hide resolved
/** | ||
* Create a location with read only user access. | ||
* This is useful for tests that need to assert that the API endpoints | ||
* are properly restricted for read only users. | ||
* @param db E2E testing data sources. | ||
* @returns location the user will have read only access. | ||
*/ | ||
export async function getReadOnlyAuthorizedLocation( | ||
db: E2EDataSources, | ||
institutionTokenType: InstitutionTokenTypes, | ||
) { | ||
const { institution } = await getAuthRelatedEntities( | ||
db.dataSource, | ||
institutionTokenType, | ||
); | ||
const location = createFakeInstitutionLocation({ institution }); | ||
await authorizeUserTokenForLocation( | ||
db.dataSource, | ||
institutionTokenType, | ||
location, | ||
{ institutionUserType: InstitutionUserTypes.readOnlyUser }, | ||
); | ||
return location; | ||
} |
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 method reduces the amount of duplicated codes for creating a location with read only user access in this PR, and I think it can be expanded further to create locations for other user types as well. A cleanup ticket is probably needed in the future considering there are quite a few duplicated codes like this in the E2E tests. This comment is not a blocker. Great method by the way.
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 would agree with @lewischen-aot. The method can be converted to a generic version that would return an authorized location with the InstitutionUserTypes
provided. Not a blocker but it would be a nice improvement 😉
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.
Looks good to me. Awesome work ❤️
...end/apps/api/src/route-controllers/education-program/education-program.controller.service.ts
Show resolved
Hide resolved
sources/packages/backend/apps/api/src/testHelpers/auth/institution-auth-helpers.ts
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.
Thanks for making the changes, only minor comments left.
Quality Gate passedIssues Measures |
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.
Great work, looks good 👍
@HasLocationAccess()
to require the user to haveInstitutionUserTypes.user
for that location;InstitutionUserTypes.user
orInstitutionUserTypes.admin
for any location and deny access to "read-only" users as education programs are at institution level;authorizeUserTokenForLocation
to optionally receive the InstitutionUserTypes for the user;