test: cover empty pairing request body

This commit is contained in:
sladro 2026-03-27 11:58:56 +08:00
parent 061c3baab3
commit 271ff76909

View File

@ -52,6 +52,23 @@ public sealed class PairingEndpointsTests
Assert.Equal("rejected", payload.Status);
}
[Fact]
public async Task Redeem_Returns_BadRequest_When_Request_Body_Is_Empty()
{
await using var fixture = new PairingApiFixture();
using var client = fixture.CreateClient();
using var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");
using var response = await client.PostAsync("/api/pairing/redeem", content);
var payload = await response.Content.ReadFromJsonAsync<RedeemResponse>();
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
Assert.NotNull(payload);
Assert.False(payload.Success);
Assert.Equal("invalid_request", payload.ErrorCode);
Assert.Equal("rejected", payload.Status);
}
[Fact]
public async Task CreateCode_Does_Not_Write_Secret_Code_To_Audit_Log()
{