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

S24/sayi/add user management endpoints #35

Merged
merged 6 commits into from
Oct 21, 2024

Conversation

sthuray
Copy link
Contributor

@sthuray sthuray commented Oct 4, 2024

Notion ticket link

Ticket Name

Implementation description

  • Changed UpdateUserDTO/UpdateUserDtoValidator so that users can update a user without providing every field
  • If a behaviourist tries to update a user and they update a value that they don't have access to, entire request is invalidated

Steps to test

GET

  1. No queries (get all users)
UME - GET - all users
  1. Query with both userId & email
UME - GET - email and userId query
  1. Invalid userId
UME - GET - invalid userId
  1. UserId not in database
UME - GET - nonexisting userid
  1. Get with userId (successful)
UME - GET by userid
  1. Invalid email
UME - GET - invalid email
  1. Email not in database
UME - DELETE - nonexisting email
  1. Get with email (successful)
UME - GET by email

PUT:

  1. (Behaviourist) userId not in database (similarly, test invalid userId)
UME - AM - userId not found
  1. (Behaviourist) Update only invalid fields
UME - AM - Update only invalid fields
  1. (Behaviourist) Update invalid & valid fields
UME - AM - Update a few valid:invalid fields
  1. (Behaviourist) Update valid fields
UME - AM - Successful Update
  1. (Admin) Update all fields
UME - Admin - Success

DELETE:

  1. Query with both userId & email
UME - DELETE - both params
  1. Query without parameters
UME - DELETE - no params
  1. Invalid userId
UME - DELETE - Invalid userid
  1. userId not in database
UME - DELETE - nonexisting userid
  1. Delete user with "Active" status by userId/email
UME - DELETE - active by userid
  1. Delete Animal Behaviourist with "Inactive" status by userId
UME - DELETE - inactive behaviourist by email
  1. Invalid email
UME - DELETE - invalid email
  1. Email not in database
UME - DELETE - nonexisting email
  1. Delete volunteer with "Invited" status (by email)
UME - DELETE - invited volunteer by id
  1. Delete as a Behaviourist
UME - DELETE - delete as behaviourist

What should reviewers focus on?

  • Refactored try catch statements in PUT
  • Set filtering for PUT
  • Querying with a non-existent email doesn't return a NotFoundError (add this to emailService?)
  • Querying with userId=10. gets through since Number(10.) returns 10, doesn't cause any problems, only visible when returning "userId 10. not found in database" (still checks database for userId 10 here)

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@sthuray sthuray requested a review from jerry-cheng5 October 4, 2024 00:12
Copy link
Contributor

@trinity-y trinity-y left a 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!!

Copy link
Contributor

@JustinScitech JustinScitech left a comment

Choose a reason for hiding this comment

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

Tested out these endpoints. The changes look good to me. Should be good to merge.

Copy link
Contributor

@jerry-cheng5 jerry-cheng5 left a comment

Choose a reason for hiding this comment

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

Great work! Just a couple minor things. fix them and you should be good to merge!

And I love the thoroughness you put into testing your endpoints :)

backend/typescript/rest/userRoutes.ts Outdated Show resolved Hide resolved
backend/typescript/rest/userRoutes.ts Show resolved Hide resolved
Copy link
Contributor

@laks0407 laks0407 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 to me! Great work.

@sthuray sthuray added this pull request to the merge queue Oct 21, 2024
Merged via the queue into main with commit 9a43dbb Oct 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants