mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 17:28:16 +08:00
Feature/websockets (#273)
* #212 - hacked websockets proxy together * faffing around * #212 hacking away :( * #212 websockets proxy middleware working * #212 map when for webockets working * #212 some test refactor * #212 temp commit * #212 websockets proxy working, tests passing...need to do some tidying and write docs * #212 more code coverage * #212 docs for websockets * #212 updated readme * #212 tidying up after websockets refactoring * #212 tidying up after websockets refactoring * #212 tidying up after websockets refactoring * stuck a warning in about logging levels into docs!
This commit is contained in:
@ -11,6 +11,7 @@ using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using System.Net.Http;
|
||||
using Ocelot.Request.Middleware;
|
||||
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
@ -18,7 +19,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
private readonly AddHeadersToRequest _addHeadersToRequest;
|
||||
private readonly Mock<IClaimsParser> _parser;
|
||||
private readonly HttpRequestMessage _downstreamRequest;
|
||||
private readonly DownstreamRequest _downstreamRequest;
|
||||
private List<Claim> _claims;
|
||||
private List<ClaimToThing> _configuration;
|
||||
private Response _result;
|
||||
@ -28,7 +29,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
_parser = new Mock<IClaimsParser>();
|
||||
_addHeadersToRequest = new AddHeadersToRequest(_parser.Object);
|
||||
_downstreamRequest = new HttpRequestMessage();
|
||||
_downstreamRequest = new DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "http://test.com"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -16,6 +16,7 @@ using Ocelot.Middleware;
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
using System.Threading.Tasks;
|
||||
using Ocelot.Request.Middleware;
|
||||
|
||||
public class HttpHeadersTransformationMiddlewareTests
|
||||
{
|
||||
@ -68,7 +69,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
private void GivenTheDownstreamRequestIs()
|
||||
{
|
||||
_downstreamContext.DownstreamRequest = new HttpRequestMessage();
|
||||
_downstreamContext.DownstreamRequest = new DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "http://test.com"));
|
||||
}
|
||||
|
||||
private void GivenTheHttpResponseMessageIs()
|
||||
@ -97,7 +98,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
private void ThenTheIHttpResponseHeaderReplacerIsCalledCorrectly()
|
||||
{
|
||||
_postReplacer.Verify(x => x.Replace(It.IsAny<HttpResponseMessage>(), It.IsAny<List<HeaderFindAndReplace>>(), It.IsAny<HttpRequestMessage>()), Times.Once);
|
||||
_postReplacer.Verify(x => x.Replace(It.IsAny<HttpResponseMessage>(), It.IsAny<List<HeaderFindAndReplace>>(), It.IsAny<DownstreamRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
private void GivenTheFollowingRequest()
|
||||
|
@ -14,6 +14,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Headers.Middleware;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Request.Middleware;
|
||||
using Ocelot.Responses;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
@ -37,7 +38,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
_loggerFactory.Setup(x => x.CreateLogger<HttpRequestHeadersBuilderMiddleware>()).Returns(_logger.Object);
|
||||
_next = context => Task.CompletedTask;
|
||||
_middleware = new HttpRequestHeadersBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
|
||||
_downstreamContext.DownstreamRequest = new HttpRequestMessage();
|
||||
_downstreamContext.DownstreamRequest = new DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "http://test.com"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -81,7 +82,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
.Setup(x => x.SetHeadersOnDownstreamRequest(
|
||||
It.IsAny<List<ClaimToThing>>(),
|
||||
It.IsAny<IEnumerable<System.Security.Claims.Claim>>(),
|
||||
It.IsAny<HttpRequestMessage>()))
|
||||
It.IsAny<DownstreamRequest>()))
|
||||
.Returns(new OkResponse());
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ using Moq;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Infrastructure.RequestData;
|
||||
using Ocelot.Request.Middleware;
|
||||
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
@ -21,7 +22,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
private HttpResponseHeaderReplacer _replacer;
|
||||
private List<HeaderFindAndReplace> _headerFindAndReplaces;
|
||||
private Response _result;
|
||||
private HttpRequestMessage _request;
|
||||
private DownstreamRequest _request;
|
||||
private Mock<IBaseUrlFinder> _finder;
|
||||
private Mock<IRequestScopedDataRepository> _repo;
|
||||
|
||||
@ -69,7 +70,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
var downstreamUrl = "http://downstream.com/";
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");
|
||||
request.RequestUri = new System.Uri(downstreamUrl);
|
||||
|
||||
var response = new HttpResponseMessage();
|
||||
@ -91,7 +92,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
var downstreamUrl = "http://downstream.com/";
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");
|
||||
request.RequestUri = new System.Uri(downstreamUrl);
|
||||
|
||||
var response = new HttpResponseMessage();
|
||||
@ -113,7 +114,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
var downstreamUrl = "http://downstream.com/test/product";
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");
|
||||
request.RequestUri = new System.Uri(downstreamUrl);
|
||||
|
||||
var response = new HttpResponseMessage();
|
||||
@ -135,7 +136,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
var downstreamUrl = "http://downstream.com/test/product";
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");
|
||||
request.RequestUri = new System.Uri(downstreamUrl);
|
||||
|
||||
var response = new HttpResponseMessage();
|
||||
@ -157,7 +158,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
var downstreamUrl = "http://downstream.com:123/test/product";
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");
|
||||
request.RequestUri = new System.Uri(downstreamUrl);
|
||||
|
||||
var response = new HttpResponseMessage();
|
||||
@ -179,7 +180,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
var downstreamUrl = "http://downstream.com:123/test/product";
|
||||
|
||||
var request = new HttpRequestMessage();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com");
|
||||
request.RequestUri = new System.Uri(downstreamUrl);
|
||||
|
||||
var response = new HttpResponseMessage();
|
||||
@ -198,7 +199,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
private void GivenTheRequestIs(HttpRequestMessage request)
|
||||
{
|
||||
_request = request;
|
||||
_request = new DownstreamRequest(request);
|
||||
}
|
||||
|
||||
private void ThenTheHeadersAreNotReplaced()
|
||||
|
Reference in New Issue
Block a user