1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

[SM-153] Add scaffolded API integration test project (#2209)

This commit is contained in:
Oscar Hinton
2022-08-29 16:24:52 +02:00
committed by GitHub
parent 194c695cd0
commit 7c4521e0b4
10 changed files with 3382 additions and 4 deletions

View File

@ -0,0 +1,36 @@
using System.Net;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace Bit.IntegrationTestCommon;
public class FakeRemoteIpAddressMiddleware
{
private readonly RequestDelegate _next;
private readonly IPAddress _fakeIpAddress;
public FakeRemoteIpAddressMiddleware(RequestDelegate next, IPAddress fakeIpAddress = null)
{
_next = next;
_fakeIpAddress = fakeIpAddress ?? IPAddress.Parse("127.0.0.1");
}
public async Task Invoke(HttpContext httpContext)
{
httpContext.Connection.RemoteIpAddress ??= _fakeIpAddress;
await _next(httpContext);
}
}
public class CustomStartupFilter : IStartupFilter
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
{
return app =>
{
app.UseMiddleware<FakeRemoteIpAddressMiddleware>();
next(app);
};
}
}