Skip to content

muniz95/TesteJuntoSeguros

Repository files navigation

Junto User Management Service

A comprehensive user management service built with .NET 9, providing APIs for user creation, retrieval, updating, and deletion, along with password management capabilities.

Technologies

  • .NET 9
  • ASP.NET Core
  • Entity Framework Core with SQL Server
  • AutoMapper for object mapping
  • FluentValidation for request validation
  • OpenTelemetry for observability
  • Prometheus for metrics collection
  • xUnit, FluentAssertions, and Moq for testing

Project Setup

Prerequisites

  • .NET 9 SDK
  • SQL Server (or SQL Server Express)
  • Visual Studio 2022 or any compatible IDE

Database Configuration

  1. Update the connection string in appsettings.json:
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=JuntoUserManagement;Trusted_Connection=True;MultipleActiveResultSets=true"
  }
}
  1. Run CreateUsersTable.dml.sql in your SQL Server database.

Running the Application

From Visual Studio

  1. Set Junto.UserManagement.API as the startup project
  2. Press F5 or click the Run button

From Command Line

cd Junto.UserManagement.API
dotnet run

The API will be available at https://localhost:5001 (or https://localhost:7xxx depending on your environment).

API Endpoints

  • GET /users - Get all users
  • GET /users/{id} - Get user by ID
  • POST /users - Create a new user
  • PUT /users/{id} - Update an existing user
  • DELETE /users/{id} - Delete a user
  • POST /users/{id}/change-password - Change user password
  • POST /forgot-password - Initiate password reset
  • POST /reset-password - Complete password reset

Observability and Health Monitoring

  • Health checks: /health, /health/ready, and /health/live
  • Prometheus metrics: /metrics

Running Tests

From Visual Studio

  1. Open Test Explorer
  2. Run all tests or select specific tests to run

From Command Line

dotnet test Junto.UserManagement.Tests

Generating coverage report

  • First, generate the code coverage .xml file
dotnet test Junto.UserManagement.Tests /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --collect:"XPlat Code Coverage"
  • To generate the visual report, install reportgenerator
dotnet tool install -g dotnet-reportgenerator-globaltool
  • Then, run reportgenerator tool to create the coverage report
reportgenerator -reports:.\Junto.UserManagement.Tests\TestResults\{test-result-folder}\coverage.cobertura.xml -targetdir:C:\Users\{your-user-folder}\TesteJuntoSegurosReport -reporttypes:Html

Project Structure

  • Junto.UserManagement.API: API controllers and middleware
  • Junto.UserManagement.Application: Service implementations and AutoMapper profiles
  • Junto.UserManagement.Domain: Entities, DTOs, and interfaces
  • Junto.UserManagement.Infrastructure: Data access, repositories, and external integrations
  • Junto.UserManagement.Tests: Unit and integration tests

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published