mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 14:48:14 +08:00
Feature/#623 (#632)
* #630 only set status code if response hasnt started, otherwise exception * #623 made {RemoteIpAddress} available as placeholder so you can do x-forwarded-for * #623 local address different on mac, windows and linux for integration test
This commit is contained in:
@ -1,22 +1,22 @@
|
||||
using Xunit;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using System.Net.Http;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Responses;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Moq;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Infrastructure.RequestData;
|
||||
using Ocelot.Middleware.Multiplexer;
|
||||
using Ocelot.Request.Middleware;
|
||||
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Infrastructure.RequestData;
|
||||
using Ocelot.Request.Middleware;
|
||||
using Xunit;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using System.Net.Http;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Responses;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Moq;
|
||||
|
||||
public class HttpResponseHeaderReplacerTests
|
||||
{
|
||||
private DownstreamResponse _response;
|
||||
@ -27,12 +27,14 @@ namespace Ocelot.UnitTests.Headers
|
||||
private DownstreamRequest _request;
|
||||
private Mock<IBaseUrlFinder> _finder;
|
||||
private Mock<IRequestScopedDataRepository> _repo;
|
||||
private Mock<IHttpContextAccessor> _accessor;
|
||||
|
||||
public HttpResponseHeaderReplacerTests()
|
||||
{
|
||||
_accessor = new Mock<IHttpContextAccessor>();
|
||||
_repo = new Mock<IRequestScopedDataRepository>();
|
||||
_finder = new Mock<IBaseUrlFinder>();
|
||||
_placeholders = new Placeholders(_finder.Object, _repo.Object);
|
||||
_placeholders = new Placeholders(_finder.Object, _repo.Object, _accessor.Object);
|
||||
_replacer = new HttpResponseHeaderReplacer(_placeholders);
|
||||
}
|
||||
|
||||
@ -261,7 +263,8 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
private void WhenICallTheReplacer()
|
||||
{
|
||||
_result = _replacer.Replace(_response, _headerFindAndReplaces, _request);
|
||||
var context = new DownstreamContext(new DefaultHttpContext()) {DownstreamResponse = _response, DownstreamRequest = _request};
|
||||
_result = _replacer.Replace(context, _headerFindAndReplaces);
|
||||
}
|
||||
|
||||
private void ThenTheHeaderShouldBe(string key, string value)
|
||||
|
Reference in New Issue
Block a user