-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle multivalue X-Forwarded-Proto header
Closes #5198
- Loading branch information
1 parent
52a204e
commit 28ba9d9
Showing
6 changed files
with
57 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/WebJobs.Script.Tests/Middleware/AppServiceHeaderFixupMiddlewareTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Azure.WebJobs.Script.WebHost.Middleware; | ||
using Microsoft.Extensions.Primitives; | ||
using Xunit; | ||
|
||
namespace Microsoft.Azure.WebJobs.Script.Tests.Middleware | ||
{ | ||
public class AppServiceHeaderFixupMiddlewareTests | ||
{ | ||
[Theory] | ||
[InlineData(new[] { "http" }, "http")] | ||
[InlineData(new[] { "https" }, "https")] | ||
[InlineData(new[] { "https", "http" }, "https")] | ||
[InlineData(new[] { "http", "https" }, "http")] | ||
public async Task AppServiceFixupMiddleware_Handles_Multivalue_Header(string[] headerValues, string expectedScheme) | ||
{ | ||
var ctx = new DefaultHttpContext(); | ||
ctx.Request.Headers.Add(AppServiceHeaderFixupMiddleware.ForwardedProtocolHeader, new StringValues(headerValues)); | ||
|
||
var middleware = new AppServiceHeaderFixupMiddleware(nextCtx => | ||
{ | ||
nextCtx.Request.Scheme.Should().Be(expectedScheme); | ||
return Task.CompletedTask; | ||
}); | ||
|
||
await middleware.Invoke(ctx); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters