Merge pull request #97 from BinaryAlley/refactor/update-authorization-roles-and-permissions-api-routes

Updates the authorization roles and permissions API routes
This commit is contained in:
BinaryAlley authored and GitHub committed 2025-01-02 14:42:25 +02:00
commit 8c579cd4bd
34 files changed
+116 -116

No files matched your search

@@ -40,7 +40,7 @@
#### Get Permissions Request
```js
GET api/v1/permissions
GET api/v1/auth/permissions
```
#### Get Permissions Response
@@ -73,7 +73,7 @@ GET api/v1/permissions
#### Get Roles Request
```js
GET api/v1/roles
GET api/v1/auth/roles
```
#### Get Roles Response
@@ -96,7 +96,7 @@ GET api/v1/roles
#### Get Role Permissions Request
```js
GET api/v1/roles/{roleId}/permissions
GET api/v1/auth/roles/{roleId}/permissions
```
#### Get Role Permissions Response
@@ -127,7 +127,7 @@ GET api/v1/roles/{roleId}/permissions
#### Add Role Request
```js
POST api/v1/roles
POST api/v1/auth/roles
```
#### Add Role Response
@@ -160,7 +160,7 @@ POST api/v1/roles
#### Update Role Request
```js
PUT api/v1/roles
PUT api/v1/auth/roles
```
```json
@@ -204,7 +204,7 @@ PUT api/v1/roles
#### Delete Role Request
```js
DELETE api/v1/roles/{roleId}
DELETE api/v1/auth/roles/{roleId}
```
#### Delete Role Response
@@ -1,2 +1,2 @@
GET {{host}}/api/v1/roles
GET {{host}}/api/v1/auth/roles
Authorization: Bearer {{ACCESS_TOKEN}}
@@ -1,2 +1,2 @@
DELETE {{host}}/api/v1/roles/{{$guid}}
DELETE {{host}}/api/v1/auth/roles/{{$guid}}
Authorization: Bearer {{ACCESS_TOKEN}}
@@ -1,2 +1,2 @@
GET {{host}}/api/v1/permissions
GET {{host}}/api/v1/auth/permissions
Authorization: Bearer {{ACCESS_TOKEN}}
@@ -1,2 +1,2 @@
GET {{host}}/api/v1/roles/{{$guid}}/permissions
GET {{host}}/api/v1/auth/roles/{{$guid}}/permissions
Authorization: Bearer {{ACCESS_TOKEN}}
@@ -1,2 +1,2 @@
GET {{host}}/api/v1/roles
GET {{host}}/api/v1/auth/roles
Authorization: Bearer {{ACCESS_TOKEN}}
@@ -1,4 +1,4 @@
PUT {{host}}/api/v1/roles
PUT {{host}}/api/v1/auth/roles
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
@@ -10,6 +10,6 @@ public static partial class ApiRoutes
/// </summary>
public static class Permissions
{
public const string GET_PERMISSIONS = "/permissions";
public const string GET_PERMISSIONS = "/auth/permissions";
}
}
@@ -10,10 +10,10 @@ public static partial class ApiRoutes
/// </summary>
public static class Roles
{
public const string GET_ROLE_PERMISSIONS_BY_ROLE_ID = "/roles/{roleId}/permissions";
public const string GET_ROLES = "/roles";
public const string CREATE_ROLE = "/roles";
public const string UPDATE_ROLE = "/roles";
public const string DELETE_ROLE = "/roles/{roleId}";
public const string GET_ROLE_PERMISSIONS_BY_ROLE_ID = "/auth/roles/{roleId}/permissions";
public const string GET_ROLES = "/auth/roles";
public const string CREATE_ROLE = "/auth/roles";
public const string UPDATE_ROLE = "/auth/roles";
public const string DELETE_ROLE = "/auth/roles/{roleId}";
}
}
@@ -16,7 +16,7 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Permissions.GetPermissions;
/// <summary>
/// API endpoint for the <c>/permissions</c> route.
/// API endpoint for the <c>/auth/permissions</c> route.
/// </summary>
public class GetPermissionsEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
@@ -40,7 +40,7 @@ public class GetPermissionsEndpointSummary : Summary<GetPermissionsEndpoint, Emp
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/permissions"
instance = "/api/v1/auth/permissions"
},
new
{
@@ -48,7 +48,7 @@ public class GetPermissionsEndpointSummary : Summary<GetPermissionsEndpoint, Emp
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/permissions"
instance = "/api/v1/auth/permissions"
},
new
{
@@ -56,7 +56,7 @@ public class GetPermissionsEndpointSummary : Summary<GetPermissionsEndpoint, Emp
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/permissions"
instance = "/api/v1/auth/permissions"
}
}
);
@@ -68,7 +68,7 @@ public class GetPermissionsEndpointSummary : Summary<GetPermissionsEndpoint, Emp
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/permissions",
instance = "/api/v1/auth/permissions",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.AddRole;
/// <summary>
/// API endpoint for the <c>/roles</c> route.
/// API endpoint for the <c>/auth/roles</c> route.
/// </summary>
public class AddRoleEndpoint : BaseEndpoint<AddRoleRequest, IResult>
{
@@ -55,7 +55,7 @@ public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
},
new
{
@@ -63,7 +63,7 @@ public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
},
new
{
@@ -71,7 +71,7 @@ public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
}
}
);
@@ -83,7 +83,7 @@ public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/roles",
instance = "/api/v1/auth/roles",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
@@ -95,7 +95,7 @@ public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
title = "General.Conflict",
status = 409,
detail = "RoleAlreadyExists",
instance = "/api/v1/roles",
instance = "/api/v1/auth/roles",
traceId = "00-f8784de7cb2d70b81b2529893068bee7-4779e0404fe5f554-00"
}
);
@@ -107,7 +107,7 @@ public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/roles",
instance = "/api/v1/auth/roles",
errors = new Dictionary<string, string[]>
{
{
@@ -14,7 +14,7 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.DeleteRole;
/// <summary>
/// API endpoint for the <c>/roles</c> route.
/// API endpoint for the <c>/auth/roles</c> route.
/// </summary>
public class DeleteRoleEndpoint : BaseEndpoint<DeleteRoleRequest, IResult>
{
@@ -41,7 +41,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/roles/{roleId}"
instance = "/api/v1/auth/roles/{roleId}"
},
new
{
@@ -49,7 +49,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/roles/{roleId}"
instance = "/api/v1/auth/roles/{roleId}"
},
new
{
@@ -57,7 +57,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/roles/{roleId}"
instance = "/api/v1/auth/roles/{roleId}"
}
}
);
@@ -71,7 +71,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.Failure",
status = 403,
detail = "AdminRoleCannotBeDeleted",
instance = "/api/v1/roles/{roleId}",
instance = "/api/v1/auth/roles/{roleId}",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
},
new
@@ -80,7 +80,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/roles/{roleId}",
instance = "/api/v1/auth/roles/{roleId}",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
}
@@ -93,7 +93,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.NotFound",
status = 404,
detail = "RoleNotFound",
instance = "/api/v1/roles/{roleId}",
instance = "/api/v1/auth/roles/{roleId}",
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
}
);
@@ -105,7 +105,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/roles/{roleId}",
instance = "/api/v1/auth/roles/{roleId}",
errors = new Dictionary<string, string[]>
{
{
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.GetRolePermissions;
/// <summary>
/// API endpoint for the <c>/roles/{roleId}/permissions</c> route.
/// API endpoint for the <c>/auth/roles/{roleId}/permissions</c> route.
/// </summary>
public class GetRolePermissionsEndpoint : BaseEndpoint<GetRolePermissionsRequest, IResult>
{
@@ -46,7 +46,7 @@ public class GetRolePermissionsEndpointSummary : Summary<GetRolePermissionsEndpo
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/roles/{roleId}/permissions"
instance = "/api/v1/auth/roles/{roleId}/permissions"
},
new
{
@@ -54,7 +54,7 @@ public class GetRolePermissionsEndpointSummary : Summary<GetRolePermissionsEndpo
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/roles/{roleId}/permissions"
instance = "/api/v1/auth/roles/{roleId}/permissions"
},
new
{
@@ -62,7 +62,7 @@ public class GetRolePermissionsEndpointSummary : Summary<GetRolePermissionsEndpo
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/roles/{roleId}/permissions"
instance = "/api/v1/auth/roles/{roleId}/permissions"
}
}
);
@@ -74,7 +74,7 @@ public class GetRolePermissionsEndpointSummary : Summary<GetRolePermissionsEndpo
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/roles/{roleId}/permissions",
instance = "/api/v1/auth/roles/{roleId}/permissions",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
@@ -86,7 +86,7 @@ public class GetRolePermissionsEndpointSummary : Summary<GetRolePermissionsEndpo
title = "General.NotFound",
status = 404,
detail = "RoleNotFound",
instance = "/api/v1/roles/{roleId}/permissions",
instance = "/api/v1/auth/roles/{roleId}/permissions",
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
}
);
@@ -98,7 +98,7 @@ public class GetRolePermissionsEndpointSummary : Summary<GetRolePermissionsEndpo
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/roles/{roleId}/permissions",
instance = "/api/v1/auth/roles/{roleId}/permissions",
errors = new Dictionary<string, string[]>
{
{
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.GetRoles;
/// <summary>
/// API endpoint for the <c>/roles</c> route.
/// API endpoint for the <c>/auth/roles</c> route.
/// </summary>
public class GetRolesEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
@@ -35,7 +35,7 @@ public class GetRolesEndpointSummary : Summary<GetRolesEndpoint, EmptyRequest>
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
},
new
{
@@ -43,7 +43,7 @@ public class GetRolesEndpointSummary : Summary<GetRolesEndpoint, EmptyRequest>
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
},
new
{
@@ -51,7 +51,7 @@ public class GetRolesEndpointSummary : Summary<GetRolesEndpoint, EmptyRequest>
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
}
}
);
@@ -63,7 +63,7 @@ public class GetRolesEndpointSummary : Summary<GetRolesEndpoint, EmptyRequest>
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/roles",
instance = "/api/v1/auth/roles",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.UpdateRole;
/// <summary>
/// API endpoint for the <c>/roles</c> route.
/// API endpoint for the <c>/auth/roles</c> route.
/// </summary>
public class UpdateRoleEndpoint : BaseEndpoint<UpdateRoleRequest, IResult>
{
@@ -57,7 +57,7 @@ public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleR
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
},
new
{
@@ -65,7 +65,7 @@ public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleR
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
},
new
{
@@ -73,7 +73,7 @@ public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleR
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/roles"
instance = "/api/v1/auth/roles"
}
}
);
@@ -85,7 +85,7 @@ public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleR
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/roles",
instance = "/api/v1/auth/roles",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
@@ -97,7 +97,7 @@ public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleR
title = "General.NotFound",
status = 404,
detail = "RoleNotFound",
instance = "/api/v1/roles",
instance = "/api/v1/auth/roles",
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
}
);
@@ -109,7 +109,7 @@ public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleR
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/roles",
instance = "/api/v1/auth/roles",
errors = new Dictionary<string, string[]>
{
{
@@ -39,8 +39,8 @@ public class AdminController : Controller
public async Task<IActionResult> ManageRoles(CancellationToken cancellationToken)
{
// get the list of roles and permissions from the API
ViewData["roles"] = await _apiHttpClient.GetAsync<RoleModel[]>($"roles/", cancellationToken).ConfigureAwait(false);
ViewData["permissions"] = await _apiHttpClient.GetAsync<PermissionModel[]>($"permissions/", cancellationToken).ConfigureAwait(false);
ViewData["roles"] = await _apiHttpClient.GetAsync<RoleModel[]>($"auth/roles/", cancellationToken).ConfigureAwait(false);
ViewData["permissions"] = await _apiHttpClient.GetAsync<PermissionModel[]>($"auth/permissions/", cancellationToken).ConfigureAwait(false);
return View();
}
@@ -52,8 +52,8 @@ public class AdminController : Controller
public async Task<IActionResult> ManagePermissions(CancellationToken cancellationToken)
{
ViewData["users"] = await _apiHttpClient.GetAsync<UserModel[]>($"auth/users", cancellationToken).ConfigureAwait(false);
ViewData["roles"] = await _apiHttpClient.GetAsync<RoleModel[]>($"roles/", cancellationToken).ConfigureAwait(false);
ViewData["permissions"] = await _apiHttpClient.GetAsync<PermissionModel[]>($"permissions/", cancellationToken).ConfigureAwait(false);
ViewData["roles"] = await _apiHttpClient.GetAsync<RoleModel[]>($"auth/roles/", cancellationToken).ConfigureAwait(false);
ViewData["permissions"] = await _apiHttpClient.GetAsync<PermissionModel[]>($"auth/permissions/", cancellationToken).ConfigureAwait(false);
return View();
}
@@ -65,7 +65,7 @@ public class AdminController : Controller
[HttpGet("api-get-permissions-by-role-id/{roleId}")]
public async Task<IActionResult> GetPermissionsByRoleId(Guid roleId, CancellationToken cancellationToken)
{
RolePermissionsModel response = await _apiHttpClient.GetAsync<RolePermissionsModel>($"roles/{roleId}/permissions", cancellationToken).ConfigureAwait(false);
RolePermissionsModel response = await _apiHttpClient.GetAsync<RolePermissionsModel>($"auth/roles/{roleId}/permissions", cancellationToken).ConfigureAwait(false);
return Json(new { success = true, data = response });
}
@@ -100,7 +100,7 @@ public class AdminController : Controller
[HttpGet("api-get-roles")]
public async Task<IActionResult> GetRoles(CancellationToken cancellationToken)
{
RoleModel[] response = await _apiHttpClient.GetAsync<RoleModel[]>($"roles/", cancellationToken).ConfigureAwait(false);
RoleModel[] response = await _apiHttpClient.GetAsync<RoleModel[]>($"auth/roles/", cancellationToken).ConfigureAwait(false);
return Json(new { success = true, data = response });
}
@@ -112,7 +112,7 @@ public class AdminController : Controller
[HttpPost("api-create-role")]
public async Task<IActionResult> CreateRole([FromBody] AddRoleRequestModel model, CancellationToken cancellationToken)
{
RolePermissionsModel response = await _apiHttpClient.PostAsync<RolePermissionsModel, AddRoleRequestModel>($"roles/", model, cancellationToken).ConfigureAwait(false);
RolePermissionsModel response = await _apiHttpClient.PostAsync<RolePermissionsModel, AddRoleRequestModel>($"auth/roles/", model, cancellationToken).ConfigureAwait(false);
return Json(new { success = true, data = response });
}
@@ -124,7 +124,7 @@ public class AdminController : Controller
[HttpPut("api-update-role")]
public async Task<IActionResult> UpdateRole([FromBody] UpdateRoleRequestModel model, CancellationToken cancellationToken)
{
RolePermissionsModel response = await _apiHttpClient.PutAsync<RolePermissionsModel, UpdateRoleRequestModel>($"roles/", model, cancellationToken).ConfigureAwait(false);
RolePermissionsModel response = await _apiHttpClient.PutAsync<RolePermissionsModel, UpdateRoleRequestModel>($"auth/roles/", model, cancellationToken).ConfigureAwait(false);
return Json(new { success = true, data = response });
}
@@ -136,7 +136,7 @@ public class AdminController : Controller
[HttpDelete("api-delete-role/{roleId}")]
public async Task<IActionResult> DeleteRole(Guid roleId, CancellationToken cancellationToken)
{
await _apiHttpClient.DeleteAsync($"roles/{roleId}", cancellationToken).ConfigureAwait(false);
await _apiHttpClient.DeleteAsync($"auth/roles/{roleId}", cancellationToken).ConfigureAwait(false);
return Json(new { success = true });
}
@@ -59,7 +59,7 @@ public class GetPermissionsEndpointTests : IClassFixture<AuthenticatedLuminaApiF
public async Task ExecuteAsync_WhenCalledWithValidRequest_ShouldReturnPermissions()
{
// Act
HttpResponseMessage response = await _client.GetAsync("/api/v1/permissions");
HttpResponseMessage response = await _client.GetAsync("/api/v1/auth/permissions");
// Assert
response.EnsureSuccessStatusCode();
@@ -82,7 +82,7 @@ public class GetPermissionsEndpointTests : IClassFixture<AuthenticatedLuminaApiF
{
// Act
_client = await _apiFactory.CreateAuthenticatedClientAsync(); // authenticated user, but not admin
HttpResponseMessage response = await _client.GetAsync("/api/v1/permissions");
HttpResponseMessage response = await _client.GetAsync("/api/v1/auth/permissions");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
@@ -95,7 +95,7 @@ public class GetPermissionsEndpointTests : IClassFixture<AuthenticatedLuminaApiF
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails["title"].GetString().Should().Be("General.Unauthorized");
problemDetails["detail"].GetString().Should().Be("NotAuthorized");
problemDetails["instance"].GetString().Should().Be("/api/v1/permissions");
problemDetails["instance"].GetString().Should().Be("/api/v1/auth/permissions");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -109,7 +109,7 @@ public class GetPermissionsEndpointTests : IClassFixture<AuthenticatedLuminaApiF
Func<Task> act = async () =>
{
cts.Cancel();
await _client.GetAsync("/api/v1/permissions", cts.Token);
await _client.GetAsync("/api/v1/auth/permissions", cts.Token);
};
// Assert
@@ -71,7 +71,7 @@ public class AddRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
);
// Act
HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/roles", request);
HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/auth/roles", request);
// Assert
response.EnsureSuccessStatusCode();
@@ -101,7 +101,7 @@ public class AddRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
);
// Act
HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/roles", request);
HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/auth/roles", request);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
@@ -113,7 +113,7 @@ public class AddRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails["title"].GetString().Should().Be("General.Unauthorized");
problemDetails["detail"].GetString().Should().Be("NotAuthorized");
problemDetails["instance"].GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetString().Should().Be("/api/v1/auth/roles");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -127,7 +127,7 @@ public class AddRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
);
// Act
HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/roles", request);
HttpResponseMessage response = await _client.PostAsJsonAsync("/api/v1/auth/roles", request);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Conflict);
@@ -139,7 +139,7 @@ public class AddRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.10");
problemDetails["title"].GetString().Should().Be("General.Conflict");
problemDetails["detail"].GetString().Should().Be("RoleAlreadyExists");
problemDetails["instance"].GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetString().Should().Be("/api/v1/auth/roles");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -157,7 +157,7 @@ public class AddRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
Func<Task> act = async () =>
{
cts.Cancel();
await _client.PostAsJsonAsync("/api/v1/roles", request, cts.Token);
await _client.PostAsJsonAsync("/api/v1/auth/roles", request, cts.Token);
};
// Assert
@@ -72,7 +72,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
await dbContext.SaveChangesAsync();
// Act
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/roles/{role.Id}");
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/auth/roles/{role.Id}");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.NoContent);
@@ -90,7 +90,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
Guid roleId = Guid.NewGuid();
// Act
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/roles/{roleId}");
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/auth/roles/{roleId}");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
@@ -102,7 +102,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails["title"].GetString().Should().Be("General.Unauthorized");
problemDetails["detail"].GetString().Should().Be("NotAuthorized");
problemDetails["instance"].GetString().Should().Be($"/api/v1/roles/{roleId}");
problemDetails["instance"].GetString().Should().Be($"/api/v1/auth/roles/{roleId}");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -116,7 +116,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
adminRole.Should().NotBeNull("Admin role should exist");
// Act
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/roles/{adminRole!.Id}");
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/auth/roles/{adminRole!.Id}");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
@@ -128,7 +128,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails["title"].GetString().Should().Be("General.Forbidden");
problemDetails["detail"].GetString().Should().Be("AdminRoleCannotBeDeleted");
problemDetails["instance"].GetString().Should().Be($"/api/v1/roles/{adminRole!.Id}");
problemDetails["instance"].GetString().Should().Be($"/api/v1/auth/roles/{adminRole!.Id}");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -139,7 +139,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
Guid nonExistentRoleId = Guid.NewGuid();
// Act
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/roles/{nonExistentRoleId}");
HttpResponseMessage response = await _client.DeleteAsync($"/api/v1/auth/roles/{nonExistentRoleId}");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
@@ -151,7 +151,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails["title"].GetString().Should().Be("General.NotFound");
problemDetails["detail"].GetString().Should().Be("RoleNotFound");
problemDetails["instance"].GetString().Should().Be($"/api/v1/roles/{nonExistentRoleId}");
problemDetails["instance"].GetString().Should().Be($"/api/v1/auth/roles/{nonExistentRoleId}");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -166,7 +166,7 @@ public class DeleteRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
Func<Task> act = async () =>
{
cts.Cancel();
await _client.DeleteAsync($"/api/v1/roles/{roleId}", cts.Token);
await _client.DeleteAsync($"/api/v1/auth/roles/{roleId}", cts.Token);
};
// Assert
@@ -65,7 +65,7 @@ public class GetRolePermissionsEndpointTests : IClassFixture<AuthenticatedLumina
role.Should().NotBeNull("Admin role should exist");
// Act
HttpResponseMessage response = await _client.GetAsync($"/api/v1/roles/{role!.Id}/permissions");
HttpResponseMessage response = await _client.GetAsync($"/api/v1/auth/roles/{role!.Id}/permissions");
// Assert
response.EnsureSuccessStatusCode();
@@ -96,7 +96,7 @@ public class GetRolePermissionsEndpointTests : IClassFixture<AuthenticatedLumina
role.Should().NotBeNull("Admin role should exist");
// Act
HttpResponseMessage response = await _client.GetAsync($"/api/v1/roles/{role!.Id}/permissions");
HttpResponseMessage response = await _client.GetAsync($"/api/v1/auth/roles/{role!.Id}/permissions");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
@@ -108,7 +108,7 @@ public class GetRolePermissionsEndpointTests : IClassFixture<AuthenticatedLumina
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails["title"].GetString().Should().Be("General.Unauthorized");
problemDetails["detail"].GetString().Should().Be("NotAuthorized");
problemDetails["instance"].GetString().Should().Be($"/api/v1/roles/{role.Id}/permissions");
problemDetails["instance"].GetString().Should().Be($"/api/v1/auth/roles/{role.Id}/permissions");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -117,7 +117,7 @@ public class GetRolePermissionsEndpointTests : IClassFixture<AuthenticatedLumina
{
// Act
Guid invalidRoleId = Guid.NewGuid();
HttpResponseMessage response = await _client.GetAsync($"/api/v1/roles/{invalidRoleId}/permissions");
HttpResponseMessage response = await _client.GetAsync($"/api/v1/auth/roles/{invalidRoleId}/permissions");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
@@ -129,7 +129,7 @@ public class GetRolePermissionsEndpointTests : IClassFixture<AuthenticatedLumina
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails["title"].GetString().Should().Be("General.NotFound");
problemDetails["detail"].GetString().Should().Be("RoleNotFound");
problemDetails["instance"].GetString().Should().Be($"/api/v1/roles/{invalidRoleId}/permissions");
problemDetails["instance"].GetString().Should().Be($"/api/v1/auth/roles/{invalidRoleId}/permissions");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -147,7 +147,7 @@ public class GetRolePermissionsEndpointTests : IClassFixture<AuthenticatedLumina
Func<Task> act = async () =>
{
cts.Cancel();
await _client.GetAsync($"/api/v1/roles/{role!.Id}/permissions", cts.Token);
await _client.GetAsync($"/api/v1/auth/roles/{role!.Id}/permissions", cts.Token);
};
// Assert
@@ -57,7 +57,7 @@ public class GetRolesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
public async Task ExecuteAsync_WhenCalledWithValidRequest_ShouldReturnRoles()
{
// Act
HttpResponseMessage response = await _client.GetAsync("/api/v1/roles");
HttpResponseMessage response = await _client.GetAsync("/api/v1/auth/roles");
// Assert
response.EnsureSuccessStatusCode();
@@ -81,7 +81,7 @@ public class GetRolesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
_client = await _apiFactory.CreateAuthenticatedClientAsync();
// Act
HttpResponseMessage response = await _client.GetAsync("/api/v1/roles");
HttpResponseMessage response = await _client.GetAsync("/api/v1/auth/roles");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
@@ -93,7 +93,7 @@ public class GetRolesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails["title"].GetString().Should().Be("General.Unauthorized");
problemDetails["detail"].GetString().Should().Be("NotAuthorized");
problemDetails["instance"].GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetString().Should().Be("/api/v1/auth/roles");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -107,7 +107,7 @@ public class GetRolesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory
Func<Task> act = async () =>
{
cts.Cancel();
await _client.GetAsync("/api/v1/roles", cts.Token);
await _client.GetAsync("/api/v1/auth/roles", cts.Token);
};
// Assert
@@ -82,7 +82,7 @@ public class UpdateRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
);
// Act
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/roles", request);
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/auth/roles", request);
// Assert
response.EnsureSuccessStatusCode();
@@ -114,7 +114,7 @@ public class UpdateRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
);
// Act
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/roles", request);
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/auth/roles", request);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
@@ -126,7 +126,7 @@ public class UpdateRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails["title"].GetString().Should().Be("General.Unauthorized");
problemDetails["detail"].GetString().Should().Be("NotAuthorized");
problemDetails["instance"].GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetString().Should().Be("/api/v1/auth/roles");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -142,7 +142,7 @@ public class UpdateRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
);
// Act
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/roles", request);
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/auth/roles", request);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
@@ -154,7 +154,7 @@ public class UpdateRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails["title"].GetString().Should().Be("General.NotFound");
problemDetails["detail"].GetString().Should().Be("RoleNotFound");
problemDetails["instance"].GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetString().Should().Be("/api/v1/auth/roles");
problemDetails["traceId"].GetString().Should().NotBeNullOrWhiteSpace();
}
@@ -173,7 +173,7 @@ public class UpdateRoleEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
Func<Task> act = async () =>
{
cts.Cancel();
await _client.PutAsJsonAsync($"/api/v1/roles", request, cts.Token);
await _client.PutAsJsonAsync($"/api/v1/auth/roles", request, cts.Token);
};
// Assert
@@ -10,7 +10,7 @@ using System.Text.Json;
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Permissions;
/// <summary>
/// Contains security tests for the <c>/permissions</c> route.
/// Contains security tests for the <c>/auth/permissions</c> route.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPermissionsEndpointTests : IClassFixture<LuminaApiFactory>
@@ -34,7 +34,7 @@ public class GetPermissionsEndpointTests : IClassFixture<LuminaApiFactory>
public async Task GetPermissions_WhenUnauthorized_ShouldReturnUnauthorizedResult()
{
// Act
HttpResponseMessage response = await _client.GetAsync("/api/v1/permissions");
HttpResponseMessage response = await _client.GetAsync("/api/v1/auth/permissions");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
@@ -46,7 +46,7 @@ public class GetPermissionsEndpointTests : IClassFixture<LuminaApiFactory>
problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status401Unauthorized);
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc7235#section-3.1");
problemDetails["title"].GetString().Should().Be("Unauthorized");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/permissions");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/auth/permissions");
problemDetails["detail"].GetString().Should().Be("Authentication failed");
}
}
@@ -11,7 +11,7 @@ using System.Text.Json;
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Roles;
/// <summary>
/// Contains security tests for the <c>/roles</c> route.
/// Contains security tests for the <c>/auth/roles</c> route.
/// </summary>
[ExcludeFromCodeCoverage]
public class AddRoleEndpointTests : IClassFixture<LuminaApiFactory>
@@ -43,7 +43,7 @@ public class AddRoleEndpointTests : IClassFixture<LuminaApiFactory>
StringContent content = new(JsonSerializer.Serialize(requestBody), Encoding.UTF8, "application/json");
// Act
HttpResponseMessage response = await _client.PostAsync("/api/v1/roles", content);
HttpResponseMessage response = await _client.PostAsync("/api/v1/auth/roles", content);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
@@ -55,7 +55,7 @@ public class AddRoleEndpointTests : IClassFixture<LuminaApiFactory>
problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status401Unauthorized);
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc7235#section-3.1");
problemDetails["title"].GetString().Should().Be("Unauthorized");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/auth/roles");
problemDetails["detail"].GetString().Should().Be("Authentication failed");
}
}
@@ -10,7 +10,7 @@ using System.Text.Json;
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Roles;
/// <summary>
/// Contains security tests for the <c>/roles/{roleId}</c> route.
/// Contains security tests for the <c>/auth/roles/{roleId}</c> route.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeleteRoleEndpointTests : IClassFixture<LuminaApiFactory>
@@ -35,7 +35,7 @@ public class DeleteRoleEndpointTests : IClassFixture<LuminaApiFactory>
{
// Arrange
Guid roleId = Guid.NewGuid();
string url = $"/api/v1/roles/{roleId}";
string url = $"/api/v1/auth/roles/{roleId}";
// Act
HttpResponseMessage response = await _client.DeleteAsync(url);
@@ -10,7 +10,7 @@ using System.Text.Json;
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Roles;
/// <summary>
/// Contains security tests for the <c>/roles/{roleId}/permissions</c> route.
/// Contains security tests for the <c>/auth/roles/{roleId}/permissions</c> route.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRolePermissionsEndpointTests : IClassFixture<LuminaApiFactory>
@@ -35,7 +35,7 @@ public class GetRolePermissionsEndpointTests : IClassFixture<LuminaApiFactory>
{
// Arrange
Guid roleId = Guid.NewGuid();
string url = $"/api/v1/roles/{roleId}/permissions";
string url = $"/api/v1/auth/roles/{roleId}/permissions";
// Act
HttpResponseMessage response = await _client.GetAsync(url);
@@ -10,7 +10,7 @@ using System.Text.Json;
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Roles;
/// <summary>
/// Contains security tests for the <c>/roles</c> route.
/// Contains security tests for the <c>/auth/roles</c> route.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetRolesEndpointTests : IClassFixture<LuminaApiFactory>
@@ -34,7 +34,7 @@ public class GetRolesEndpointTests : IClassFixture<LuminaApiFactory>
public async Task GetRoles_WhenUnauthorized_ShouldReturnUnauthorizedResult()
{
// Act
HttpResponseMessage response = await _client.GetAsync("/api/v1/roles");
HttpResponseMessage response = await _client.GetAsync("/api/v1/auth/roles");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
@@ -46,7 +46,7 @@ public class GetRolesEndpointTests : IClassFixture<LuminaApiFactory>
problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status401Unauthorized);
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc7235#section-3.1");
problemDetails["title"].GetString().Should().Be("Unauthorized");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/auth/roles");
problemDetails["detail"].GetString().Should().Be("Authentication failed");
}
}
@@ -12,7 +12,7 @@ using System.Text.Json;
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Roles;
/// <summary>
/// Contains security tests for the <c>/roles</c> route.
/// Contains security tests for the <c>/auth/roles</c> route.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateRoleEndpointTests : IClassFixture<LuminaApiFactory>
@@ -49,7 +49,7 @@ public class UpdateRoleEndpointTests : IClassFixture<LuminaApiFactory>
);
// Act
HttpResponseMessage response = await _client.PutAsync("/api/v1/roles", content);
HttpResponseMessage response = await _client.PutAsync("/api/v1/auth/roles", content);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
@@ -61,7 +61,7 @@ public class UpdateRoleEndpointTests : IClassFixture<LuminaApiFactory>
problemDetails!["status"].GetInt32().Should().Be(StatusCodes.Status401Unauthorized);
problemDetails["type"].GetString().Should().Be("https://tools.ietf.org/html/rfc7235#section-3.1");
problemDetails["title"].GetString().Should().Be("Unauthorized");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/roles");
problemDetails["instance"].GetProperty("value").GetString().Should().Be("/api/v1/auth/roles");
problemDetails["detail"].GetString().Should().Be("Authentication failed");
}
}