Remove Ocelot specific Middleware to make Ocelot more compatible with kestrel middleware and get ready for YARP

This commit is contained in:
Tom Pallister
2020-05-23 15:48:51 +01:00
committed by GitHub
parent 99a15d8668
commit fe3e8bd23a
214 changed files with 9574 additions and 9919 deletions

View File

@ -1,38 +1,34 @@
using Microsoft.AspNetCore.Http;
using Ocelot.Cache;
using Ocelot.Middleware;
using Shouldly;
using System.Net.Http;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Cache
namespace Ocelot.UnitTests.Cache
{
using Ocelot.Cache;
using Ocelot.Request.Middleware;
using Shouldly;
using System.Net.Http;
using TestStack.BDDfy;
using Xunit;
public class CacheKeyGeneratorTests
{
private readonly ICacheKeyGenerator _cacheKeyGenerator;
private readonly DownstreamContext _downstreamContext;
private readonly DownstreamRequest _downstreamRequest;
public CacheKeyGeneratorTests()
{
_cacheKeyGenerator = new CacheKeyGenerator();
_cacheKeyGenerator = new CacheKeyGenerator();
_downstreamContext = new DownstreamContext(new DefaultHttpContext())
{
DownstreamRequest = new Ocelot.Request.Middleware.DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"))
};
_downstreamRequest = new DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"));
}
[Fact]
public void should_generate_cache_key_from_context()
{
this.Given(x => x.GivenCacheKeyFromContext(_downstreamContext))
this.Given(x => x.GivenCacheKeyFromContext(_downstreamRequest))
.BDDfy();
}
private void GivenCacheKeyFromContext(DownstreamContext context)
private void GivenCacheKeyFromContext(DownstreamRequest downstreamRequest)
{
string generatedCacheKey = _cacheKeyGenerator.GenerateRequestCacheKey(context);
string generatedCacheKey = _cacheKeyGenerator.GenerateRequestCacheKey(downstreamRequest);
string cachekey = MD5Helper.GenerateMd5("GET-https://some.url/blah?abcd=123");
generatedCacheKey.ShouldBe(cachekey);
}