diff --git a/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs b/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs
index b3ea67d4..905573aa 100644
--- a/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs
+++ b/src/Lumina.Application/Common/DependencyInjection/ApplicationLayerServices.cs
@@ -3,6 +3,7 @@ using FluentValidation;
using Lumina.Application.Common.Behaviors;
using Mediator;
using Microsoft.Extensions.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Application.Common.DependencyInjection;
@@ -10,6 +11,7 @@ namespace Lumina.Application.Common.DependencyInjection;
///
/// Contains all services of the Application layer.
///
+[ExcludeFromCodeCoverage]
public static class ApplicationLayerServices
{
///
diff --git a/src/Lumina.Application/Common/Mapping/Authentication/RegistrationRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Authentication/RegistrationRequestMapping.cs
index 9cef13b5..49cdc0c9 100644
--- a/src/Lumina.Application/Common/Mapping/Authentication/RegistrationRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/Authentication/RegistrationRequestMapping.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands;
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
using Lumina.Application.Core.UsersManagement.Authentication.Commands.RegisterUser;
using Lumina.Contracts.Requests.Authentication;
#endregion
diff --git a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommand.cs b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommand.cs
similarity index 89%
rename from src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommand.cs
rename to src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommand.cs
index b31989d5..8d9c161a 100644
--- a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommand.cs
+++ b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommand.cs
@@ -4,7 +4,7 @@ using Lumina.Contracts.Responses.Authentication;
using Mediator;
#endregion
-namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Commands;
+namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
///
/// Command for the initial application setup.
@@ -14,8 +14,8 @@ namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Commands;
/// Confirmation of the password.
/// Indicates whether to enable two-factor authentication for the Admin account.
public record SetupApplicationCommand(
- string? Username,
- string? Password,
- string? PasswordConfirm,
+ string? Username,
+ string? Password,
+ string? PasswordConfirm,
bool Use2fa
) : IRequest>;
diff --git a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandHandler.cs b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandHandler.cs
similarity index 97%
rename from src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandHandler.cs
rename to src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandHandler.cs
index 64e2688e..5f2ce8b7 100644
--- a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandHandler.cs
+++ b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandHandler.cs
@@ -15,7 +15,7 @@ using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Commands;
+namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
///
/// Handler for the command to perform the initial application setup.
@@ -37,9 +37,9 @@ public class SetupApplicationCommandHandler : IRequestHandlerInjected service for generating and validating TOTP tokens.
/// Injected service for generating QR codes.
public SetupApplicationCommandHandler(
- IUnitOfWork unitOfWork,
- IHashService hashService,
- ICryptographyService cryptographyService,
+ IUnitOfWork unitOfWork,
+ IHashService hashService,
+ ICryptographyService cryptographyService,
ITotpTokenGenerator totpTokenGenerator,
IQRCodeGenerator qRCodeGenerator)
{
diff --git a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandValidator.cs b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandValidator.cs
similarity index 98%
rename from src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandValidator.cs
rename to src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandValidator.cs
index d1def565..b7d75b24 100644
--- a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandValidator.cs
+++ b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandValidator.cs
@@ -3,7 +3,7 @@ using FluentValidation;
using Lumina.Application.Common.Errors;
#endregion
-namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Commands;
+namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
///
/// Validates the needed validation rules for .
diff --git a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitializationQuery.cs b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQuery.cs
similarity index 94%
rename from src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitializationQuery.cs
rename to src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQuery.cs
index d2ef6026..3400a137 100644
--- a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitializationQuery.cs
+++ b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQuery.cs
@@ -3,7 +3,7 @@ using Lumina.Contracts.Responses.UsersManagement;
using Mediator;
#endregion
-namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Queries;
+namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
///
/// Query for checking the initialization of the application.
diff --git a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitializationQueryHandler.cs b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQueryHandler.cs
similarity index 93%
rename from src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitializationQueryHandler.cs
rename to src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQueryHandler.cs
index 01b554d6..690c99d8 100644
--- a/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitializationQueryHandler.cs
+++ b/src/Lumina.Application/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQueryHandler.cs
@@ -13,7 +13,7 @@ using System.Threading;
using System.Threading.Tasks;
#endregion
-namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Queries;
+namespace Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
///
/// Handler for the query to check the initialization of the application.
@@ -22,6 +22,9 @@ public class CheckInitializationQueryHandler : IRequestHandler
+ /// Initializes a new instance of the class.
+ ///
public CheckInitializationQueryHandler(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs
index af17ae55..9db2c4c4 100644
--- a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs
@@ -48,6 +48,14 @@ public class RegisterUserCommandHandler : IRequestHandler
+ /// Handles the command to register an account.
+ ///
+ /// The request to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either a successfully created , or an error message.
+ ///
public async ValueTask> Handle(RegisterUserCommand request, CancellationToken cancellationToken)
{
// check if any users already exists (admin account is only set once!)
diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs
index 7f05d206..5ea0c600 100644
--- a/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs
@@ -72,7 +72,7 @@ public class LoginUserQueryHandler : IRequestHandler DateTime.UtcNow)
+ if (resultSelectUser.Value.TempPasswordCreated!.Value.AddMinutes(15) < DateTime.UtcNow)
{
resultSelectUser.Value.TempPassword = null;
resultSelectUser.Value.TempPasswordCreated = null;
diff --git a/src/Lumina.DataAccess/Common/DependencyInjection/DataAccessLayerServices.cs b/src/Lumina.DataAccess/Common/DependencyInjection/DataAccessLayerServices.cs
index bc5fd532..53050eeb 100644
--- a/src/Lumina.DataAccess/Common/DependencyInjection/DataAccessLayerServices.cs
+++ b/src/Lumina.DataAccess/Common/DependencyInjection/DataAccessLayerServices.cs
@@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -17,6 +18,7 @@ namespace Lumina.DataAccess.Common.DependencyInjection;
///
/// Contains all services of the DataAccess layer.
///
+[ExcludeFromCodeCoverage]
public static class DataAccessLayerServices
{
///
diff --git a/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs b/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs
index 14ff1d88..c81e80d0 100644
--- a/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs
+++ b/src/Lumina.Domain/Common/DependencyInjection/DomainLayerServices.cs
@@ -4,6 +4,7 @@ using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.File
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
using Microsoft.Extensions.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
using System.IO.Abstractions;
#endregion
@@ -12,6 +13,7 @@ namespace Lumina.Domain.Common.DependencyInjection;
///
/// Contains all services of the Domain layer.
///
+[ExcludeFromCodeCoverage]
public static class DomainLayerServices
{
///
diff --git a/src/Lumina.Infrastructure/Common/DependencyInjection/InfrastructureLayerServices.cs b/src/Lumina.Infrastructure/Common/DependencyInjection/InfrastructureLayerServices.cs
index 5de680f6..13c0096f 100644
--- a/src/Lumina.Infrastructure/Common/DependencyInjection/InfrastructureLayerServices.cs
+++ b/src/Lumina.Infrastructure/Common/DependencyInjection/InfrastructureLayerServices.cs
@@ -7,6 +7,7 @@ using Lumina.Infrastructure.Core.Authentication;
using Lumina.Infrastructure.Core.Security;
using Lumina.Infrastructure.Core.Time;
using Microsoft.Extensions.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
using System.Reflection;
#endregion
@@ -15,6 +16,7 @@ namespace Lumina.Infrastructure.Common.DependencyInjection;
///
/// Contains all services of the Infrastructure layer.
///
+[ExcludeFromCodeCoverage]
public static class InfrastructureLayerServices
{
///
diff --git a/src/Lumina.Infrastructure/Common/DependencyInjection/SharedConfiguration.cs b/src/Lumina.Infrastructure/Common/DependencyInjection/SharedConfiguration.cs
index 877c375b..430d8cfe 100644
--- a/src/Lumina.Infrastructure/Common/DependencyInjection/SharedConfiguration.cs
+++ b/src/Lumina.Infrastructure/Common/DependencyInjection/SharedConfiguration.cs
@@ -3,6 +3,7 @@ using Lumina.Infrastructure.Common.Models.Configuration;
using Lumina.Infrastructure.Common.Utilities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
#endregion
@@ -12,6 +13,7 @@ namespace Lumina.Infrastructure.Common.DependencyInjection;
///
/// Class containing the shared configuration bindings of the application.
///
+[ExcludeFromCodeCoverage]
public static class SharedConfiguration
{
///
diff --git a/src/Lumina.Infrastructure/Core/Time/DateTimeProvider.cs b/src/Lumina.Infrastructure/Core/Time/DateTimeProvider.cs
index d6d5a211..2334c5aa 100644
--- a/src/Lumina.Infrastructure/Core/Time/DateTimeProvider.cs
+++ b/src/Lumina.Infrastructure/Core/Time/DateTimeProvider.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Infrastructure.Time;
using System;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Infrastructure.Core.Time;
@@ -8,6 +9,7 @@ namespace Lumina.Infrastructure.Core.Time;
///
/// Service for time related concerns
///
+[ExcludeFromCodeCoverage]
public class DateTimeProvider : IDateTimeProvider
{
///
diff --git a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerConfiguration.cs b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerConfiguration.cs
index b0853263..148e42f4 100644
--- a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerConfiguration.cs
+++ b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerConfiguration.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
#endregion
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Common.DependencyInjection;
///
/// Class containing the configuration bindings of the Presentation API layer.
///
+[ExcludeFromCodeCoverage]
internal static class PresentationApiLayerConfiguration
{
///
diff --git a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs
index 346ea65a..a62f62fc 100644
--- a/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs
+++ b/src/Lumina.Presentation.Api/Common/DependencyInjection/PresentationApiLayerServices.cs
@@ -11,6 +11,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -22,6 +23,7 @@ namespace Lumina.Presentation.Api.Common.DependencyInjection;
///
/// Contains all services of the Presentation API layer.
///
+[ExcludeFromCodeCoverage]
public static class PresentationApiLayerServices
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs
index 254e1cb1..23c84f93 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetDirectories;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directorie
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetDirectoriesEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs
index d8954ec5..da5e6175 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetDirectoryTree;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directorie
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetDirectoryTreeEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs
index 107a5e3f..434d3740 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetTreeDirectories;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directorie
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetTreeDirectoriesEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs
index 7c4a876d..d6b5ddbc 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Drives.GetDrives;
@@ -9,6 +10,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Drives.Get
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetDrivesEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs
index be0c69d3..7aaf65bb 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.FileSystem.GetType;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.FileSystem
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetTypeEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs
index c247e725..831d31c8 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetFiles;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetF
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetFilesEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs
index 1a227c34..49be978e 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetTreeFiles;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetT
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetTreeFilesEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs
index f75d6371..c8a159e1 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using FastEndpoints.Swagger;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.CheckPathExists;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.Check
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class CheckPathExistsEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs
index a027c023..3babebc1 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.CombinePath;
@@ -9,6 +10,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.Combi
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class CombinePathEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs
index 67611bf2..44e2d177 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathParent;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPa
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetPathParentEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs
index 03c63e27..57e558b4 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathRoot;
@@ -9,6 +10,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPa
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetPathRootEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs
index 845c462f..28aa7765 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathSeparator;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPa
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetPathSeparatorEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs
index 4344a365..f0df92ec 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs
@@ -3,6 +3,7 @@ using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.SplitPath;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.Split
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class SplitPathEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs
index 1a19a34f..011ccc4c 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.ValidatePath;
@@ -9,6 +10,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.Valid
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class ValidatePathEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs
index 9de7f5a8..cbaad9ef 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Thumbnails.GetThumbnail;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Thumbnails
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetThumbnailEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs
index 3e6756f4..3df13595 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+using System.Diagnostics.CodeAnalysis;
#endregion
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.B
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class AddLibraryEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs
index e4a78069..49a7af53 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooks;
@@ -9,6 +10,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.B
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class GetBooksEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs
index d7388b32..b5519fe2 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/Management/AddLibrary/AddLibraryEndpointSummary.cs
@@ -2,6 +2,7 @@
using FastEndpoints;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
+using System.Diagnostics.CodeAnalysis;
#endregion
@@ -11,6 +12,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.M
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class AddLibraryEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpoint.cs
index 97228c65..0ac46c2d 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpoint.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpoint.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
-using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries;
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
using Lumina.Contracts.Responses.UsersManagement;
using Lumina.Presentation.Api.Common.Routes.Maintenance;
using Lumina.Presentation.Api.Core.Endpoints.Common;
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs
index e0287981..56ffe275 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.UsersManagement;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup;
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class CheckInitializationEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs
index dfe83f21..1c08943b 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup;
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class SetupApplicationEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs
index 6b340e79..24a4eb2f 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.ChangePassword;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class ChangePasswordEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs
index c211da62..8ba72585 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.Login;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class LoginEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs
index 9488321d..af3f3afe 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.RecoverPassword;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class RecoverPasswordEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs
index cb239aee..04f87c13 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.Register;
@@ -8,6 +9,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.
///
/// Class used for providing a textual description for the API endpoint, for Swagger.
///
+[ExcludeFromCodeCoverage]
public class RegisterEndpointSummary : Summary
{
///
diff --git a/src/Lumina.Presentation.Api/Program.cs b/src/Lumina.Presentation.Api/Program.cs
index 6bfc0cf3..72ba4875 100644
--- a/src/Lumina.Presentation.Api/Program.cs
+++ b/src/Lumina.Presentation.Api/Program.cs
@@ -15,6 +15,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Serilog;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
#endregion
@@ -24,6 +25,7 @@ namespace Lumina.Presentation.Api;
///
/// Application entry point, contains the composition root module, wires up all dependencies of the application.
///
+[ExcludeFromCodeCoverage]
public class Program
{
///
diff --git a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs
index 513b0223..e949c91d 100644
--- a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs
+++ b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs
@@ -3,6 +3,7 @@ using Lumina.Presentation.Web.Common.Models.Configuration;
using Lumina.Presentation.Web.Common.Utilities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Common.DependencyInjection;
@@ -10,6 +11,7 @@ namespace Lumina.Presentation.Web.Common.DependencyInjection;
///
/// Class containing the configuration bindings of the Lumina.Presentation.Web project.
///
+[ExcludeFromCodeCoverage]
internal static class PresentationWebLayerConfiguration
{
///
diff --git a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs
index fb394a97..f21ac11c 100644
--- a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs
+++ b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs
@@ -17,6 +17,7 @@ using Polly.CircuitBreaker;
using Polly.Retry;
using Polly.Wrap;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Text.Json.Serialization;
@@ -28,6 +29,7 @@ namespace Lumina.Presentation.Web.Common.DependencyInjection;
///
/// Contains all services of the Presentation Web layer.
///
+[ExcludeFromCodeCoverage]
public static class PresentationWebLayerServices
{
///
diff --git a/src/Lumina.Presentation.Web/Program.cs b/src/Lumina.Presentation.Web/Program.cs
index 7d4bf1a8..109a3e6e 100644
--- a/src/Lumina.Presentation.Web/Program.cs
+++ b/src/Lumina.Presentation.Web/Program.cs
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Primitives;
using Serilog;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
#endregion
@@ -16,6 +17,7 @@ namespace Lumina.Presentation.Web;
///
/// Application entry point, contains the composition root module, wires up all dependencies of the application.
///
+[ExcludeFromCodeCoverage]
public class Program
{
///
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/ChangePasswordRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/ChangePasswordRequestMappingTests.cs
new file mode 100644
index 00000000..baa0a82c
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/ChangePasswordRequestMappingTests.cs
@@ -0,0 +1,85 @@
+#region ========================================================================= USING =====================================================================================
+using FluentAssertions;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
+using Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.ChangePassword.Fixtures;
+using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
+using Lumina.Application.Common.Mapping.Authentication;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordRequestMappingTests
+{
+ private readonly ChangePasswordRequestFixture _fixture;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ChangePasswordRequestMappingTests()
+ {
+ _fixture = new();
+ }
+
+ [Fact]
+ public void ToCommand_WhenMappingRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ ChangePasswordRequest request = _fixture.CreateChangePasswordRequest();
+
+ // Act
+ ChangePasswordCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(request.Username);
+ result.CurrentPassword.Should().Be(request.CurrentPassword);
+ result.NewPassword.Should().Be(request.NewPassword);
+ result.NewPasswordConfirm.Should().Be(request.NewPasswordConfirm);
+ }
+
+ [Fact]
+ public void ToCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
+ {
+ // Arrange
+ ChangePasswordRequest request = new(null, null, null, null);
+
+ // Act
+ ChangePasswordCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().BeNull();
+ result.CurrentPassword.Should().BeNull();
+ result.NewPassword.Should().BeNull();
+ result.NewPasswordConfirm.Should().BeNull();
+ }
+
+ [Theory]
+ [InlineData("user1", "oldPass", "newPass", "newPass")]
+ [InlineData("", "", "", "")]
+ [InlineData("testUser", null, "pass123", "pass123")]
+ public void ToCommand_WhenMappingRequestWithSpecificValues_ShouldMapCorrectly(
+ string? username,
+ string? currentPassword,
+ string? newPassword,
+ string? newPasswordConfirm)
+ {
+ // Arrange
+ ChangePasswordRequest request = new(username, currentPassword, newPassword, newPasswordConfirm);
+
+ // Act
+ ChangePasswordCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(username);
+ result.CurrentPassword.Should().Be(currentPassword);
+ result.NewPassword.Should().Be(newPassword);
+ result.NewPasswordConfirm.Should().Be(newPasswordConfirm);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/LoginRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/LoginRequestMappingTests.cs
new file mode 100644
index 00000000..bfe307f4
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/LoginRequestMappingTests.cs
@@ -0,0 +1,82 @@
+#region ========================================================================= USING =====================================================================================
+using FluentAssertions;
+using Lumina.Application.Common.Mapping.Authentication;
+using Lumina.Application.Core.UsersManagement.Authentication.Queries.LoginUser;
+using Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Queries.LoginUser.Fixtures;
+using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class LoginRequestMappingTests
+{
+ private readonly LoginRequestFixture _fixture;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public LoginRequestMappingTests()
+ {
+ _fixture = new();
+ }
+
+ [Fact]
+ public void ToQuery_WhenMappingRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ LoginRequest request = _fixture.CreateLoginRequest();
+
+ // Act
+ LoginUserQuery result = request.ToQuery();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(request.Username);
+ result.Password.Should().Be(request.Password);
+ result.TotpCode.Should().Be(request.TotpCode);
+ }
+
+ [Fact]
+ public void ToQuery_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
+ {
+ // Arrange
+ LoginRequest request = new(null, null);
+
+ // Act
+ LoginUserQuery result = request.ToQuery();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().BeNull();
+ result.Password.Should().BeNull();
+ result.TotpCode.Should().BeNull();
+ }
+
+ [Theory]
+ [InlineData("user1", "pass123", "123456")]
+ [InlineData("", "", "")]
+ [InlineData("testUser", null, null)]
+ [InlineData("admin", "admin123", null)]
+ public void ToQuery_WhenMappingRequestWithSpecificValues_ShouldMapCorrectly(
+ string? username,
+ string? password,
+ string? totpCode)
+ {
+ // Arrange
+ LoginRequest request = new(username, password, totpCode);
+
+ // Act
+ LoginUserQuery result = request.ToQuery();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(username);
+ result.Password.Should().Be(password);
+ result.TotpCode.Should().Be(totpCode);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/RecoverPasswordRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/RecoverPasswordRequestMappingTests.cs
new file mode 100644
index 00000000..23b09457
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/RecoverPasswordRequestMappingTests.cs
@@ -0,0 +1,78 @@
+#region ========================================================================= USING =====================================================================================
+using FluentAssertions;
+using Lumina.Application.Common.Mapping.Authentication;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
+using Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.RecoverPassword.Fixtures;
+using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordRequestMappingTests
+{
+ private readonly RecoverPasswordRequestFixture _fixture;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RecoverPasswordRequestMappingTests()
+ {
+ _fixture = new();
+ }
+
+ [Fact]
+ public void ToCommand_WhenMappingRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ RecoverPasswordRequest request = _fixture.CreateRecoverPasswordRequest();
+
+ // Act
+ RecoverPasswordCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(request.Username);
+ result.TotpCode.Should().Be(request.TotpCode);
+ }
+
+ [Fact]
+ public void ToCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
+ {
+ // Arrange
+ RecoverPasswordRequest request = new(null, null);
+
+ // Act
+ RecoverPasswordCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().BeNull();
+ result.TotpCode.Should().BeNull();
+ }
+
+ [Theory]
+ [InlineData("user1", "123456")]
+ [InlineData("", "")]
+ [InlineData("testUser", null)]
+ [InlineData(null, "654321")]
+ public void ToCommand_WhenMappingRequestWithSpecificValues_ShouldMapCorrectly(
+ string? username,
+ string? totpCode)
+ {
+ // Arrange
+ RecoverPasswordRequest request = new(username, totpCode);
+
+ // Act
+ RecoverPasswordCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(username);
+ result.TotpCode.Should().Be(totpCode);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/RegistrationRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/RegistrationRequestMappingTests.cs
new file mode 100644
index 00000000..155d6df4
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/Authentication/RegistrationRequestMappingTests.cs
@@ -0,0 +1,146 @@
+#region ========================================================================= USING =====================================================================================
+using FluentAssertions;
+using Lumina.Application.Common.Mapping.Authentication;
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.RegisterUser;
+using Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.RegisterUser.Fixture;
+using Lumina.Contracts.Requests.Authentication;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.Authentication;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RegistrationRequestMappingTests
+{
+ private readonly RegistrationRequestFixture _fixture;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RegistrationRequestMappingTests()
+ {
+ _fixture = new();
+ }
+
+ [Fact]
+ public void ToSetupCommand_WhenMappingRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ RegistrationRequest request = _fixture.CreateRegistrationRequest();
+
+ // Act
+ SetupApplicationCommand result = request.ToSetupCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(request.Username);
+ result.Password.Should().Be(request.Password);
+ result.PasswordConfirm.Should().Be(request.PasswordConfirm);
+ result.Use2fa.Should().Be(request.Use2fa);
+ }
+
+ [Fact]
+ public void ToCommand_WhenMappingRequest_ShouldMapCorrectly()
+ {
+ // Arrange
+ RegistrationRequest request = _fixture.CreateRegistrationRequest();
+
+ // Act
+ RegisterUserCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(request.Username);
+ result.Password.Should().Be(request.Password);
+ result.PasswordConfirm.Should().Be(request.PasswordConfirm);
+ result.Use2fa.Should().Be(request.Use2fa);
+ }
+
+ [Fact]
+ public void ToSetupCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
+ {
+ // Arrange
+ RegistrationRequest request = new();
+
+ // Act
+ SetupApplicationCommand result = request.ToSetupCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().BeNull();
+ result.Password.Should().BeNull();
+ result.PasswordConfirm.Should().BeNull();
+ result.Use2fa.Should().BeTrue();
+ }
+
+ [Fact]
+ public void ToCommand_WhenMappingRequestWithNullValues_ShouldMapCorrectly()
+ {
+ // Arrange
+ RegistrationRequest request = new();
+
+ // Act
+ RegisterUserCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().BeNull();
+ result.Password.Should().BeNull();
+ result.PasswordConfirm.Should().BeNull();
+ result.Use2fa.Should().BeTrue();
+ }
+
+ [Theory]
+ [InlineData("user1", "pass123", "pass123", true)]
+ [InlineData("", "", "", false)]
+ [InlineData("testUser", null, null, true)]
+ [InlineData(null, "pass123", "pass123", false)]
+ public void ToSetupCommand_WhenMappingRequestWithSpecificValues_ShouldMapCorrectly(
+ string? username,
+ string? password,
+ string? passwordConfirm,
+ bool use2fa)
+ {
+ // Arrange
+ RegistrationRequest request = new(username, password, passwordConfirm, use2fa);
+
+ // Act
+ SetupApplicationCommand result = request.ToSetupCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(username);
+ result.Password.Should().Be(password);
+ result.PasswordConfirm.Should().Be(passwordConfirm);
+ result.Use2fa.Should().Be(use2fa);
+ }
+
+ [Theory]
+ [InlineData("user1", "pass123", "pass123", true)]
+ [InlineData("", "", "", false)]
+ [InlineData("testUser", null, null, true)]
+ [InlineData(null, "pass123", "pass123", false)]
+ public void ToCommand_WhenMappingRequestWithSpecificValues_ShouldMapCorrectly(
+ string? username,
+ string? password,
+ string? passwordConfirm,
+ bool use2fa)
+ {
+ // Arrange
+ RegistrationRequest request = new(username, password, passwordConfirm, use2fa);
+
+ // Act
+ RegisterUserCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.Username.Should().Be(username);
+ result.Password.Should().Be(password);
+ result.PasswordConfirm.Should().Be(passwordConfirm);
+ result.Use2fa.Should().Be(use2fa);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UserManagement/Users/Fixtures/UserEntityFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UserManagement/Users/Fixtures/UserEntityFixture.cs
new file mode 100644
index 00000000..7b999cf2
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UserManagement/Users/Fixtures/UserEntityFixture.cs
@@ -0,0 +1,69 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Domain.Common.Enums.MediaLibrary;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users.Fixtures;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class UserEntityFixture
+{
+ ///
+ /// Creates a random valid user entity.
+ ///
+ /// Number of libraries to generate. Default is 0.
+ /// The created user entity.
+ public static UserEntity CreateUserEntity(int libraryCount = 0)
+ {
+ Guid userId = Guid.NewGuid();
+ List libraries = [.. new Faker()
+ .CustomInstantiator(f => new LibraryEntity
+ {
+ Id = Guid.NewGuid(),
+ UserId = userId,
+ Title = f.Commerce.ProductName(),
+ LibraryType = f.PickRandom(),
+ ContentLocations = [],
+ Created = f.Date.Past(),
+ Updated = null
+ })
+ .Generate(libraryCount)];
+
+ return new Faker()
+ .CustomInstantiator(f => new UserEntity
+ {
+ Id = userId,
+ Username = default!,
+ Password = default!,
+ Created = default,
+ TotpSecret = default,
+ Libraries = libraries
+ })
+ .RuleFor(x => x.Username, f => f.Internet.UserName())
+ .RuleFor(x => x.Password, f => Uri.EscapeDataString(f.Internet.Password()))
+ .RuleFor(x => x.Created, f => f.Date.Past())
+ .RuleFor(x => x.TotpSecret, f => f.Random.Bool() ? f.Random.String2(32) : null)
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of user entities.
+ ///
+ /// The number of entities to create.
+ /// The created list.
+ public static List CreateMany(int count = 3)
+ {
+ return Enumerable.Range(0, count)
+ .Select(_ => CreateUserEntity())
+ .ToList();
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UserManagement/Users/UserEntityMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UserManagement/Users/UserEntityMappingTests.cs
index fa4785c7..c9a5e2c2 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UserManagement/Users/UserEntityMappingTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UserManagement/Users/UserEntityMappingTests.cs
@@ -4,6 +4,7 @@ using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.Mapping.Common.Metadata;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
using Lumina.Application.Common.Mapping.UsersManagement.Users;
+using Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users.Fixtures;
using Lumina.Contracts.Responses.UsersManagement.Users;
using Lumina.Domain.Common.Enums.MediaLibrary;
using System;
@@ -18,19 +19,21 @@ namespace Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users;
[ExcludeFromCodeCoverage]
public class UserEntityMappingTests
{
+ private readonly UserEntityFixture _fixture;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public UserEntityMappingTests()
+ {
+ _fixture = new UserEntityFixture();
+ }
+
[Fact]
public void ToResponse_WhenMappingValidUserEntity_ShouldMapCorrectly()
{
// Arrange
- UserEntity entity = new()
- {
- Id = Guid.NewGuid(),
- Username = "testuser",
- Password = "hashedpassword",
- Libraries = [],
- Created = DateTime.UtcNow,
- Updated = null
- };
+ UserEntity entity = UserEntityFixture.CreateUserEntity();
// Act
UserResponse result = entity.ToResponse();
@@ -51,15 +54,8 @@ public class UserEntityMappingTests
public void ToResponse_WhenMappingDifferentUsernames_ShouldMapCorrectly(string username)
{
// Arrange
- UserEntity entity = new()
- {
- Id = Guid.NewGuid(),
- Username = username,
- Password = "hashedpassword",
- Libraries = [],
- Created = DateTime.UtcNow,
- Updated = null
- };
+ UserEntity entity = UserEntityFixture.CreateUserEntity();
+ entity.Username = username;
// Act
UserResponse result = entity.ToResponse();
@@ -73,60 +69,22 @@ public class UserEntityMappingTests
public void ToResponse_WhenMappingWithUpdatedDateTime_ShouldMapCorrectly()
{
// Arrange
- DateTime updated = DateTime.UtcNow.AddDays(-1);
- UserEntity entity = new()
- {
- Id = Guid.NewGuid(),
- Username = "testuser",
- Password = "hashedpassword",
- Libraries = [],
- Created = DateTime.UtcNow,
- Updated = updated
- };
+ UserEntity entity = UserEntityFixture.CreateUserEntity();
+ entity.Updated = DateTime.UtcNow.AddDays(-1);
// Act
UserResponse result = entity.ToResponse();
// Assert
result.Should().NotBeNull();
- result.Updated.Should().Be(updated);
+ result.Updated.Should().Be(entity.Updated);
}
[Fact]
public void ToResponse_WhenMappingWithLibraries_ShouldNotAffectMapping()
{
// Arrange
- UserEntity entity = new()
- {
- Id = Guid.NewGuid(),
- Username = "testuser",
- Password = "hashedpassword",
- Libraries =
- [
- new()
- {
- Id = Guid.NewGuid(),
- UserId = Guid.NewGuid(),
- Title = "Library 1",
- LibraryType = LibraryType.Book,
- ContentLocations = [],
- Created = DateTime.UtcNow,
- Updated = null
- },
- new()
- {
- Id = Guid.NewGuid(),
- UserId = Guid.NewGuid(),
- Title = "Library 2",
- LibraryType = LibraryType.Movie,
- ContentLocations = [],
- Created = DateTime.UtcNow,
- Updated = null
- }
- ],
- Created = DateTime.UtcNow,
- Updated = null
- };
+ UserEntity entity = UserEntityFixture.CreateUserEntity(2);
// Act
UserResponse result = entity.ToResponse();
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryHandlerTests.cs
index 3ee980e4..c3db6f95 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryHandlerTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryHandlerTests.cs
@@ -20,7 +20,6 @@ using System.Threading.Tasks;
namespace Lumina.Application.UnitTests.Core.FileSystemManagement.Files.Queries.GetFiles;
-
///
/// Contains unit tests for the class.
///
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/Fixtures/SetupApplicationCommandFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/Fixtures/SetupApplicationCommandFixture.cs
similarity index 75%
rename from tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/Fixtures/SetupApplicationCommandFixture.cs
rename to tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/Fixtures/SetupApplicationCommandFixture.cs
index 2a5f1892..c4449632 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/Fixtures/SetupApplicationCommandFixture.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/Fixtures/SetupApplicationCommandFixture.cs
@@ -1,10 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
-using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands;
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
using System.Diagnostics.CodeAnalysis;
#endregion
-namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands.Fixtures;
+namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands.SetupApplication.Fixtures;
///
/// Fixture class for the class.
@@ -16,7 +16,7 @@ public class SetupApplicationCommandFixture
/// Creates a random valid command for the application setup.
///
/// The created command.
- public static SetupApplicationCommand CreateSetupApplicationCommand()
+ public SetupApplicationCommand CreateSetupApplicationCommand()
{
string password = "Abcd123$";
return new Faker()
@@ -26,8 +26,10 @@ public class SetupApplicationCommandFixture
default!,
true
))
- .RuleFor(x => x.Username, f => f.Person.UserName)
+ .RuleFor(x => x.Username, f => f.Internet.UserName())
.RuleFor(x => x.Password, password)
- .RuleFor(x => x.PasswordConfirm, password);
+ .RuleFor(x => x.PasswordConfirm, password)
+ .RuleFor(x => x.Use2fa, f => f.Random.Bool())
+ .Generate();
}
}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandHandlerTests.cs
new file mode 100644
index 00000000..276d67b1
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandHandlerTests.cs
@@ -0,0 +1,194 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using FluentAssertions;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Common.DataAccess.Repositories.Users;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Errors;
+using Lumina.Application.Common.Infrastructure.Authentication;
+using Lumina.Application.Common.Infrastructure.Security;
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
+using Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users.Fixtures;
+using Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands.SetupApplication.Fixtures;
+using Lumina.Contracts.Responses.Authentication;
+using NSubstitute;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class SetupApplicationCommandHandlerTests
+{
+ private readonly IUnitOfWork _mockUnitOfWork;
+ private readonly IHashService _mockHashService;
+ private readonly ICryptographyService _mockCryptographyService;
+ private readonly ITotpTokenGenerator _mockTotpTokenGenerator;
+ private readonly IQRCodeGenerator _mockQRCodeGenerator;
+ private readonly IUserRepository _mockUserRepository;
+ private readonly SetupApplicationCommandHandler _sut;
+ private readonly SetupApplicationCommandFixture _setupApplicationCommandFixture;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public SetupApplicationCommandHandlerTests()
+ {
+ _mockUnitOfWork = Substitute.For();
+ _mockHashService = Substitute.For();
+ _mockCryptographyService = Substitute.For();
+ _mockTotpTokenGenerator = Substitute.For();
+ _mockQRCodeGenerator = Substitute.For();
+ _mockUserRepository = Substitute.For();
+ _setupApplicationCommandFixture = new SetupApplicationCommandFixture();
+
+ _mockUnitOfWork.GetRepository().Returns(_mockUserRepository);
+
+ _sut = new SetupApplicationCommandHandler(
+ _mockUnitOfWork,
+ _mockHashService,
+ _mockCryptographyService,
+ _mockTotpTokenGenerator,
+ _mockQRCodeGenerator);
+ }
+
+ [Fact]
+ public async Task Handle_WhenNoExistingUsers_ShouldCreateAdminUserWithout2FA()
+ {
+ // Arrange
+ SetupApplicationCommand command = _setupApplicationCommandFixture.CreateSetupApplicationCommand() with { Use2fa = false };
+ string hashedPassword = Uri.EscapeDataString("hashedPassword");
+
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(ErrorOrFactory.From(Enumerable.Empty()));
+ _mockHashService.HashString(command.Password!)
+ .Returns(hashedPassword);
+ _mockUserRepository.InsertAsync(Arg.Any(), Arg.Any())
+ .Returns(Result.Created);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeFalse();
+ result.Value.Should().NotBeNull();
+ result.Value.Username.Should().Be(command.Username);
+ result.Value.TotpSecret.Should().BeNull();
+
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ await _mockUserRepository.Received(1).InsertAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenNoExistingUsersAndWith2FA_ShouldCreateAdminUserWithTOTP()
+ {
+ // Arrange
+ SetupApplicationCommand command = _setupApplicationCommandFixture.CreateSetupApplicationCommand() with { Use2fa = true };
+ string hashedPassword = Uri.EscapeDataString("hashedPassword");
+ byte[] totpSecret = [1, 2, 3];
+ string qrCodeUri = "data:image/png;base64,test";
+ string encryptedSecret = "encryptedSecret";
+
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(ErrorOrFactory.From(Enumerable.Empty()));
+ _mockHashService.HashString(command.Password!)
+ .Returns(hashedPassword);
+ _mockTotpTokenGenerator.GenerateSecret()
+ .Returns(totpSecret);
+ _mockQRCodeGenerator.GenerateQrCodeDataUri(command.Username!, totpSecret)
+ .Returns(qrCodeUri);
+ _mockCryptographyService.Encrypt(Arg.Any())
+ .Returns(encryptedSecret);
+ _mockUserRepository.InsertAsync(Arg.Any(), Arg.Any())
+ .Returns(Result.Created);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeFalse();
+ result.Value.Should().NotBeNull();
+ result.Value.Username.Should().Be(command.Username);
+ result.Value.TotpSecret.Should().Be(qrCodeUri);
+
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ await _mockUserRepository.Received(1).InsertAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenUserAlreadyExists_ShouldReturnError()
+ {
+ // Arrange
+ SetupApplicationCommand command = _setupApplicationCommandFixture.CreateSetupApplicationCommand();
+ UserEntity existingUser = UserEntityFixture.CreateUserEntity();
+
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(new[] { existingUser });
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(Errors.Authorization.AdminAccountAlreadyCreated);
+
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenGetAllUsersReturnsError_ShouldReturnError()
+ {
+ // Arrange
+ SetupApplicationCommand command = _setupApplicationCommandFixture.CreateSetupApplicationCommand();
+ Error error = Error.Failure("Database.Error", "Failed to retrieve users");
+
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(error);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(error);
+
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenInsertUserReturnsError_ShouldReturnError()
+ {
+ // Arrange
+ SetupApplicationCommand command = _setupApplicationCommandFixture.CreateSetupApplicationCommand();
+ Error error = Error.Failure("Database.Error", "Failed to insert user");
+
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(ErrorOrFactory.From(Enumerable.Empty()));
+ _mockUserRepository.InsertAsync(Arg.Any(), Arg.Any())
+ .Returns(error);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(error);
+
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ await _mockUserRepository.Received(1).InsertAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandValidatorTests.cs
similarity index 82%
rename from tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandValidatorTests.cs
rename to tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandValidatorTests.cs
index be30ec52..d0752370 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplicationCommandValidatorTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Commands/SetupApplication/SetupApplicationCommandValidatorTests.cs
@@ -1,14 +1,12 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation.TestHelper;
-using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
-using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands;
-using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Commands.CombinePath.Fixtures;
-using Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands.Fixtures;
using Lumina.Application.Common.Errors;
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
+using Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands.SetupApplication.Fixtures;
using System.Diagnostics.CodeAnalysis;
#endregion
-namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands;
+namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
///
/// Contains unit tests for the class.
@@ -17,6 +15,7 @@ namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Command
public class SetupApplicationCommandValidatorTests
{
private readonly SetupApplicationCommandValidator _validator;
+ private readonly SetupApplicationCommandFixture _commandFixture;
///
/// Initializes a new instance of the class.
@@ -24,14 +23,15 @@ public class SetupApplicationCommandValidatorTests
public SetupApplicationCommandValidatorTests()
{
_validator = new SetupApplicationCommandValidator();
+ _commandFixture = new SetupApplicationCommandFixture();
}
[Fact]
public void Validate_WhenUsernameIsNull_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
- command = command with { Username = null! };
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
+ command = command with { Username = null };
// Act
TestValidationResult result = _validator.TestValidate(command);
@@ -45,7 +45,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenUsernameIsEmpty_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Username = string.Empty };
// Act
@@ -60,7 +60,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenUsernameIsWhiteSpace_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Username = " " };
// Act
@@ -75,7 +75,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordIsNull_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Password = null! };
// Act
@@ -90,7 +90,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordIsEmpty_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Password = string.Empty };
// Act
@@ -105,7 +105,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordIsWhiteSpace_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Password = " " };
// Act
@@ -120,7 +120,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordConfirmIsNull_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { PasswordConfirm = null! };
// Act
@@ -135,7 +135,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordConfirmIsEmpty_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { PasswordConfirm = string.Empty };
// Act
@@ -150,7 +150,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordConfirmIsWhiteSpace_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { PasswordConfirm = " " };
// Act
@@ -165,7 +165,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordAndPasswordConfirmDontMatch_ShouldHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { PasswordConfirm = "$321Bcda" };
// Act
@@ -186,7 +186,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordDoesNotMatchPattern_ShouldHaveValidationError(string password)
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Password = password, PasswordConfirm = password };
// Act
@@ -205,7 +205,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenPasswordMatchesPattern_ShouldNotHaveValidationError(string password)
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Password = password, PasswordConfirm = password };
// Act
@@ -219,7 +219,7 @@ public class SetupApplicationCommandValidatorTests
public void Validate_WhenCommandIsValid_ShouldNotHaveValidationError()
{
// Arrange
- SetupApplicationCommand command = SetupApplicationCommandFixture.CreateSetupApplicationCommand();
+ SetupApplicationCommand command = _commandFixture.CreateSetupApplicationCommand();
command = command with { Password = "$321Bcda", PasswordConfirm = "$321Bcda" };
// Act
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Queries/CheckInitiliazation/CheckInitializationQueryHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Queries/CheckInitiliazation/CheckInitializationQueryHandlerTests.cs
new file mode 100644
index 00000000..06801841
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/Maintenance/ApplicationSetup/Queries/CheckInitiliazation/CheckInitializationQueryHandlerTests.cs
@@ -0,0 +1,91 @@
+#region ========================================================================= USING =====================================================================================
+using AutoFixture;
+using AutoFixture.AutoNSubstitute;
+using ErrorOr;
+using FluentAssertions;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Common.DataAccess.Repositories.Users;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
+using Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users.Fixtures;
+using Lumina.Contracts.Responses.UsersManagement;
+using NSubstitute;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.Maintenance.ApplicationSetup.Queries.CheckInitiliazation;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class CheckInitializationQueryHandlerTests
+{
+ private readonly IUnitOfWork _mockUnitOfWork;
+ private readonly IUserRepository _mockUserRepository;
+ private readonly CheckInitializationQueryHandler _sut;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public CheckInitializationQueryHandlerTests()
+ {
+ _mockUnitOfWork = Substitute.For();
+ _mockUserRepository = Substitute.For();
+
+ _mockUnitOfWork.GetRepository().Returns(_mockUserRepository);
+
+ _sut = new CheckInitializationQueryHandler(_mockUnitOfWork);
+ }
+
+ [Fact]
+ public async Task Handle_WhenUsersExist_ShouldReturnInitialized()
+ {
+ // Arrange
+ List users = UserEntityFixture.CreateMany();
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(ErrorOrFactory.From(users.AsEnumerable()));
+
+ // Act
+ InitializationResponse result = await _sut.Handle(new CheckInitializationQuery(), CancellationToken.None);
+
+ // Assert
+ result.IsInitialized.Should().BeTrue();
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenNoUsersExist_ShouldReturnNotInitialized()
+ {
+ // Arrange
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(ErrorOrFactory.From(Enumerable.Empty()));
+
+ // Act
+ InitializationResponse result = await _sut.Handle(new CheckInitializationQuery(), CancellationToken.None);
+
+ // Assert
+ result.IsInitialized.Should().BeFalse();
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenRepositoryReturnsError_ShouldReturnNotInitialized()
+ {
+ // Arrange
+ Error error = Error.Failure("Database.Error", "Failed to retrieve users");
+ _mockUserRepository.GetAllAsync(Arg.Any())
+ .Returns(error);
+
+ // Act
+ InitializationResponse result = await _sut.Handle(new CheckInitializationQuery(), CancellationToken.None);
+
+ // Assert
+ result.IsInitialized.Should().BeFalse();
+ await _mockUserRepository.Received(1).GetAllAsync(Arg.Any());
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandHandlerTests.cs
new file mode 100644
index 00000000..e2e7c9b2
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandHandlerTests.cs
@@ -0,0 +1,207 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using FluentAssertions;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Common.DataAccess.Repositories.Users;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Errors;
+using Lumina.Application.Common.Infrastructure.Security;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
+using Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users.Fixtures;
+using Lumina.Contracts.Responses.Authentication;
+using NSubstitute;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.ChangePassword;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordCommandHandlerTests
+{
+ private readonly IUnitOfWork _mockUnitOfWork;
+ private readonly IHashService _mockHashService;
+ private readonly IUserRepository _mockUserRepository;
+ private readonly ChangePasswordCommandHandler _sut;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ChangePasswordCommandHandlerTests()
+ {
+ _mockUnitOfWork = Substitute.For();
+ _mockHashService = Substitute.For();
+ _mockUserRepository = Substitute.For();
+
+ _mockUnitOfWork.GetRepository().Returns(_mockUserRepository);
+
+ _sut = new ChangePasswordCommandHandler(
+ _mockUnitOfWork,
+ _mockHashService);
+ }
+
+ [Fact]
+ public async Task Handle_WhenPasswordChangeIsSuccessful_ShouldUpdateUserAndReturnSuccess()
+ {
+ // Arrange
+ string currentPassword = "currentPassword";
+ string newPassword = "newPassword";
+ string hashedNewPassword = "hashedNewPassword";
+ string escapedHashedCurrentPassword = Uri.EscapeDataString("hashedCurrentPassword");
+
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ user.Password = escapedHashedCurrentPassword;
+
+ ChangePasswordCommand command = new(
+ user.Username,
+ currentPassword,
+ newPassword,
+ newPassword);
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+ _mockHashService.CheckStringAgainstHash(currentPassword, "hashedCurrentPassword")
+ .Returns(true);
+ _mockHashService.HashString(newPassword)
+ .Returns(hashedNewPassword);
+ _mockUserRepository.UpdateAsync(Arg.Any(), Arg.Any())
+ .Returns(Result.Updated);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeFalse();
+ result.Value.IsPasswordChanged.Should().BeTrue();
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ _mockHashService.Received(1).CheckStringAgainstHash(currentPassword, "hashedCurrentPassword");
+ _mockHashService.Received(1).HashString(newPassword);
+ await _mockUserRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenUserDoesNotExist_ShouldReturnError()
+ {
+ // Arrange
+ ChangePasswordCommand command = new("nonexistentUser", "oldPass", "newPass", "newPass");
+
+ _mockUserRepository.GetByUsernameAsync(command.Username!, Arg.Any())
+ .Returns(ErrorOrFactory.From(null));
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(Errors.Authentication.UsernameDoesNotExist);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any());
+ await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenCurrentPasswordIsIncorrect_ShouldReturnError()
+ {
+ // Arrange
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ string incorrectPassword = "wrongPassword";
+
+ ChangePasswordCommand command = new(
+ user.Username,
+ incorrectPassword,
+ "newPass",
+ "newPass");
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+ _mockHashService.CheckStringAgainstHash(incorrectPassword, Uri.UnescapeDataString(user.Password))
+ .Returns(false);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(Errors.Authentication.InvalidCurrentPassword);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ _mockHashService.Received(1).CheckStringAgainstHash(incorrectPassword, Uri.UnescapeDataString(user.Password));
+ await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenUpdateFails_ShouldReturnError()
+ {
+ // Arrange
+ string currentPassword = "currentPassword";
+ string newPassword = "newPassword";
+ string escapedHashedCurrentPassword = Uri.EscapeDataString("hashedCurrentPassword");
+ Error error = Error.Failure("Database.Error", "Failed to update user");
+
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ user.Password = escapedHashedCurrentPassword;
+
+ ChangePasswordCommand command = new(
+ user.Username,
+ currentPassword,
+ newPassword,
+ newPassword);
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+ _mockHashService.CheckStringAgainstHash(currentPassword, "hashedCurrentPassword")
+ .Returns(true);
+ _mockUserRepository.UpdateAsync(Arg.Any(), Arg.Any())
+ .Returns(error);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(error);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ _mockHashService.Received(1).CheckStringAgainstHash(currentPassword, "hashedCurrentPassword");
+ await _mockUserRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenGetByUsernameReturnsError_ShouldReturnError()
+ {
+ // Arrange
+ string currentPassword = "currentPassword";
+ string newPassword = "newPassword";
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ ChangePasswordCommand command = new(
+ user.Username,
+ currentPassword,
+ newPassword,
+ newPassword);
+ Error error = Error.Failure("Database.Error", "Failed to check username");
+
+ _mockUserRepository.GetByUsernameAsync(command.Username!, Arg.Any())
+ .Returns(error);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(error);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any());
+ await _mockUserRepository.DidNotReceive().InsertAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandValidatorTests.cs
new file mode 100644
index 00000000..2c272751
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandValidatorTests.cs
@@ -0,0 +1,303 @@
+#region ========================================================================= USING =====================================================================================
+using FluentValidation.TestHelper;
+using Lumina.Application.Common.Errors;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
+using Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.ChangePassword.Fixtures;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.ChangePassword;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordCommandValidatorTests
+{
+ private readonly ChangePasswordCommandValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ChangePasswordCommandValidatorTests()
+ {
+ _validator = new ChangePasswordCommandValidator();
+ }
+
+ [Fact]
+ public void Validate_WhenUsernameIsNull_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { Username = null! };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.Username)
+ .WithErrorMessage(Errors.Authentication.UsernameCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenUsernameIsEmpty_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { Username = string.Empty };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.Username)
+ .WithErrorMessage(Errors.Authentication.UsernameCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenUsernameIsWhiteSpace_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { Username = " " };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.Username)
+ .WithErrorMessage(Errors.Authentication.UsernameCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenCurrentPasswordIsNull_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { CurrentPassword = null! };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.CurrentPassword)
+ .WithErrorMessage(Errors.Authentication.CurrentPasswordCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenCurrentPasswordIsEmpty_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { CurrentPassword = string.Empty };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.CurrentPassword)
+ .WithErrorMessage(Errors.Authentication.CurrentPasswordCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenCurrentPasswordIsWhiteSpace_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { CurrentPassword = " " };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.CurrentPassword)
+ .WithErrorMessage(Errors.Authentication.CurrentPasswordCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenNewPasswordIsNull_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPassword = null! };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPassword)
+ .WithErrorMessage(Errors.Authentication.NewPasswordCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenNewPasswordIsEmpty_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPassword = string.Empty };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPassword)
+ .WithErrorMessage(Errors.Authentication.NewPasswordCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenNewPasswordIsWhiteSpace_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPassword = " " };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPassword)
+ .WithErrorMessage(Errors.Authentication.NewPasswordCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenNewPasswordConfirmIsNull_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPasswordConfirm = null! };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPasswordConfirm)
+ .WithErrorMessage(Errors.Authentication.NewPasswordConfirmCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenNewPasswordConfirmIsEmpty_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPasswordConfirm = string.Empty };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPasswordConfirm)
+ .WithErrorMessage(Errors.Authentication.NewPasswordConfirmCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenNewPasswordConfirmIsWhiteSpace_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPasswordConfirm = " " };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPasswordConfirm)
+ .WithErrorMessage(Errors.Authentication.NewPasswordConfirmCannotBeEmpty.Description);
+ }
+
+ [Fact]
+ public void Validate_WhenNewPasswordAndNewPasswordConfirmDontMatch_ShouldHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPasswordConfirm = "$321Bcda" };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPassword)
+ .WithErrorMessage(Errors.Authentication.PasswordsNotMatch.Description);
+ }
+
+ [Theory]
+ [InlineData("password123")] // Missing uppercase and special character
+ [InlineData("PASSWORD123")] // Missing special character
+ [InlineData("Password123")] // Missing special character
+ [InlineData("Password!@#")] // Missing number
+ [InlineData("Pass1!")] // Too short
+ [InlineData("password")] // Missing uppercase, number, and special character
+ public void Validate_WhenCurrentPasswordDoesNotMatchPattern_ShouldHaveValidationError(string password)
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { CurrentPassword = password };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.CurrentPassword)
+ .WithErrorMessage(Errors.Authentication.InvalidPassword.Description);
+ }
+
+ [Theory]
+ [InlineData("password123")] // Missing uppercase and special character
+ [InlineData("PASSWORD123")] // Missing special character
+ [InlineData("Password123")] // Missing special character
+ [InlineData("Password!@#")] // Missing number
+ [InlineData("Pass1!")] // Too short
+ [InlineData("password")] // Missing uppercase, number, and special character
+ public void Validate_WhenNewPasswordDoesNotMatchPattern_ShouldHaveValidationError(string password)
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with { NewPassword = password, NewPasswordConfirm = password };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldHaveValidationErrorFor(x => x.NewPassword)
+ .WithErrorMessage(Errors.Authentication.InvalidPassword.Description);
+ }
+
+ [Theory]
+ [InlineData("Password1!")] // Valid password
+ [InlineData("Complex1@Password")] // Valid password
+ [InlineData("MyP@ssw0rd")] // Valid password
+ [InlineData("Abcd123!@#")] // Valid password
+ public void Validate_WhenPasswordsMatchPattern_ShouldNotHaveValidationError(string password)
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+ command = command with
+ {
+ CurrentPassword = password,
+ NewPassword = password,
+ NewPasswordConfirm = password
+ };
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldNotHaveValidationErrorFor(x => x.CurrentPassword);
+ result.ShouldNotHaveValidationErrorFor(x => x.NewPassword);
+ }
+
+ [Fact]
+ public void Validate_WhenCommandIsValid_ShouldNotHaveValidationError()
+ {
+ // Arrange
+ ChangePasswordCommand command = ChangePasswordCommandFixture.CreateChangePasswordCommand();
+
+ // Act
+ TestValidationResult result = _validator.TestValidate(command);
+
+ // Assert
+ result.ShouldNotHaveValidationErrorFor(x => x.Username);
+ result.ShouldNotHaveValidationErrorFor(x => x.CurrentPassword);
+ result.ShouldNotHaveValidationErrorFor(x => x.NewPassword);
+ result.ShouldNotHaveValidationErrorFor(x => x.NewPasswordConfirm);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/Fixtures/ChangePasswordCommandFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/Fixtures/ChangePasswordCommandFixture.cs
new file mode 100644
index 00000000..49ca6c5b
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/Fixtures/ChangePasswordCommandFixture.cs
@@ -0,0 +1,35 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.ChangePassword.Fixtures;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordCommandFixture
+{
+ ///
+ /// Creates a random valid command for changing a password.
+ ///
+ /// The created command.
+ public static ChangePasswordCommand CreateChangePasswordCommand()
+ {
+ string currentPassword = "Abcd123$";
+ string newPassword = "Wxyz789#";
+ return new Faker()
+ .CustomInstantiator(f => new ChangePasswordCommand(
+ default!,
+ default!,
+ default!,
+ default!
+ ))
+ .RuleFor(x => x.Username, f => f.Person.UserName)
+ .RuleFor(x => x.CurrentPassword, currentPassword)
+ .RuleFor(x => x.NewPassword, newPassword)
+ .RuleFor(x => x.NewPasswordConfirm, newPassword);
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/Fixtures/ChangePasswordRequestFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/Fixtures/ChangePasswordRequestFixture.cs
new file mode 100644
index 00000000..28141e51
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/ChangePassword/Fixtures/ChangePasswordRequestFixture.cs
@@ -0,0 +1,56 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Authentication;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.ChangePassword.Fixtures;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordRequestFixture
+{
+ private readonly Faker _faker;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ChangePasswordRequestFixture()
+ {
+ _faker = new Faker();
+ }
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// The created .
+ public ChangePasswordRequest CreateChangePasswordRequest(
+ string? username = null,
+ string? currentPassword = null,
+ string? newPassword = null,
+ string? newPasswordConfirm = null)
+ {
+ return new ChangePasswordRequest(
+ username ?? _faker.Internet.UserName(),
+ currentPassword ?? _faker.Internet.Password(),
+ newPassword ?? _faker.Internet.Password(),
+ newPasswordConfirm ?? _faker.Internet.Password()
+ );
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return Enumerable.Range(0, count)
+ .Select(_ => CreateChangePasswordRequest())
+ .ToList();
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/Fixtures/RecoverPasswordCommandFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/Fixtures/RecoverPasswordCommandFixture.cs
new file mode 100644
index 00000000..ec608ab4
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/Fixtures/RecoverPasswordCommandFixture.cs
@@ -0,0 +1,29 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
+using System.Diagnostics.CodeAnalysis;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.RecoverPassword.Fixtures;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordCommandFixture
+{
+ ///
+ /// Creates a random valid command for password recovery.
+ ///
+ /// The created command.
+ public static RecoverPasswordCommand CreateRecoverPasswordCommand()
+ {
+ return new Faker()
+ .CustomInstantiator(f => new RecoverPasswordCommand(
+ default!,
+ default!
+ ))
+ .RuleFor(x => x.Username, f => f.Person.UserName)
+ .RuleFor(x => x.TotpCode, f => f.Random.Replace("######")); // generates 6 random digits
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/Fixtures/RecoverPasswordRequestFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/Fixtures/RecoverPasswordRequestFixture.cs
new file mode 100644
index 00000000..b5d1c413
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/Fixtures/RecoverPasswordRequestFixture.cs
@@ -0,0 +1,52 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Authentication;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.RecoverPassword.Fixtures;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordRequestFixture
+{
+ private readonly Faker _faker;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RecoverPasswordRequestFixture()
+ {
+ _faker = new Faker();
+ }
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// The created .
+ public RecoverPasswordRequest CreateRecoverPasswordRequest(
+ string? username = null,
+ string? totpCode = null)
+ {
+ return new RecoverPasswordRequest(
+ username ?? _faker.Internet.UserName(),
+ totpCode ?? _faker.Random.Number(100000, 999999).ToString()
+ );
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return Enumerable.Range(0, count)
+ .Select(_ => CreateRecoverPasswordRequest())
+ .ToList();
+ }
+}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/RecoverPasswordCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/RecoverPasswordCommandHandlerTests.cs
new file mode 100644
index 00000000..2e54a568
--- /dev/null
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/UsersManagement/Authentication/Commands/RecoverPassword/RecoverPasswordCommandHandlerTests.cs
@@ -0,0 +1,288 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using FluentAssertions;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Common.DataAccess.Repositories.Users;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Errors;
+using Lumina.Application.Common.Infrastructure.Authentication;
+using Lumina.Application.Common.Infrastructure.Security;
+using Lumina.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
+using Lumina.Application.UnitTests.Common.Mapping.UserManagement.Users.Fixtures;
+using Lumina.Contracts.Responses.Authentication;
+using NSubstitute;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.UnitTests.Core.UsersManagement.Authentication.Commands.RecoverPassword;
+
+///
+/// Contains unit tests for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordCommandHandlerTests
+{
+ private readonly IUnitOfWork _mockUnitOfWork;
+ private readonly IHashService _mockHashService;
+ private readonly ITotpTokenGenerator _mockTotpTokenGenerator;
+ private readonly ICryptographyService _mockCryptographyService;
+ private readonly IUserRepository _mockUserRepository;
+ private readonly RecoverPasswordCommandHandler _sut;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RecoverPasswordCommandHandlerTests()
+ {
+ _mockUnitOfWork = Substitute.For();
+ _mockHashService = Substitute.For();
+ _mockTotpTokenGenerator = Substitute.For();
+ _mockCryptographyService = Substitute.For();
+ _mockUserRepository = Substitute.For();
+
+ _mockUnitOfWork.GetRepository().Returns(_mockUserRepository);
+
+ _sut = new RecoverPasswordCommandHandler(
+ _mockUnitOfWork,
+ _mockHashService,
+ _mockTotpTokenGenerator,
+ _mockCryptographyService);
+ }
+
+ [Fact]
+ public async Task Handle_WhenUserExistsAndTotpIsValid_ShouldResetPassword()
+ {
+ // Arrange
+ string totpCode = "123456";
+ string encryptedTotpSecret = Convert.ToBase64String(new byte[] { 1, 2, 3 });
+ string decryptedTotpSecret = Convert.ToBase64String(new byte[] { 4, 5, 6 });
+ string hashedTempPassword = "hashedTempPassword";
+
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ user.TotpSecret = encryptedTotpSecret;
+ user.TempPassword = null;
+
+ RecoverPasswordCommand command = new(user.Username, totpCode);
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+ _mockCryptographyService.Decrypt(encryptedTotpSecret)
+ .Returns(decryptedTotpSecret);
+ _mockTotpTokenGenerator.ValidateToken(Arg.Any(), totpCode)
+ .Returns(true);
+ _mockHashService.HashString("Abcd123$")
+ .Returns(hashedTempPassword);
+ _mockUserRepository.UpdateAsync(Arg.Any(), Arg.Any())
+ .Returns(Result.Updated);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeFalse();
+ result.Value.IsPasswordReset.Should().BeTrue();
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ _mockTotpTokenGenerator.Received(1).ValidateToken(Arg.Any(), totpCode);
+ _mockHashService.Received(1).HashString("Abcd123$");
+ await _mockUserRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.Received(1).SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenUserDoesNotExist_ShouldReturnError()
+ {
+ // Arrange
+ RecoverPasswordCommand command = new("nonexistentUser", "123456");
+
+ _mockUserRepository.GetByUsernameAsync(command.Username!, Arg.Any())
+ .Returns(ErrorOrFactory.From(null));
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(Errors.Authentication.UsernameDoesNotExist);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(command.Username!, Arg.Any());
+ await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenTempPasswordExists_ShouldReturnError()
+ {
+ // Arrange
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ user.TempPassword = "existingTempPassword";
+ user.TempPasswordCreated = DateTime.UtcNow;
+
+ RecoverPasswordCommand command = new(user.Username, "123456");
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(Errors.Authentication.PasswordResetAlreadyRequested);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenUserDoesNotUseTOTP_ShouldReturnError()
+ {
+ // Arrange
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ user.TotpSecret = null;
+
+ RecoverPasswordCommand command = new(user.Username, "123456");
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(Errors.Authentication.InvalidTotpCode);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenTotpCodeIsInvalid_ShouldReturnError()
+ {
+ // Arrange
+ string totpCode = "123456";
+ string encryptedTotpSecret = Convert.ToBase64String(new byte[] { 1, 2, 3 });
+ string decryptedTotpSecret = Convert.ToBase64String(new byte[] { 4, 5, 6 });
+
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ user.TotpSecret = encryptedTotpSecret;
+
+ RecoverPasswordCommand command = new(user.Username, totpCode);
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+ _mockCryptographyService.Decrypt(encryptedTotpSecret)
+ .Returns(decryptedTotpSecret);
+ _mockTotpTokenGenerator.ValidateToken(Arg.Any(), totpCode)
+ .Returns(false);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(Errors.Authentication.InvalidTotpCode);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ _mockTotpTokenGenerator.Received(1).ValidateToken(Arg.Any(), totpCode);
+ await _mockUserRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any());
+ }
+
+ [Fact]
+ public async Task Handle_WhenUpdateFails_ShouldReturnError()
+ {
+ // Arrange
+ string totpCode = "123456";
+ string encryptedTotpSecret = Convert.ToBase64String(new byte[] { 1, 2, 3 });
+ string decryptedTotpSecret = Convert.ToBase64String(new byte[] { 4, 5, 6 });
+ Error error = Error.Failure("Database.Error", "Failed to update user");
+
+ UserEntity user = UserEntityFixture.CreateUserEntity();
+ user.TotpSecret = encryptedTotpSecret;
+
+ RecoverPasswordCommand command = new(user.Username, totpCode);
+
+ _mockUserRepository.GetByUsernameAsync(user.Username, Arg.Any())
+ .Returns(ErrorOrFactory.From(user));
+ _mockCryptographyService.Decrypt(encryptedTotpSecret)
+ .Returns(decryptedTotpSecret);
+ _mockTotpTokenGenerator.ValidateToken(Arg.Any(), totpCode)
+ .Returns(true);
+ _mockUserRepository.UpdateAsync(Arg.Any(), Arg.Any())
+ .Returns(error);
+
+ // Act
+ ErrorOr result = await _sut.Handle(command, CancellationToken.None);
+
+ // Assert
+ result.IsError.Should().BeTrue();
+ result.FirstError.Should().Be(error);
+
+ await _mockUserRepository.Received(1).GetByUsernameAsync(user.Username, Arg.Any());
+ _mockTotpTokenGenerator.Received(1).ValidateToken(Arg.Any(), totpCode);
+ await _mockUserRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any());
+ await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any