Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate HTTP doc link behind proxy (#14)
* add test for doc link behind proxy * handle x-forwarded-proto when generating doc link
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 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
33 changes: 33 additions & 0 deletions
33
src/Argolis.Tests/ApiDocumentation/RequestResponseExtensionsTests.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,33 @@ | ||
using System.Collections.Generic; | ||
using Argolis.Hydra.Nancy; | ||
using FluentAssertions; | ||
using Nancy; | ||
using Xunit; | ||
|
||
namespace Argolis.Tests.ApiDocumentation | ||
{ | ||
public class RequestResponseExtensionsTests | ||
{ | ||
[Theory] | ||
[InlineData("https")] | ||
[InlineData("HTTPS")] | ||
public void GetApiDocumentationUri_should_honor_X_Forwarded_Proto(string proto) | ||
{ | ||
// given | ||
var headers = new Dictionary<string, IEnumerable<string>> | ||
{ | ||
{ "X-Forwarded-Proto", new[] { proto } } | ||
}; | ||
var request = new Request( | ||
"GET", | ||
new Url("http://hydra.app/some/resource"), | ||
headers: headers); | ||
|
||
// when | ||
var apiDocUri = request.GetApiDocumentationUri("/api/doc"); | ||
|
||
// then | ||
apiDocUri.Should().Be("https://hydra.app/api/doc"); | ||
} | ||
} | ||
} |