public async Task BlockedIp() { var blockedIp = IPAddress.Parse("192.99.110.138"); //Blocked with SPFBL RBL var trotterMiddlware = new TrotterWatchMiddleware(httpContext => Task.CompletedTask, new TrotterWatchOptions()); HttpContext context = new DefaultHttpContext { Connection = { RemoteIpAddress = blockedIp } }; await trotterMiddlware.Invoke(context); Assert.IsTrue(context.Response.StatusCode == StatusCodes.Status403Forbidden); }
public async Task LegitIp() { var legitIp = IPAddress.Parse("8.8.8.8"); var trotterMiddlware = new TrotterWatchMiddleware(httpContext => Task.CompletedTask, new TrotterWatchOptions()); HttpContext context = new DefaultHttpContext { Connection = { RemoteIpAddress = legitIp } }; await trotterMiddlware.Invoke(context); Assert.IsTrue(context.Response.StatusCode == StatusCodes.Status200OK); }