Lock display names at registration
This commit is contained in:
@@ -136,17 +136,6 @@ public class StateTests
|
||||
Assert.False(me.GetProperty("votesFinal").GetBoolean());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Name_endpoint_rejects_over_16_chars()
|
||||
{
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var client = factory.CreateClientWithCookies();
|
||||
await client.RegisterAsync("namelimit");
|
||||
|
||||
var resp = await client.PostAsJsonAsync("/api/me/name", new { name = new string('a', 17) });
|
||||
Assert.Equal(HttpStatusCode.BadRequest, resp.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Cannot_advance_to_results_when_locked()
|
||||
{
|
||||
@@ -182,19 +171,19 @@ public class StateTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Name_endpoint_trims_and_rejects_blank()
|
||||
public async Task Display_name_cannot_be_changed_after_registration()
|
||||
{
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var client = factory.CreateClientWithCookies();
|
||||
await client.RegisterAsync("nametest");
|
||||
var username = "fixedname";
|
||||
await client.RegisterAsync(username);
|
||||
var originalDisplay = $"{username}-name";
|
||||
|
||||
var bad = await client.PostAsJsonAsync("/api/me/name", new { name = " " });
|
||||
Assert.Equal(HttpStatusCode.BadRequest, bad.StatusCode);
|
||||
var attempt = await client.PostAsJsonAsync("/api/me/name", new { name = "New Name" });
|
||||
Assert.Equal(HttpStatusCode.NotFound, attempt.StatusCode);
|
||||
|
||||
var ok = await client.PostAsJsonAsync("/api/me/name", new { name = " Alice " });
|
||||
ok.EnsureSuccessStatusCode();
|
||||
var me = await client.GetFromJsonAsync<JsonElement>("/api/me");
|
||||
Assert.Equal("Alice", me.GetProperty("displayName").GetString());
|
||||
Assert.Equal(originalDisplay, me.GetProperty("displayName").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user