mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 03:58:15 +08:00
moved logic to request mapper and public setter gone
This commit is contained in:
@ -13,6 +13,8 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -27,6 +29,8 @@
|
||||
|
||||
private List<KeyValuePair<string, StringValues>> _inputHeaders = null;
|
||||
|
||||
private DownstreamReRoute _downstreamReRoute;
|
||||
|
||||
public RequestMapperTests()
|
||||
{
|
||||
_httpContext = new DefaultHttpContext();
|
||||
@ -82,6 +86,21 @@
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("", "GET")]
|
||||
[InlineData(null, "GET")]
|
||||
[InlineData("POST", "POST")]
|
||||
public void Should_use_downstream_reroute_method_if_set(string input, string expected)
|
||||
{
|
||||
this.Given(_ => GivenTheInputRequestHasMethod("GET"))
|
||||
.And(_ => GivenTheDownstreamReRouteMethodIs(input))
|
||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||
.When(_ => WhenMapped())
|
||||
.Then(_ => ThenNoErrorIsReturned())
|
||||
.And(_ => ThenTheMappedRequestHasMethod(expected))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_map_all_headers()
|
||||
{
|
||||
@ -154,16 +173,6 @@
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenTheInputRequestHasNoContentLength()
|
||||
{
|
||||
_inputRequest.ContentLength = null;
|
||||
}
|
||||
|
||||
private void GivenTheInputRequestHasNoContentType()
|
||||
{
|
||||
_inputRequest.ContentType = null;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Should_map_content_headers()
|
||||
{
|
||||
@ -212,6 +221,22 @@
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenTheDownstreamReRouteMethodIs(string input)
|
||||
{
|
||||
_downstreamReRoute = new DownstreamReRouteBuilder().WithDownStreamHttpMethod(input).Build();
|
||||
}
|
||||
|
||||
private void GivenTheInputRequestHasNoContentLength()
|
||||
{
|
||||
_inputRequest.ContentLength = null;
|
||||
}
|
||||
|
||||
private void GivenTheInputRequestHasNoContentType()
|
||||
{
|
||||
_inputRequest.ContentType = null;
|
||||
}
|
||||
|
||||
|
||||
private void ThenTheContentHeadersAreNotAddedToNonContentHeaders()
|
||||
{
|
||||
_mappedRequest.Data.Headers.ShouldNotContain(x => x.Key == "Content-Disposition");
|
||||
@ -380,7 +405,7 @@
|
||||
|
||||
private async Task WhenMapped()
|
||||
{
|
||||
_mappedRequest = await _requestMapper.Map(_inputRequest);
|
||||
_mappedRequest = await _requestMapper.Map(_inputRequest, _downstreamReRoute);
|
||||
}
|
||||
|
||||
private void ThenNoErrorIsReturned()
|
||||
|
Reference in New Issue
Block a user