Tests voor client api and service
This commit is contained in:
parent
cd2ec646fd
commit
3d73a9914c
12 changed files with 267 additions and 30 deletions
|
|
@ -2,18 +2,6 @@ using IdentityShroud.Core.Model;
|
|||
|
||||
namespace IdentityShroud.Core.Contracts;
|
||||
|
||||
//public record CreateClientRequest(Guid RealmId, string ClientId, string? Description);
|
||||
|
||||
public class ClientCreateRequest
|
||||
{
|
||||
public required string ClientId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? SignatureAlgorithm { get; set; }
|
||||
public bool? AllowClientCredentialsFlow { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public interface IClientService
|
||||
{
|
||||
Task<Result<Client>> Create(
|
||||
|
|
@ -21,6 +9,6 @@ public interface IClientService
|
|||
ClientCreateRequest request,
|
||||
CancellationToken ct = default);
|
||||
|
||||
Task<Client?> GetByClientId(string clientId, CancellationToken ct = default);
|
||||
Task<Client?> FindById(int id, CancellationToken ct = default);
|
||||
Task<Client?> GetByClientId(Guid realmId, string clientId, CancellationToken ct = default);
|
||||
Task<Client?> FindById(Guid realmId, int id, CancellationToken ct = default);
|
||||
}
|
||||
10
IdentityShroud.Core/DTO/Client/ClientCreateRequest.cs
Normal file
10
IdentityShroud.Core/DTO/Client/ClientCreateRequest.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
namespace IdentityShroud.Core.Contracts;
|
||||
|
||||
public class ClientCreateRequest
|
||||
{
|
||||
public required string ClientId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? SignatureAlgorithm { get; set; }
|
||||
public bool? AllowClientCredentialsFlow { get; set; }
|
||||
}
|
||||
|
|
@ -34,14 +34,20 @@ public class ClientService(
|
|||
return client;
|
||||
}
|
||||
|
||||
public async Task<Client?> GetByClientId(string clientId, CancellationToken ct = default)
|
||||
public async Task<Client?> GetByClientId(
|
||||
Guid realmId,
|
||||
string clientId,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
return await db.Clients.FirstOrDefaultAsync(c => c.ClientId == clientId, ct);
|
||||
return await db.Clients.FirstOrDefaultAsync(c => c.ClientId == clientId && c.RealmId == realmId, ct);
|
||||
}
|
||||
|
||||
public async Task<Client?> FindById(int id, CancellationToken ct = default)
|
||||
public async Task<Client?> FindById(
|
||||
Guid realmId,
|
||||
int id,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
return await db.Clients.FirstOrDefaultAsync(c => c.Id == id, ct);
|
||||
return await db.Clients.FirstOrDefaultAsync(c => c.Id == id && c.RealmId == realmId, ct);
|
||||
}
|
||||
|
||||
private ClientSecret CreateSecret()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue