Fix
This commit is contained in:
parent
68e6fa2353
commit
4714d25724
6 changed files with 86 additions and 20 deletions
|
|
@ -87,6 +87,12 @@ public class EndToEndChatTests : IAsyncLifetime
|
|||
return null;
|
||||
}
|
||||
|
||||
_app.MapGet("/api/csrf-token", (CsrfProtectionService csrf) =>
|
||||
{
|
||||
var token = csrf.GenerateToken();
|
||||
return Results.Ok(new { token });
|
||||
});
|
||||
|
||||
_app.MapGet("/api/info", (ServerOptions opt) => Results.Ok(new ServerInfoResponse
|
||||
{
|
||||
ServerName = opt.ServerName,
|
||||
|
|
@ -103,11 +109,6 @@ public class EndToEndChatTests : IAsyncLifetime
|
|||
_app.MapPost("/api/auth/register", async (RegisterRequest req, IAuthService auth, CsrfProtectionService csrf, HttpContext context) =>
|
||||
{
|
||||
string? csrfToken = context.Request.Headers["X-CSRF-Token"];
|
||||
// Register the token for testing (since client generates it)
|
||||
if (!string.IsNullOrWhiteSpace(csrfToken))
|
||||
{
|
||||
csrf.RegisterTokenForTesting(csrfToken, "");
|
||||
}
|
||||
if (!csrf.ValidateToken(csrfToken ?? "", ""))
|
||||
{
|
||||
return Results.BadRequest(new { error = "Invalid CSRF token" });
|
||||
|
|
@ -120,11 +121,6 @@ public class EndToEndChatTests : IAsyncLifetime
|
|||
_app.MapPost("/api/auth/login", async (LoginRequest req, IAuthService auth, CsrfProtectionService csrf, HttpContext context) =>
|
||||
{
|
||||
string? csrfToken = context.Request.Headers["X-CSRF-Token"];
|
||||
// Register the token for testing (since client generates it)
|
||||
if (!string.IsNullOrWhiteSpace(csrfToken))
|
||||
{
|
||||
csrf.RegisterTokenForTesting(csrfToken, "");
|
||||
}
|
||||
if (!csrf.ValidateToken(csrfToken ?? "", ""))
|
||||
{
|
||||
return Results.BadRequest(new { error = "Invalid CSRF token" });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue