From 271ff76909ae6f745fde0dc088b78167ec65c291 Mon Sep 17 00:00:00 2001 From: sladro Date: Fri, 27 Mar 2026 11:58:56 +0800 Subject: [PATCH] test: cover empty pairing request body --- .../Api/PairingEndpointsTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/windows_agent/tests/TermRemoteCtl.Agent.IntegrationTests/Api/PairingEndpointsTests.cs b/apps/windows_agent/tests/TermRemoteCtl.Agent.IntegrationTests/Api/PairingEndpointsTests.cs index b8a9b85..a2a4a68 100644 --- a/apps/windows_agent/tests/TermRemoteCtl.Agent.IntegrationTests/Api/PairingEndpointsTests.cs +++ b/apps/windows_agent/tests/TermRemoteCtl.Agent.IntegrationTests/Api/PairingEndpointsTests.cs @@ -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(); + + 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() {