Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces new user management endpoints in the router along with corresponding service, repository, middleware, and documentation updates to support user search, account activation, recovery, and administrative user actions (blocking and deletion). Key changes include:
- Adding routes and middleware for management operations in the router.
- Implementing DeleteUser, GetUsers, and GetBlockStatus in both Postgres and in-memory repositories.
- Updating tests, DTOs, and Swagger documentation to support the new endpoints.
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/router/router_test.go | Added new routes for auth and management endpoints. |
| internal/router/router.go | Added new middleware and management route initialization. |
| internal/router/management_router.go | Created new management routes for user operations. |
| internal/repository/users/repository.go & postgres.go | Added DeleteUser, GetUsers, GetBlockStatus methods with error handling. |
| internal/repository/memory/users.go | Added corresponding implementations for in-memory repository. |
| internal/middleware/jwt_admin.go & jwt_admin_test.go | Implemented and tested JWT admin middleware. |
| internal/handlers/users/management/* | Implemented management handler endpoints and tests. |
| docs/* | Updated Swagger docs to reflect new endpoints and DTO definitions. |
| config/config.go | Updated config to include PAGE_SIZE, BLOCK_DURATION, and related environment helpers. |
| func (r *inMemoryUsersRepository) GetBlockStatus(id uuid.UUID) (*models.Block, error) { | ||
| blockedUntil, exists := r.blocksDB[id] | ||
| if !exists { | ||
| return nil, errors.NewNotFoundError("user not found") |
There was a problem hiding this comment.
The in-memory repository returns 'user not found' for GetBlockStatus while the Postgres implementation returns 'block status not found'. Consider aligning these error messages for consistency across implementations.
| return nil, errors.NewNotFoundError("user not found") | |
| return nil, errors.NewNotFoundError("block status not found") |
| assert.Equal(t, http.StatusBadRequest, w.Code) | ||
|
|
||
| req, _ = http.NewRequest("PUT", "/management/block_status/"+userID.String(), bytes.NewBuffer([]byte("invalid json"))) | ||
| req.Header.Set("Content-Type", "application/json") |
There was a problem hiding this comment.
Consider creating a new httptest.ResponseRecorder for each ServeHTTP call in TestUpdateUserBlockStatus_BadRequest to ensure that responses from previous requests do not affect subsequent assertions.
| req.Header.Set("Content-Type", "application/json") | |
| req.Header.Set("Content-Type", "application/json") | |
| w = httptest.NewRecorder() |
No description provided.