Skip to content

Commit

Permalink
Return 404 for malformed confirmation ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTedder committed Sep 22, 2023
1 parent 5798640 commit 8c760d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
15 changes: 15 additions & 0 deletions LeaderboardBackend.Test/Features/Users/AccountConfirmationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,21 @@ public async Task ConfirmAccount_BadConfirmationId()
user!.Role.Should().Be(UserRole.Registered);
}

[Test]
public async Task ConfirmAccount_MalformedConfirmationId()
{
HttpClient client = _factory.WithWebHostBuilder(builder =>
{
builder.ConfigureTestServices(services =>
{
services.AddSingleton<IClock, FakeClock>(_ => new(Instant.FromUnixTimeSeconds(1)));
});
}).CreateClient();

HttpResponseMessage res = await client.PutAsync("/account/confirm/not_a_guid", null);
res.StatusCode.Should().Be(HttpStatusCode.NotFound);
}

[Test]
public async Task ConfirmAccount_BadRole()
{
Expand Down
1 change: 0 additions & 1 deletion LeaderboardBackend/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ [FromBody] RecoverAccountRequest request
/// <param name="id">The confirmation token.</param>
/// <param name="confirmationService">IAccountConfirmationService dependency.</param>
/// <response code="200">The account was confirmed successfully.</response>
/// <response code="400">The token was malformed.</response>
/// <response code="404">The token provided was invalid or expired.</response>
/// <response code="409">The user's account was either already confirmed or banned.</response>
[AllowAnonymous]
Expand Down
2 changes: 1 addition & 1 deletion LeaderboardBackend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
"description": "The account was confirmed successfully."
},
"400": {
"description": "The token was malformed.",
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
Expand Down

0 comments on commit 8c760d9

Please sign in to comment.