backend: Enforce UTF-8 password byte limits
This commit is contained in:
1 parent
0215af0749
commit
9fe713fc10
6 files changed
+44
-25
No files matched your search
@@ -6,6 +6,7 @@ using Helpdesk.Application.Users;
|
||||
using Helpdesk.Domain.Auth;
|
||||
using Helpdesk.Domain.Users;
|
||||
using Helpdesk.Infrastructure.Persistence;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using static Helpdesk.IntegrationTests.BackendFixture;
|
||||
@@ -62,15 +63,17 @@ public sealed class EmailConfirmationTests(BackendFixture fixture) : IClassFixtu
|
||||
var otherToken = await fixture.TakeConfirmationTokenAsync(address);
|
||||
await ExpectAsync(anonymous.PostAsJsonAsync(Confirm, new { token = original.Token }, Cancellation),
|
||||
HttpStatusCode.BadRequest);
|
||||
await ExpectAsync(anonymous.PostAsJsonAsync(Confirm, new ConfirmEmailRequest(original.Token, new string('č', 37)), Cancellation),
|
||||
HttpStatusCode.BadRequest);
|
||||
await ExpectAsync(anonymous.PostAsJsonAsync(Confirm, new ConfirmEmailRequest(original.Token, Password), Cancellation),
|
||||
var newPassword = new string('č', 36);
|
||||
var validation = await ReadAsync<ValidationProblemDetails>(anonymous.PostAsJsonAsync(Confirm,
|
||||
new ConfirmEmailRequest(original.Token, newPassword + "a"), Cancellation), HttpStatusCode.BadRequest);
|
||||
Assert.Contains("72 bajtů", Assert.Single(validation.Errors["newPassword"]));
|
||||
await ExpectAsync(anonymous.PostAsJsonAsync(Confirm, new ConfirmEmailRequest(original.Token, newPassword), Cancellation),
|
||||
HttpStatusCode.NoContent);
|
||||
await ExpectAsync(anonymous.PostAsJsonAsync(Confirm, new ConfirmEmailRequest(otherToken, oldPassword), Cancellation),
|
||||
HttpStatusCode.BadRequest);
|
||||
await ExpectAsync(anonymous.PostAsJsonAsync(Login, new LoginRequest(address, oldPassword), Cancellation),
|
||||
HttpStatusCode.Unauthorized);
|
||||
var session = await LoginAsync(anonymous, address);
|
||||
var session = await ReadAsync<AuthResponse>(anonymous.PostAsJsonAsync(Login, new LoginRequest(address, newPassword), Cancellation));
|
||||
Assert.Equal((pending.Id, pending.FirstName, pending.LastName), (session.User.Id, session.User.FirstName, session.User.LastName));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user