Skip to content

Commit feb3262

Browse files
Unit test project added
1 parent 15fb749 commit feb3262

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CentralizedLoggingMonitoring.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CentralizedLogging.Sdk", "C
1717
EndProject
1818
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CentralizedLogging.Contracts", "CentralizedLogging.Contracts\CentralizedLogging.Contracts.csproj", "{FAAAA797-C668-4B08-B5CA-504A21A3917A}"
1919
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserManagementApi.Tests.Unit", "UserManagementApi.Tests.Unit\UserManagementApi.Tests.Unit.csproj", "{66616F9C-B71C-45BF-8962-BAA356215BE6}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
5153
{FAAAA797-C668-4B08-B5CA-504A21A3917A}.Debug|Any CPU.Build.0 = Debug|Any CPU
5254
{FAAAA797-C668-4B08-B5CA-504A21A3917A}.Release|Any CPU.ActiveCfg = Release|Any CPU
5355
{FAAAA797-C668-4B08-B5CA-504A21A3917A}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{66616F9C-B71C-45BF-8962-BAA356215BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{66616F9C-B71C-45BF-8962-BAA356215BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{66616F9C-B71C-45BF-8962-BAA356215BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{66616F9C-B71C-45BF-8962-BAA356215BE6}.Release|Any CPU.Build.0 = Release|Any CPU
5460
EndGlobalSection
5561
GlobalSection(SolutionProperties) = preSolution
5662
HideSolutionNode = FALSE

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Centralized Logging & Monitoring API
22

3+
[![Build](https://github.com/HasanJaved-Developer/CentralizedLoggingMonitoring/actions/workflows/dotnet-test-coverage.yml/badge.svg)](https://github.com/HasanJaved-Developer/CentralizedLoggingMonitoring/actions/workflows/dotnet-test-coverage.yml)
4+
[![Docker Build](https://github.com/HasanJaved-Developer/CentralizedLoggingMonitoring/actions/workflows/docker-build.yml/badge.svg)](https://github.com/HasanJaved-Developer/CentralizedLoggingMonitoring/actions/workflows/docker-build.yml)
5+
[![codecov](https://codecov.io/gh/HasanJaved-Developer/CentralizedLoggingMonitoring/branch/main/graph/badge.svg)](https://codecov.io/gh/HasanJaved-Developer/CentralizedLoggingMonitoring)
6+
[![License](https://img.shields.io/github/license/HasanJaved-Developer/CentralizedLoggingMonitoring)](./LICENSE.txt)
7+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/HasanJaved-Developer/CentralizedLoggingMonitoring)
8+
9+
310
A centralized error logging and monitoring API built with **.NET 9**, Entity Framework Core, and SQL Server. This project is designed to serve as a foundation for collecting, storing, and managing error logs from multiple applications. **Phase 5,7&8** have also been complated and the pending **Phase 6** will be developed in a new repository.
411

512
Each phase of development is preserved in its own branch, culminating in the final **Integration Portal,** which, together with the API projects, forms a **Microservices-inspired architechture** that demonstrates **the Single Service Database Pattern.**

UserManagementApi/Controllers/UsersController.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ public async Task<ActionResult<AuthResponse>> Authenticate([FromBody] DTO.LoginR
7070
var dto = await BuildPermissionsForUser(user.Id);
7171

7272
var token = GenerateJwt(user, dto.Categories, out var expiresAtUtc);
73-
74-
// Get the same permissions tree you already expose
75-
var permissions = await BuildPermissionsForUser(user.Id);
76-
73+
7774
return Ok(new AuthResponse(user.Id, user.UserName, token, expiresAtUtc));
7875
}
7976

@@ -95,7 +92,7 @@ public async Task<ActionResult<UserPermissionsDto>> GetPermissions(int userId)
9592

9693
// ----- helpers -----
9794

98-
private async Task<UserPermissionsDto> BuildPermissionsForUser(int userId)
95+
protected virtual async Task<UserPermissionsDto> BuildPermissionsForUser(int userId)
9996
{
10097
// Fetch the user (for name in DTO)
10198
var user = await _db.Users.AsNoTracking().FirstAsync(u => u.Id == userId);
@@ -153,7 +150,7 @@ on rf.FunctionId equals f.Id
153150
return new UserPermissionsDto(user.Id, user.UserName, categoryDtos);
154151
}
155152

156-
private string GenerateJwt(AppUser user, List<CategoryDto> Categories, out DateTime expiresAtUtc)
153+
protected virtual string GenerateJwt(AppUser user, List<CategoryDto> Categories, out DateTime expiresAtUtc)
157154
{
158155
var keyBase64 = _jwt.Key;
159156
var keyPlain = Encoding.UTF8.GetString(Convert.FromBase64String(keyBase64));

0 commit comments

Comments
 (0)