Skip to content

Add unit tests for API login endpoint#83

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-82
Open

Add unit tests for API login endpoint#83
Copilot wants to merge 4 commits intomainfrom
copilot/fix-82

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2025

This PR adds unit tests for the login functionality in the API to verify the correct creation of a JWT token.

Implementation details:

  • Created a new test project AppVecinos.API.Tests with xUnit, TestHost, and Moq dependencies
  • Implemented two test cases for the login endpoint:
    1. Login_WithValidCredentials_ReturnsToken: Verifies that a valid JWT token is returned when correct credentials are provided
    2. Login_WithInvalidCredentials_ReturnsUnauthorized: Verifies that an Unauthorized response is returned when invalid credentials are provided
  • Tests use mock services to simulate authentication behavior without requiring a real database
  • Added test configuration for JWT settings to enable token generation during tests

Testing strategy:

The tests use the TestHost to create an in-memory test server that simulates HTTP requests to the login endpoint. This approach ensures we're testing the actual endpoint behavior without needing to deploy the API.

The mock setup allows us to test both successful and unsuccessful authentication scenarios by controlling what the NeighborService returns.

Fixes #82.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits May 28, 2025 03:18
Co-authored-by: aminespinoza10 <106186354+aminespinoza10@users.noreply.github.com>
Co-authored-by: aminespinoza10 <106186354+aminespinoza10@users.noreply.github.com>
Copilot AI changed the title [WIP] Create unit test for login method in the API Add unit tests for API login endpoint May 28, 2025
Copilot AI requested a review from aminespinoza10 May 28, 2025 03:21
@aminespinoza10 aminespinoza10 marked this pull request as ready for review July 10, 2025 20:32
@aminespinoza10 aminespinoza10 self-requested a review July 10, 2025 20:32
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.

Create unit test for login method in the API

2 participants