Adds authentication support for integration testing

This commit is contained in:
BinaryAlley committed 2024-11-16 15:49:24 +02:00
1 parent f2703b86c5
commit 5aa7a5f672
33 files changed
+671 -227

No files matched your search

@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Mediator;
using System.Diagnostics;
@@ -13,6 +14,6 @@ namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathEx
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
[DebuggerDisplay("Path: {Path}, IncludeHiddenElements: {IncludeHiddenElements}")]
public record CheckPathExistsQuery(
string? Path,
string? Path,
bool IncludeHiddenElements
) : IRequest<PathExistsResponse>;
) : IRequest<ErrorOr<PathExistsResponse>>;
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Mediator;
@@ -11,7 +12,7 @@ namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathEx
/// <summary>
/// Handler for the query to check the existence a file system path.
/// </summary>
public class CheckPathExistsQueryHandler : IRequestHandler<CheckPathExistsQuery, PathExistsResponse>
public class CheckPathExistsQueryHandler : IRequestHandler<CheckPathExistsQuery, ErrorOr<PathExistsResponse>>
{
private readonly IPathService _pathService;
@@ -30,10 +31,10 @@ public class CheckPathExistsQueryHandler : IRequestHandler<CheckPathExistsQuery,
/// <param name="request">The query containing the request.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// <see langword="true"/> if the specified path exists, <see langword="false"/> otherwise.
/// An <see cref="ErrorOr{TValue}"/> containing either <see langword="true"/> if the specified path exists, <see langword="false"/> if it doesn't, or an error message.
/// </returns>
public ValueTask<PathExistsResponse> Handle(CheckPathExistsQuery request, CancellationToken cancellationToken)
public ValueTask<ErrorOr<PathExistsResponse>> Handle(CheckPathExistsQuery request, CancellationToken cancellationToken)
{
return ValueTask.FromResult(new PathExistsResponse(_pathService.Exists(request.Path!, request.IncludeHiddenElements)));
return ValueTask.FromResult(ErrorOrFactory.From(new PathExistsResponse(_pathService.Exists(request.Path!, request.IncludeHiddenElements))));
}
}
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
@@ -37,7 +38,6 @@ public class CheckPathExistsEndpoint : BaseEndpoint<CheckPathExistsRequest, IRes
Verbs(Http.GET);
Routes(ApiRoutes.Path.CHECK_PATH_EXISTS);
Version(1);
AllowAnonymous();
DontCatchExceptions();
}
@@ -48,7 +48,7 @@ public class CheckPathExistsEndpoint : BaseEndpoint<CheckPathExistsRequest, IRes
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(CheckPathExistsRequest request, CancellationToken cancellationToken)
{
PathExistsResponse result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
return TypedResults.Ok(result);
ErrorOr<PathExistsResponse> result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}