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:
Tom Pallister
2018-03-23 18:01:02 +00:00
committed by GitHub
parent 4493b22d0d
commit 463a7bdab4
80 changed files with 1539 additions and 369 deletions

View File

@ -12,24 +12,27 @@ using TestStack.BDDfy;
using Xunit;
using System.Net.Http;
using System;
using Ocelot.Request.Middleware;
namespace Ocelot.UnitTests.QueryStrings
{
public class AddQueriesToRequestTests
{
private readonly AddQueriesToRequest _addQueriesToRequest;
private HttpRequestMessage _downstreamRequest;
private DownstreamRequest _downstreamRequest;
private readonly Mock<IClaimsParser> _parser;
private List<ClaimToThing> _configuration;
private List<Claim> _claims;
private Response _result;
private Response<string> _claimValue;
private HttpRequestMessage _request;
public AddQueriesToRequestTests()
{
_request = new HttpRequestMessage(HttpMethod.Post, "http://my.url/abc?q=123");
_parser = new Mock<IClaimsParser>();
_addQueriesToRequest = new AddQueriesToRequest(_parser.Object);
_downstreamRequest = new HttpRequestMessage(HttpMethod.Post, "http://my.url/abc?q=123");
_downstreamRequest = new DownstreamRequest(_request);
}
[Fact]
@ -78,7 +81,7 @@ namespace Ocelot.UnitTests.QueryStrings
private void TheTheQueryStringIs(string expected)
{
_downstreamRequest.RequestUri.Query.ShouldBe(expected);
_downstreamRequest.Query.ShouldBe(expected);
}
[Fact]
@ -123,7 +126,7 @@ namespace Ocelot.UnitTests.QueryStrings
private void ThenTheQueryIsAdded()
{
var queries = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(_downstreamRequest.RequestUri.OriginalString);
var queries = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(_downstreamRequest.ToHttpRequestMessage().RequestUri.OriginalString);
var query = queries.First(x => x.Key == "query-key");
query.Value.First().ShouldBe(_claimValue.Data);
}
@ -140,15 +143,18 @@ namespace Ocelot.UnitTests.QueryStrings
private void GivenTheDownstreamRequestHasQueryString(string queryString)
{
_downstreamRequest = new HttpRequestMessage(HttpMethod.Post, $"http://my.url/abc{queryString}");
_request = new HttpRequestMessage(HttpMethod.Post, $"http://my.url/abc{queryString}");
_downstreamRequest = new DownstreamRequest(_request);
}
private void GivenTheDownstreamRequestHasQueryString(string key, string value)
{
var newUri = Microsoft.AspNetCore.WebUtilities.QueryHelpers
.AddQueryString(_downstreamRequest.RequestUri.OriginalString, key, value);
.AddQueryString(_downstreamRequest.ToHttpRequestMessage().RequestUri.OriginalString, key, value);
_downstreamRequest.RequestUri = new Uri(newUri);
_request.RequestUri = new Uri(newUri);
//todo - might not need to instanciate
_downstreamRequest = new DownstreamRequest(_request);
}
private void GivenTheClaimParserReturns(Response<string> claimValue)