tests: add jwt token builder for testing protected endpoints
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using FiscalOS.Infra.Authentication;
|
||||
|
||||
namespace FiscalOS.API.Tests.Infra;
|
||||
|
||||
public class TestApi : WebApplicationFactory<Program>
|
||||
@@ -14,22 +10,12 @@ public class TestApi : WebApplicationFactory<Program>
|
||||
|
||||
builder.ConfigureTestServices(static c =>
|
||||
{
|
||||
var dbOpts = Options.Create(new AppDbContextOptions()
|
||||
c.AddSingleton(Options.Create(new AppDbContextOptions()
|
||||
{
|
||||
DatabaseFilePath = $"{Guid.NewGuid()}.db",
|
||||
});
|
||||
}));
|
||||
|
||||
c.AddSingleton(dbOpts);
|
||||
|
||||
var jwtOpts = Options.Create(new JwtOptions()
|
||||
{
|
||||
Issuer = "TestIssuer",
|
||||
Audience = "TestAudience",
|
||||
Secret = Convert.ToBase64String(RandomNumberGenerator.GetBytes(32)),
|
||||
ExpiryInMinutes = 5,
|
||||
});
|
||||
|
||||
c.AddSingleton(jwtOpts);
|
||||
c.AddSingleton(Options.Create(JwtTokenBuilder.DefaultJwtOptions));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user