From a37e772a3823fbedcf8fba8a88859d62444b130b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marie=20P=C3=ADchov=C3=A1?= Date: Tue, 23 Feb 2021 19:34:59 +0100 Subject: [PATCH] Addressed styling issues. --- .../Common/TestEnvironment.cs | 2 +- .../HeaderEncodingTests.cs | 28 +++---------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/test/ReverseProxy.FunctionalTests/Common/TestEnvironment.cs b/test/ReverseProxy.FunctionalTests/Common/TestEnvironment.cs index 92660bee28..8b3d36c50e 100644 --- a/test/ReverseProxy.FunctionalTests/Common/TestEnvironment.cs +++ b/test/ReverseProxy.FunctionalTests/Common/TestEnvironment.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; @@ -14,7 +15,6 @@ using Microsoft.Extensions.Hosting; using Microsoft.ReverseProxy.Abstractions; using Microsoft.ReverseProxy.Utilities.Tests; -using System.Text; namespace Microsoft.ReverseProxy.Common { diff --git a/test/ReverseProxy.FunctionalTests/HeaderEncodingTests.cs b/test/ReverseProxy.FunctionalTests/HeaderEncodingTests.cs index 91e405b6ef..dec0fda938 100644 --- a/test/ReverseProxy.FunctionalTests/HeaderEncodingTests.cs +++ b/test/ReverseProxy.FunctionalTests/HeaderEncodingTests.cs @@ -59,9 +59,12 @@ public async Task ProxyAsync_RequestWithEncodedHeaderValue(string headerValue, s return Task.CompletedTask; } }); - proxyApp.UseMiddleware(HeaderNames.Referer, headerValue); proxyApp.Use(async (context, next) => { + Assert.True(context.Request.Headers.TryGetValue(HeaderNames.Referer, out var header)); + var value = Assert.Single(header); + Assert.Equal(headerValue, value); + await next(); proxyError = context.Features.Get(); }); @@ -201,29 +204,6 @@ public async Task ProxyAsync_ResponseWithEncodedHeaderValue(string headerValue, } } - private class CheckHeaderMiddleware - { - private readonly RequestDelegate _next; - private readonly string _headerName; - private readonly string _headerValue; - - public CheckHeaderMiddleware(RequestDelegate next, string headerName, string headerValue) - { - _next = next; - _headerName = headerName; - _headerValue = headerValue; - } - - public async Task Invoke(HttpContext context) - { - Assert.True(context.Request.Headers.TryGetValue(_headerName, out var header)); - var value = Assert.Single(header); - Assert.Equal(_headerValue, value); - - await _next.Invoke(context); - } - } - private class HeaderEncodingClientFactory : IProxyHttpClientFactory { private Encoding _encoding;