Add payload serializer guardrails
This commit is contained in:
27
RpgRoller.Tests/Api/ResponseCompressionApiTests.cs
Normal file
27
RpgRoller.Tests/Api/ResponseCompressionApiTests.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace RpgRoller.Tests;
|
||||
|
||||
public sealed class ResponseCompressionApiTests : ApiTestBase
|
||||
{
|
||||
public ResponseCompressionApiTests(WebApplicationFactory<Program> factory) : base(factory)
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AuthenticatedJsonResponses_EnableGzipCompression()
|
||||
{
|
||||
using var factory = CreateFactory();
|
||||
using var client = factory.CreateClient(new() { AllowAutoRedirect = false });
|
||||
|
||||
await RegisterAsync(client, "gm-compress", "Password123", "GM");
|
||||
await LoginAsync(client, "gm-compress", "Password123");
|
||||
_ = await PostAsync<CreateCampaignRequest, CampaignSummary>(client, "/api/campaigns", new("Compressed", "d6"));
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "/api/campaigns");
|
||||
request.Headers.Add("Accept-Encoding", "gzip");
|
||||
|
||||
var response = await client.SendAsync(request);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
Assert.Contains("gzip", response.Content.Headers.ContentEncoding);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user