Added skoruba user service integration test
This commit is contained in:
@@ -164,7 +164,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
if (defaultRole == null)
|
||||
return Result.Fail(NotFoundError.Create("Role 'Contributor' not found."));
|
||||
|
||||
var roleAssignmentResult = await skorubaService.AddRoleAsync(newUserId, defaultRole.Id, cancellationToken);
|
||||
var roleAssignmentResult = await skorubaService.AddRoleAsync(newUserId, Guid.Parse(defaultRole.Id), cancellationToken);
|
||||
|
||||
if (roleAssignmentResult.IsFailed)
|
||||
return Result.Fail(UpdateError.Create("Failed to assign role to user."));
|
||||
@@ -255,7 +255,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
await Result.Try((Func<Task<Result<Role[]>>>)(async () =>
|
||||
await skorubaService.GetAvailableRolesAsync(cancellationToken: cancellationToken)));
|
||||
|
||||
public async Task<Result> DeleteUserRoleAsync(Guid targetUserId, string roleId, Guid userId, CancellationToken cancellationToken = default) =>
|
||||
public async Task<Result> DeleteUserRoleAsync(Guid targetUserId, Guid roleId, Guid userId, CancellationToken cancellationToken = default) =>
|
||||
await Result.Try((Func<Task<Result>>)(async () =>
|
||||
{
|
||||
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
@@ -278,7 +278,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
.CausedBy(addClaimResult.Errors));
|
||||
}));
|
||||
|
||||
public async Task<Result> AddUserRoleAsync(Guid targetUserId, string roleId, Guid userId, CancellationToken cancellationToken = default) =>
|
||||
public async Task<Result> AddUserRoleAsync(Guid targetUserId, Guid roleId, Guid userId, CancellationToken cancellationToken = default) =>
|
||||
await Result.Try((Func<Task<Result>>)(async () =>
|
||||
{
|
||||
var userRolesResult = await skorubaService.GetUserRolesAsync(targetUserId, cancellationToken: cancellationToken);
|
||||
@@ -289,7 +289,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
|
||||
foreach (var role in userRolesResult.Value)
|
||||
{
|
||||
var deleteRoleResult = await skorubaService.RemoveRoleAsync(targetUserId, role.Id, cancellationToken);
|
||||
var deleteRoleResult = await skorubaService.RemoveRoleAsync(targetUserId, Guid.Parse(role.Id), cancellationToken);
|
||||
|
||||
if (deleteRoleResult.IsFailed)
|
||||
return Result.Fail(UpdateError.Create("Failed to remove existing user role.")
|
||||
@@ -308,7 +308,7 @@ public sealed class UserService(IDbContextFactory<ApplicationDbContext> contextF
|
||||
return Result.Fail(NotFoundError.Create("Failed to retrieve system roles.")
|
||||
.CausedBy(systemRoles.Errors));
|
||||
|
||||
var targetRole = systemRoles.Value.FirstOrDefault(r => r.Id == roleId);
|
||||
var targetRole = systemRoles.Value.FirstOrDefault(r => r.Id == roleId.ToString());
|
||||
|
||||
if (targetRole == null)
|
||||
return Result.Fail(NotFoundError.Create("Role not found."));
|
||||
|
||||
Reference in New Issue
Block a user