benoit-bremaud / HappiHub

HappiHub - A platform for organizing and discovering cultural and artistic events. Join the community and explore events happening around you!
https://www.happihub.com
MIT License
1 stars 3 forks source link

`feature/delete-comment-by-id` #199

Closed benoit-bremaud closed 4 months ago

benoit-bremaud commented 4 months ago

feat: implement DELETE /comments/:id route to delete a comment by ID

Summary

This pull request implements the DELETE /comments/:id route that allows authenticated users to delete a specific comment by its ID. The route ensures that only the author of the comment or an admin can perform the deletion.

Changes Implemented

How to Test

  1. Delete Comment as Author:

    • Send a DELETE request to http://localhost:5000/comments/:id with a valid comment ID where the author matches the authenticated user.
    • Ensure the comment is deleted successfully.
  2. Delete Comment as Admin:

    • Send a DELETE request to http://localhost:5000/comments/:id with a valid comment ID using an admin token.
    • Ensure the comment is deleted successfully.
  3. Unauthorized Deletion Attempt:

    • Send a DELETE request to http://localhost:5000/comments/:id with a valid comment ID using a token from a different user (not the author and not an admin).
    • Ensure the response is 403 Forbidden.
  4. Comment Not Found:

    • Send a DELETE request to http://localhost:5000/comments/:id with a non-existent comment ID.
    • Ensure the response is 404 Not Found.

Example Request (Admin)

DELETE /comments/669b31e121af94e2afcdd82f HTTP/1.1
Host: localhost:5000
Authorization: Bearer <admin_token>

Example Response

{
    "message": "Comment deleted successfully"
}

New Issues Created

Resolves #152