diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 317d652..614bcac 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -115,6 +115,20 @@ jobs: run: | dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest + - name: Run Integration Tests (UI Chrome) + env: + Browser: Chrome + run: | + dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest + + - name: Run Integration Tests (UI Edge) + env: + Browser: Edge + DriverPath: C:\\SeleniumWebDrivers\\EdgeDriver\\ + DriverExe: msedgedriver.exe + run: | + dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest + - uses: actions/upload-artifact@v4.4.0 if: ${{ failure() }} with: diff --git a/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs b/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs index 17c652e..46f261b 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs @@ -66,12 +66,12 @@ public void AfterScenario() public async Task BeforeScenario() { String? browser = Environment.GetEnvironmentVariable("Browser"); - //browser = "Firefox"; + //browser = "Edge"; if (browser == null || browser == "Chrome") { ChromeOptions options = new ChromeOptions(); options.AddArguments("--disable-gpu"); - //options.AddArguments("--headless"); + options.AddArguments("--headless"); options.AddArguments("--no-sandbox"); options.AddArguments("--disable-dev-shm-usage"); options.AddArguments("disable-infobars"); diff --git a/SecurityService/Controllers/ApiResourceController.cs b/SecurityService/Controllers/ApiResourceController.cs deleted file mode 100644 index 64e0323..0000000 --- a/SecurityService/Controllers/ApiResourceController.cs +++ /dev/null @@ -1,125 +0,0 @@ -/*using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Shared.Results; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using Azure.Core; - using Common.Examples; - using DataTransferObjects; - using DataTransferObjects.Requests; - using DataTransferObjects.Responses; - using Duende.IdentityServer.Models; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using SecurityService.BusinessLogic; - using SecurityService.BusinessLogic.Requests; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateApiResourceRequest = DataTransferObjects.Requests.CreateApiResourceRequest; - - /// - /// - /// - /// - [Route(ApiResourceController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class ApiResourceController : ControllerBase - { - private readonly IMediator Mediator; - private readonly IModelFactory ModelFactory; - - public ApiResourceController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - /// - /// Creates the API resource. - /// - /// The create API resource request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateApiResourceResponse))] - [SwaggerResponseExample(201, typeof(CreateApiResourceResponseExample))] - public async Task CreateApiResource([FromBody] CreateApiResourceRequest createApiResourceRequest, - CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateApiResourceCommand command = new(createApiResourceRequest.Name, - createApiResourceRequest.DisplayName, - createApiResourceRequest.Description, - createApiResourceRequest.Secret, - createApiResourceRequest.Scopes, - createApiResourceRequest.UserClaims); - - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the API resource. - /// - /// Name of the API resource. - /// The cancellation token. - /// - [HttpGet] - [Route("{apiResourceName}")] - [SwaggerResponse(201, type: typeof(ApiResourceDetails))] - [SwaggerResponseExample(201, typeof(ApiResourceDetailsResponseExample))] - public async Task GetApiResource([FromRoute] String apiResourceName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetApiResourceQuery query = new(apiResourceName); - - Result result= await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - - } - - /// - /// Gets the API resources. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(201, typeof(ApiResourceDetailsListResponseExample))] - public async Task GetApiResources(CancellationToken cancellationToken) { - SecurityServiceQueries.GetApiResourcesQuery query = new SecurityServiceQueries.GetApiResourcesQuery(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "apiresources"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + ApiResourceController.ControllerName; - - #endregion - } -} -*/ \ No newline at end of file diff --git a/SecurityService/Controllers/ApiScopeController.cs b/SecurityService/Controllers/ApiScopeController.cs deleted file mode 100644 index 0630741..0000000 --- a/SecurityService/Controllers/ApiScopeController.cs +++ /dev/null @@ -1,112 +0,0 @@ -/*using MediatR; -using Microsoft.AspNetCore.Http; -using SecurityService.BusinessLogic.RequestHandlers; -using SecurityService.BusinessLogic.Requests; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using BusinessLogic; - using Common.Examples; - using DataTransferObjects.Requests; - using DataTransferObjects.Responses; - using Duende.IdentityServer.Models; - using Factories; - using Microsoft.AspNetCore.Mvc; - using Shared.Results; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - - /// - /// - /// - /// - [Route(ApiScopeController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class ApiScopeController : ControllerBase - { - private readonly IMediator Mediator; - private readonly IModelFactory ModelFactory; - - public ApiScopeController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateApiScopeResponse))] - [SwaggerResponseExample(201, typeof(CreateApiScopeResponseExample))] - public async Task CreateApiScope([FromBody] CreateApiScopeRequest createApiScopeRequest, - CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateApiScopeCommand command = new(createApiScopeRequest.Name, - createApiScopeRequest.DisplayName, - createApiScopeRequest.Description); - - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the API scope. - /// - /// Name of the API scope. - /// The cancellation token. - /// - [HttpGet] - [Route("{apiScopeName}")] - [SwaggerResponse(200, type: typeof(ApiScopeDetails))] - [SwaggerResponseExample(200, typeof(ApiScopeDetailsResponseExample))] - public async Task GetApiScope([FromRoute] String apiScopeName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetApiScopeQuery query = new(apiScopeName); - - var result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the api scopes. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(200, typeof(ApiScopeDetailsListResponseExample))] - public async Task GetApiScopes(CancellationToken cancellationToken) - { - SecurityServiceQueries.GetApiScopesQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "apiscopes"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + ApiScopeController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Controllers/ClientController.cs b/SecurityService/Controllers/ClientController.cs deleted file mode 100644 index f10199b..0000000 --- a/SecurityService/Controllers/ClientController.cs +++ /dev/null @@ -1,158 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects; - using DataTransferObjects.Responses; - using Duende.IdentityServer.EntityFramework.Entities; - using Duende.IdentityServer.Models; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Shared.Results; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateClientRequest = DataTransferObjects.Requests.CreateClientRequest; - - /// - /// - /// - /// - [Route(ClientController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class ClientController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - /// - /// The model factory - /// - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The manager. - /// The model factory. - public ClientController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the client. - /// - /// The create client request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateClientResponse))] - [SwaggerResponseExample(201, typeof(CreateClientResponseExample))] - public async Task CreateClient([FromBody] CreateClientRequest createClientRequest, CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateClientCommand command = new(createClientRequest.ClientId, - createClientRequest.Secret, - createClientRequest.ClientName, - createClientRequest.ClientDescription, - createClientRequest.AllowedScopes, - createClientRequest.AllowedGrantTypes, - createClientRequest.ClientUri, - createClientRequest.ClientRedirectUris, - createClientRequest.ClientPostLogoutRedirectUris, - createClientRequest.RequireConsent, - createClientRequest.AllowOfflineAccess); - - // Create the client - Result result = await this.Mediator.Send(command, cancellationToken); - - //if (result.IsFailed) - // return result.ToActionResultX(); - - //// return the result - //return this.Created($"{ClientController.ControllerRoute}/{createClientRequest.ClientId}", - // new CreateClientResponse - // { - // ClientId = createClientRequest.ClientId - // }); - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the client. - /// - /// The client identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("{clientId}")] - [SwaggerResponse(200, type: typeof(ClientDetails))] - [SwaggerResponseExample(200, typeof(ClientDetailsResponseExample))] - public async Task GetClient([FromRoute] String clientId, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetClientQuery query = new(clientId); - - Result result= await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the clients. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(200, typeof(ClientDetailsListResponseExample))] - public async Task GetClients(CancellationToken cancellationToken) - { - SecurityServiceQueries.GetClientsQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "clients"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + ClientController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Controllers/DeveloperController.cs b/SecurityService/Controllers/DeveloperController.cs deleted file mode 100644 index 24c2401..0000000 --- a/SecurityService/Controllers/DeveloperController.cs +++ /dev/null @@ -1,67 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace SecurityService.Controllers -{ - using System; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Bootstrapper; - using BusinessLogic; - using MessagingService.Client; - using Microsoft.Extensions.Hosting; - - [Route(DeveloperController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class DeveloperController : ControllerBase - { - private readonly IMessagingServiceClient MessagingServiceClient; - - public DeveloperController(IMessagingServiceClient messagingServiceClient) { - this.MessagingServiceClient = messagingServiceClient; - } - - [HttpGet] - [Route("lastemail")] - public async Task GetLastEmailMessage(CancellationToken cancellationToken) { - if (Startup.WebHostEnvironment.IsEnvironment("IntegrationTest") && this.MessagingServiceClient.GetType() == typeof(TestMessagingServiceClient)) { - var lastEmailRequest = ((TestMessagingServiceClient)this.MessagingServiceClient).LastEmailRequest; - - return Ok(lastEmailRequest); - } - - return this.NotFound(); - } - - [HttpGet] - [Route("lastsms")] - public async Task GetLastSMSMessage(CancellationToken cancellationToken) - { - if (Startup.WebHostEnvironment.IsEnvironment("IntegrationTest") && this.MessagingServiceClient.GetType() == typeof(TestMessagingServiceClient)) - { - var lastSmsRequest = ((TestMessagingServiceClient)this.MessagingServiceClient).LastSMSRequest; - - return Ok(lastSmsRequest); - } - - return this.NotFound(); - } - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "developer"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + DeveloperController.ControllerName; - - #endregion - } -} -*/ \ No newline at end of file diff --git a/SecurityService/Controllers/IdentityResourceController.cs b/SecurityService/Controllers/IdentityResourceController.cs deleted file mode 100644 index 32f7c08..0000000 --- a/SecurityService/Controllers/IdentityResourceController.cs +++ /dev/null @@ -1,143 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects.Responses; - using Duende.IdentityServer.Models; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Shared.Results; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateIdentityResourceRequest = DataTransferObjects.Requests.CreateIdentityResourceRequest; - - /// - /// - /// - /// - [Route(IdentityResourceController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class IdentityResourceController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - /// - /// The model factory - /// - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The manager. - /// The model factory. - public IdentityResourceController(IMediator mediator, - IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the identity resource. - /// - /// The create identity resource request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateIdentityResourceResponse))] - [SwaggerResponseExample(201, typeof(CreateIdentityResourceResponseExample))] - public async Task CreateIdentityResource([FromBody] CreateIdentityResourceRequest createIdentityResourceRequest, - CancellationToken cancellationToken) - { - SecurityServiceCommands.CreateIdentityResourceCommand command = new(createIdentityResourceRequest.Name, - createIdentityResourceRequest.DisplayName, - createIdentityResourceRequest.Description, - createIdentityResourceRequest.Required, - createIdentityResourceRequest.Emphasize, - createIdentityResourceRequest.ShowInDiscoveryDocument, - createIdentityResourceRequest.Claims); - - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the identity resource. - /// - /// Name of the identity resource. - /// The cancellation token. - /// - [HttpGet] - [Route("{identityResourceName}")] - [SwaggerResponse(200, type: typeof(IdentityResourceDetails))] - [SwaggerResponseExample(200, typeof(IdentityResourceDetailsResponseExample))] - public async Task GetIdentityResource([FromRoute] String identityResourceName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetIdentityResourceQuery query = new(identityResourceName); - - Result result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the identity resources. - /// - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(200, typeof(IdentityResourceDetailsListResponseExample))] - public async Task GetIdentityResources(CancellationToken cancellationToken) { - SecurityServiceQueries.GetIdentityResourcesQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "identityresources"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + IdentityResourceController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Controllers/RoleController.cs b/SecurityService/Controllers/RoleController.cs deleted file mode 100644 index d7c5f37..0000000 --- a/SecurityService/Controllers/RoleController.cs +++ /dev/null @@ -1,126 +0,0 @@ -/*using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Shared.Results; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System.Threading; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects.Responses; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateRoleRequest = DataTransferObjects.Requests.CreateRoleRequest; - - [Route(RoleController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class RoleController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - public RoleController(IMediator mediator, IModelFactory modelFactory) - { - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the role. - /// - /// The create role request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateRoleResponse))] - [SwaggerResponseExample(statusCode: 201, typeof(CreateRoleResponseExample))] - public async Task CreateRole([FromBody] CreateRoleRequest createRoleRequest, CancellationToken cancellationToken) - { - Guid roleId = Guid.NewGuid(); - SecurityServiceCommands.CreateRoleCommand command = new(roleId, createRoleRequest.RoleName); - - Result result = await this.Mediator.Send(command, cancellationToken); - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the role. - /// - /// The role identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("{roleId}")] - [SwaggerResponse(200, type: typeof(RoleDetails))] - [SwaggerResponseExample(statusCode: 200, typeof(RoleDetailsResponseExample))] - public async Task GetRole([FromRoute] Guid roleId, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetRoleQuery query = new(roleId); - - Result result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the roles. - /// - /// The role identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(statusCode: 200, typeof(RoleDetailsListResponseExample))] - public async Task GetRoles(CancellationToken cancellationToken) - { - SecurityServiceQueries.GetRolesQuery query = new(); - - Result> result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "roles"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + RoleController.ControllerName; - - #endregion - } -} -*/ \ No newline at end of file diff --git a/SecurityService/Controllers/UserController.cs b/SecurityService/Controllers/UserController.cs deleted file mode 100644 index 3b7c514..0000000 --- a/SecurityService/Controllers/UserController.cs +++ /dev/null @@ -1,147 +0,0 @@ -/*using Microsoft.AspNetCore.Http; -using Shared.Results; -using Shared.Results.Web; -using SimpleResults; - -namespace SecurityService.Controllers -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Azure.Core; - using BusinessLogic; - using BusinessLogic.Requests; - using Common.Examples; - using DataTransferObjects; - using DataTransferObjects.Responses; - using Factories; - using MediatR; - using Microsoft.AspNetCore.Mvc; - using Swashbuckle.AspNetCore.Annotations; - using Swashbuckle.AspNetCore.Filters; - using CreateUserRequest = DataTransferObjects.CreateUserRequest; - - /// - /// - /// - /// - [Route(UserController.ControllerRoute)] - [ApiController] - [ExcludeFromCodeCoverage] - public class UserController : ControllerBase - { - #region Fields - - private readonly IMediator Mediator; - - private readonly IModelFactory ModelFactory; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The manager. - /// The model factory. - public UserController(IMediator mediator, IModelFactory modelFactory){ - this.Mediator = mediator; - this.ModelFactory = modelFactory; - } - - #endregion - - #region Methods - - /// - /// Creates the user. - /// - /// The create user request. - /// The cancellation token. - /// - [HttpPost] - [Route("")] - [SwaggerResponse(201, type: typeof(CreateUserResponse))] - [SwaggerResponseExample(statusCode: 201, typeof(CreateUserResponseExample))] - public async Task CreateUser([FromBody] CreateUserRequest createUserRequest, CancellationToken cancellationToken) - { - Guid userId = Guid.NewGuid(); - - SecurityServiceCommands.CreateUserCommand command =new(userId, - createUserRequest.GivenName, - createUserRequest.MiddleName, - createUserRequest.FamilyName, - createUserRequest.EmailAddress, - createUserRequest.Password, - createUserRequest.EmailAddress, - createUserRequest.PhoneNumber, - createUserRequest.Claims, - createUserRequest.Roles); - - // Create the user - Result result = await this.Mediator.Send(command, cancellationToken); - - return ResponseFactory.FromResult(result); - } - - /// - /// Gets the user. - /// - /// The user identifier. - /// The cancellation token. - /// - [HttpGet] - [Route("{userId}")] - [SwaggerResponse(200, type: typeof(UserDetails))] - [SwaggerResponseExample(statusCode: 200, typeof(UserDetailsResponseExample))] - public async Task GetUser([FromRoute] Guid userId, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetUserQuery query = new(userId); - - Result result = await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - /// - /// Gets the users. - /// - /// Name of the user. - /// The cancellation token. - /// - [HttpGet] - [Route("")] - [SwaggerResponse(200, type: typeof(List))] - [SwaggerResponseExample(statusCode: 200, typeof(UserDetailsListResponseExample))] - - public async Task GetUsers([FromQuery] String userName, - CancellationToken cancellationToken) - { - SecurityServiceQueries.GetUsersQuery query = new(userName); - - Result> result= await this.Mediator.Send(query, cancellationToken); - - return ResponseFactory.FromResult(result, this.ModelFactory.ConvertFrom); - } - - #endregion - - #region Others - - /// - /// The controller name - /// - private const String ControllerName = "users"; - - /// - /// The controller route - /// - private const String ControllerRoute = "api/" + UserController.ControllerName; - - #endregion - } -}*/ \ No newline at end of file diff --git a/SecurityService/Handlers/DeveloperHandler.cs b/SecurityService/Handlers/DeveloperHandler.cs index 5438d4c..7458806 100644 --- a/SecurityService/Handlers/DeveloperHandler.cs +++ b/SecurityService/Handlers/DeveloperHandler.cs @@ -22,7 +22,7 @@ public static Task GetLastEmailMessage(IMessagingServiceClient messagin return Task.FromResult(Results.Ok(lastEmailRequest) as IResult); } - return Task.FromResult(Results.NotFound() as IResult); + return Task.FromResult(Results.BadRequest() as IResult); } public static Task GetLastSMSMessage(IMessagingServiceClient messagingServiceClient,