public async void ReturnsFalseWhenMaxHeaderLengthIsConfiguredAndHeadersExceedLength() { var context = new ApiRequestContext { RequestAborted = new System.Threading.CancellationToken(false), Request = new ApiRequestInfo { Headers = new List <ApiHeader> { new ApiHeader("X-Header1", "MyValue1111"), new ApiHeader("X-Header2", "MyValue2222"), new ApiHeader("X-Header2", "MyValue233") } }, Configuration = new DeepSleepRequestConfiguration { RequestValidation = new ApiRequestValidationConfiguration { MaxHeaderLength = 10 } } }; var processed = await context.ProcessHttpRequestHeaderValidation().ConfigureAwait(false); processed.Should().BeFalse(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); context.Response.StatusCode.Should().Be(431); context.Validation.Should().NotBeNull(); context.Validation.Errors.Should().NotBeNull(); context.Validation.Errors.Should().HaveCount(0); }
public async void ReturnsTrueWhenMaxHeaderLengthIsUnconfigured(int?maxHeaderLength) { var context = new ApiRequestContext { RequestAborted = new System.Threading.CancellationToken(false), Request = new ApiRequestInfo { Headers = new List <ApiHeader> { new ApiHeader("X-Header1", "MyValue1"), new ApiHeader("X-Header2", "MyValue2") } }, Configuration = new DeepSleepRequestConfiguration { RequestValidation = new ApiRequestValidationConfiguration { MaxHeaderLength = maxHeaderLength } } }; var processed = await context.ProcessHttpRequestHeaderValidation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); }
public async void ReturnsFalseForCancelledRequest() { var context = new ApiRequestContext { RequestAborted = new System.Threading.CancellationToken(true) }; var processed = await context.ProcessHttpRequestHeaderValidation().ConfigureAwait(false); processed.Should().BeFalse(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); }
public async void ReturnsTrueWhenEmptyHeaders() { var context = new ApiRequestContext { RequestAborted = new System.Threading.CancellationToken(false), Request = new ApiRequestInfo { Headers = new List <ApiHeader>() } }; var processed = await context.ProcessHttpRequestHeaderValidation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.ResponseObject.Should().BeNull(); }