Skip to content

Add unit tests for API login endpoint #83

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

Copilot
Copy link
Contributor

@Copilot 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
@Copilot 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 Copilot AI requested a review from aminespinoza10 May 28, 2025 03:21
Copilot finished work on behalf of 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