mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-20 08:02:50 +08:00
Fix async/await warnings
This commit is contained in:
parent
db05935b89
commit
b8e95373a4
@ -18,7 +18,7 @@ namespace Ocelot.Configuration.Repository
|
|||||||
_configFilePath = $"{AppContext.BaseDirectory}/configuration{(string.IsNullOrEmpty(hostingEnvironment.EnvironmentName) ? string.Empty : ".")}{hostingEnvironment.EnvironmentName}.json";
|
_configFilePath = $"{AppContext.BaseDirectory}/configuration{(string.IsNullOrEmpty(hostingEnvironment.EnvironmentName) ? string.Empty : ".")}{hostingEnvironment.EnvironmentName}.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Response<FileConfiguration>> Get()
|
public Task<Response<FileConfiguration>> Get()
|
||||||
{
|
{
|
||||||
string jsonConfiguration;
|
string jsonConfiguration;
|
||||||
|
|
||||||
@ -29,10 +29,10 @@ namespace Ocelot.Configuration.Repository
|
|||||||
|
|
||||||
var fileConfiguration = JsonConvert.DeserializeObject<FileConfiguration>(jsonConfiguration);
|
var fileConfiguration = JsonConvert.DeserializeObject<FileConfiguration>(jsonConfiguration);
|
||||||
|
|
||||||
return new OkResponse<FileConfiguration>(fileConfiguration);
|
return Task.FromResult<Response<FileConfiguration>>(new OkResponse<FileConfiguration>(fileConfiguration));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Response> Set(FileConfiguration fileConfiguration)
|
public Task<Response> Set(FileConfiguration fileConfiguration)
|
||||||
{
|
{
|
||||||
string jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration);
|
string jsonConfiguration = JsonConvert.SerializeObject(fileConfiguration);
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ namespace Ocelot.Configuration.Repository
|
|||||||
|
|
||||||
System.IO.File.WriteAllText(_configFilePath, jsonConfiguration);
|
System.IO.File.WriteAllText(_configFilePath, jsonConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OkResponse();
|
return Task.FromResult<Response>(new OkResponse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,19 +12,19 @@ namespace Ocelot.Configuration.Repository
|
|||||||
|
|
||||||
private IOcelotConfiguration _ocelotConfiguration;
|
private IOcelotConfiguration _ocelotConfiguration;
|
||||||
|
|
||||||
public async Task<Response<IOcelotConfiguration>> Get()
|
public Task<Response<IOcelotConfiguration>> Get()
|
||||||
{
|
{
|
||||||
return new OkResponse<IOcelotConfiguration>(_ocelotConfiguration);
|
return Task.FromResult<Response<IOcelotConfiguration>>(new OkResponse<IOcelotConfiguration>(_ocelotConfiguration));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Response> AddOrReplace(IOcelotConfiguration ocelotConfiguration)
|
public Task<Response> AddOrReplace(IOcelotConfiguration ocelotConfiguration)
|
||||||
{
|
{
|
||||||
lock (LockObject)
|
lock (LockObject)
|
||||||
{
|
{
|
||||||
_ocelotConfiguration = ocelotConfiguration;
|
_ocelotConfiguration = ocelotConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OkResponse();
|
return Task.FromResult<Response>(new OkResponse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ocelot.Values;
|
using Ocelot.Values;
|
||||||
|
|
||||||
@ -14,16 +13,16 @@ namespace Ocelot.ServiceDiscovery
|
|||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Service>> Get()
|
public Task<List<Service>> Get()
|
||||||
{
|
{
|
||||||
return new List<Service>
|
return Task.FromResult(new List<Service>
|
||||||
{
|
{
|
||||||
new Service(_configuration.ServiceName,
|
new Service(_configuration.ServiceName,
|
||||||
new ServiceHostAndPort(_configuration.HostName, _configuration.Port),
|
new ServiceHostAndPort(_configuration.HostName, _configuration.Port),
|
||||||
"doesnt matter with service fabric",
|
"doesnt matter with service fabric",
|
||||||
"doesnt matter with service fabric",
|
"doesnt matter with service fabric",
|
||||||
new List<string>())
|
new List<string>())
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,13 +221,15 @@ namespace Ocelot.AcceptanceTests
|
|||||||
.Configure(app =>
|
.Configure(app =>
|
||||||
{
|
{
|
||||||
app.UsePathBase(basePath);
|
app.UsePathBase(basePath);
|
||||||
app.Run(async context =>
|
app.Run(context =>
|
||||||
{
|
{
|
||||||
context.Response.OnStarting(() => {
|
context.Response.OnStarting(() => {
|
||||||
context.Response.Headers.Add(headerKey, headerValue);
|
context.Response.Headers.Add(headerKey, headerValue);
|
||||||
context.Response.StatusCode = statusCode;
|
context.Response.StatusCode = statusCode;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
@ -6,6 +6,7 @@ namespace Ocelot.UnitTests.Authentication
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Authentication.Middleware;
|
using Ocelot.Authentication.Middleware;
|
||||||
@ -44,10 +45,11 @@ namespace Ocelot.UnitTests.Authentication
|
|||||||
|
|
||||||
private void WhenICallTheMiddleware()
|
private void WhenICallTheMiddleware()
|
||||||
{
|
{
|
||||||
_next = async (context) => {
|
_next = (context) => {
|
||||||
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
|
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
|
||||||
MemoryStream stream = new MemoryStream(byteArray);
|
var stream = new MemoryStream(byteArray);
|
||||||
context.HttpContext.Response.Body = stream;
|
context.HttpContext.Response.Body = stream;
|
||||||
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
_middleware = new AuthenticationMiddleware(_next, _factory.Object);
|
_middleware = new AuthenticationMiddleware(_next, _factory.Object);
|
||||||
_middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
|
_middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
|
||||||
@ -55,10 +57,11 @@ namespace Ocelot.UnitTests.Authentication
|
|||||||
|
|
||||||
private void GivenTheTestServerPipelineIsConfigured()
|
private void GivenTheTestServerPipelineIsConfigured()
|
||||||
{
|
{
|
||||||
_next = async (context) => {
|
_next = (context) => {
|
||||||
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
|
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
|
||||||
MemoryStream stream = new MemoryStream(byteArray);
|
var stream = new MemoryStream(byteArray);
|
||||||
context.HttpContext.Response.Body = stream;
|
context.HttpContext.Response.Body = stream;
|
||||||
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,18 +4,17 @@ namespace Ocelot.UnitTests.Authorization
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Authorisation;
|
using Ocelot.Authorisation;
|
||||||
using Ocelot.Authorisation.Middleware;
|
using Ocelot.Authorisation.Middleware;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.DownstreamRouteFinder;
|
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
|
|
||||||
public class AuthorisationMiddlewareTests
|
public class AuthorisationMiddlewareTests
|
||||||
@ -36,9 +35,7 @@ namespace Ocelot.UnitTests.Authorization
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<AuthorisationMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<AuthorisationMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_middleware = new AuthorisationMiddleware(_next, _authService.Object, _authScopesService.Object, _loggerFactory.Object);
|
_middleware = new AuthorisationMiddleware(_next, _authService.Object, _authScopesService.Object, _loggerFactory.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ namespace Ocelot.UnitTests.Cache
|
|||||||
using Shouldly;
|
using Shouldly;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Cache;
|
using Ocelot.Cache;
|
||||||
using Ocelot.Cache.Middleware;
|
using Ocelot.Cache.Middleware;
|
||||||
@ -43,9 +44,7 @@ namespace Ocelot.UnitTests.Cache
|
|||||||
_cacheManager = new OcelotCacheManagerCache<CachedResponse>(cacheManagerOutputCache);
|
_cacheManager = new OcelotCacheManagerCache<CachedResponse>(cacheManagerOutputCache);
|
||||||
_downstreamContext = new DownstreamContext(new DefaultHttpContext());
|
_downstreamContext = new DownstreamContext(new DefaultHttpContext());
|
||||||
_downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123");
|
_downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123");
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing..
|
|
||||||
};
|
|
||||||
_middleware = new OutputCacheMiddleware(_next, _loggerFactory.Object, _cacheManager, _regionCreator);
|
_middleware = new OutputCacheMiddleware(_next, _loggerFactory.Object, _cacheManager, _regionCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,19 +7,16 @@ namespace Ocelot.UnitTests.Cache
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Cache;
|
using Ocelot.Cache;
|
||||||
using Ocelot.Cache.Middleware;
|
using Ocelot.Cache.Middleware;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.DownstreamRouteFinder;
|
using Ocelot.DownstreamRouteFinder;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Responses;
|
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@ -42,10 +39,7 @@ namespace Ocelot.UnitTests.Cache
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<OutputCacheMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<OutputCacheMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
|
|
||||||
_downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123");
|
_downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Ocelot.UnitTests.Claims
|
namespace Ocelot.UnitTests.Claims
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Claims;
|
using Ocelot.Claims;
|
||||||
@ -32,9 +33,7 @@ namespace Ocelot.UnitTests.Claims
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<ClaimsBuilderMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<ClaimsBuilderMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_middleware = new ClaimsBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
|
_middleware = new ClaimsBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,8 @@ using Ocelot.Middleware.Multiplexer;
|
|||||||
namespace Ocelot.UnitTests.DownstreamRouteFinder
|
namespace Ocelot.UnitTests.DownstreamRouteFinder
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
@ -42,9 +41,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<DownstreamRouteFinderMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<DownstreamRouteFinderMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_multiplexer = new Mock<IMultiplexer>();
|
_multiplexer = new Mock<IMultiplexer>();
|
||||||
_middleware = new DownstreamRouteFinderMiddleware(_next, _loggerFactory.Object, _finder.Object, _provider.Object, _multiplexer.Object);
|
_middleware = new DownstreamRouteFinderMiddleware(_next, _loggerFactory.Object, _finder.Object, _provider.Object, _multiplexer.Object);
|
||||||
}
|
}
|
||||||
|
@ -6,23 +6,19 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.DownstreamRouteFinder;
|
using Ocelot.DownstreamRouteFinder;
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||||
using Ocelot.DownstreamUrlCreator;
|
|
||||||
using Ocelot.DownstreamUrlCreator.Middleware;
|
using Ocelot.DownstreamUrlCreator.Middleware;
|
||||||
using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
|
using Ocelot.DownstreamUrlCreator.UrlTemplateReplacer;
|
||||||
using Ocelot.Infrastructure.RequestData;
|
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Responses;
|
using Ocelot.Responses;
|
||||||
using Ocelot.Values;
|
using Ocelot.Values;
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
public class DownstreamUrlCreatorMiddlewareTests
|
public class DownstreamUrlCreatorMiddlewareTests
|
||||||
@ -43,9 +39,7 @@ namespace Ocelot.UnitTests.DownstreamUrlCreator
|
|||||||
_loggerFactory.Setup(x => x.CreateLogger<DownstreamUrlCreatorMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<DownstreamUrlCreatorMiddleware>()).Returns(_logger.Object);
|
||||||
_downstreamUrlTemplateVariableReplacer = new Mock<IDownstreamPathPlaceholderReplacer>();
|
_downstreamUrlTemplateVariableReplacer = new Mock<IDownstreamPathPlaceholderReplacer>();
|
||||||
_downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://my.url/abc/?q=123");
|
_downstreamContext.DownstreamRequest = new HttpRequestMessage(HttpMethod.Get, "https://my.url/abc/?q=123");
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -11,11 +11,12 @@ using Ocelot.Configuration.Builder;
|
|||||||
using Ocelot.Headers;
|
using Ocelot.Headers;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Ocelot.Authorisation.Middleware;
|
using Ocelot.Authorisation.Middleware;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
|
||||||
namespace Ocelot.UnitTests.Headers
|
namespace Ocelot.UnitTests.Headers
|
||||||
{
|
{
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class HttpHeadersTransformationMiddlewareTests
|
public class HttpHeadersTransformationMiddlewareTests
|
||||||
{
|
{
|
||||||
private Mock<IHttpContextRequestHeaderReplacer> _preReplacer;
|
private Mock<IHttpContextRequestHeaderReplacer> _preReplacer;
|
||||||
@ -34,9 +35,7 @@ namespace Ocelot.UnitTests.Headers
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<AuthorisationMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<AuthorisationMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_middleware = new HttpHeadersTransformationMiddleware(_next, _loggerFactory.Object, _preReplacer.Object, _postReplacer.Object);
|
_middleware = new HttpHeadersTransformationMiddleware(_next, _loggerFactory.Object, _preReplacer.Object, _postReplacer.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,14 +4,12 @@ namespace Ocelot.UnitTests.Headers
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.DownstreamRouteFinder;
|
using Ocelot.DownstreamRouteFinder;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||||
using Ocelot.Headers;
|
using Ocelot.Headers;
|
||||||
using Ocelot.Headers.Middleware;
|
using Ocelot.Headers.Middleware;
|
||||||
@ -37,9 +35,7 @@ namespace Ocelot.UnitTests.Headers
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<HttpRequestHeadersBuilderMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<HttpRequestHeadersBuilderMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_middleware = new HttpRequestHeadersBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
|
_middleware = new HttpRequestHeadersBuilderMiddleware(_next, _loggerFactory.Object, _addHeaders.Object);
|
||||||
_downstreamContext.DownstreamRequest = new HttpRequestMessage();
|
_downstreamContext.DownstreamRequest = new HttpRequestMessage();
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
@ -43,9 +44,7 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<LoadBalancingMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<LoadBalancingMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_downstreamContext.DownstreamRequest = _downstreamRequest;
|
_downstreamContext.DownstreamRequest = _downstreamRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace Ocelot.UnitTests.Middleware
|
|||||||
{
|
{
|
||||||
_aggregator = new Mock<IResponseAggregator>();
|
_aggregator = new Mock<IResponseAggregator>();
|
||||||
_context = new DownstreamContext(new DefaultHttpContext());
|
_context = new DownstreamContext(new DefaultHttpContext());
|
||||||
_pipeline = async context => { _count++; };
|
_pipeline = context => Task.FromResult(_count++);
|
||||||
_multiplexer = new Multiplexer(_aggregator.Object);
|
_multiplexer = new Multiplexer(_aggregator.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ namespace Ocelot.UnitTests.QueryStrings
|
|||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Configuration;
|
using Ocelot.Configuration;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
@ -17,9 +16,8 @@ namespace Ocelot.UnitTests.QueryStrings
|
|||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class QueryStringBuilderMiddlewareTests
|
public class QueryStringBuilderMiddlewareTests
|
||||||
{
|
{
|
||||||
@ -36,9 +34,7 @@ namespace Ocelot.UnitTests.QueryStrings
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<QueryStringBuilderMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<QueryStringBuilderMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_addQueries = new Mock<IAddQueriesToRequest>();
|
_addQueries = new Mock<IAddQueriesToRequest>();
|
||||||
_downstreamContext.DownstreamRequest = new HttpRequestMessage();
|
_downstreamContext.DownstreamRequest = new HttpRequestMessage();
|
||||||
_middleware = new QueryStringBuilderMiddleware(_next, _loggerFactory.Object, _addQueries.Object);
|
_middleware = new QueryStringBuilderMiddleware(_next, _loggerFactory.Object, _addQueries.Object);
|
||||||
|
@ -15,9 +15,9 @@ namespace Ocelot.UnitTests.RateLimit
|
|||||||
using Shouldly;
|
using Shouldly;
|
||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Ocelot.DownstreamRouteFinder.Middleware;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class ClientRateLimitMiddlewareTests
|
public class ClientRateLimitMiddlewareTests
|
||||||
{
|
{
|
||||||
@ -42,8 +42,7 @@ namespace Ocelot.UnitTests.RateLimit
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<ClientRateLimitMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<ClientRateLimitMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async (context) => {
|
_next = context => Task.CompletedTask;
|
||||||
};
|
|
||||||
_middleware = new ClientRateLimitMiddleware(_next, _loggerFactory.Object, _rateLimitCounterHandler);
|
_middleware = new ClientRateLimitMiddleware(_next, _loggerFactory.Object, _rateLimitCounterHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ namespace Ocelot.UnitTests.RequestId
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.Configuration.Builder;
|
using Ocelot.Configuration.Builder;
|
||||||
using Ocelot.DownstreamRouteFinder;
|
using Ocelot.DownstreamRouteFinder;
|
||||||
@ -40,8 +41,10 @@ namespace Ocelot.UnitTests.RequestId
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<ReRouteRequestIdMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<ReRouteRequestIdMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context =>
|
||||||
|
{
|
||||||
context.HttpContext.Response.Headers.Add("LSRequestId", context.HttpContext.TraceIdentifier);
|
context.HttpContext.Response.Headers.Add("LSRequestId", context.HttpContext.TraceIdentifier);
|
||||||
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
_middleware = new ReRouteRequestIdMiddleware(_next, _loggerFactory.Object, _repo.Object);
|
_middleware = new ReRouteRequestIdMiddleware(_next, _loggerFactory.Object, _repo.Object);
|
||||||
_downstreamContext.DownstreamRequest = _downstreamRequest;
|
_downstreamContext.DownstreamRequest = _downstreamRequest;
|
||||||
|
@ -17,12 +17,13 @@ namespace Ocelot.UnitTests.Requester
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int Order {get;private set;}
|
public int Order {get;private set;}
|
||||||
|
|
||||||
public DateTime TimeCalled {get;private set;}
|
public DateTime TimeCalled {get;private set;}
|
||||||
|
|
||||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
TimeCalled = DateTime.Now;
|
TimeCalled = DateTime.Now;
|
||||||
return new HttpResponseMessage();
|
return Task.FromResult(new HttpResponseMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace Ocelot.UnitTests.Requester
|
|||||||
using TestStack.BDDfy;
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class HttpRequesterMiddlewareTests
|
public class HttpRequesterMiddlewareTests
|
||||||
{
|
{
|
||||||
@ -30,9 +31,7 @@ namespace Ocelot.UnitTests.Requester
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<HttpRequesterMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<HttpRequesterMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_middleware = new HttpRequesterMiddleware(_next, _loggerFactory.Object, _requester.Object);
|
_middleware = new HttpRequesterMiddleware(_next, _loggerFactory.Object, _requester.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace Ocelot.UnitTests.Responder
|
|||||||
{
|
{
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ocelot.DownstreamRouteFinder.Finder;
|
using Ocelot.DownstreamRouteFinder.Finder;
|
||||||
using Ocelot.Errors;
|
using Ocelot.Errors;
|
||||||
@ -32,9 +33,7 @@ namespace Ocelot.UnitTests.Responder
|
|||||||
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
_loggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||||
_logger = new Mock<IOcelotLogger>();
|
_logger = new Mock<IOcelotLogger>();
|
||||||
_loggerFactory.Setup(x => x.CreateLogger<ResponderMiddleware>()).Returns(_logger.Object);
|
_loggerFactory.Setup(x => x.CreateLogger<ResponderMiddleware>()).Returns(_logger.Object);
|
||||||
_next = async context => {
|
_next = context => Task.CompletedTask;
|
||||||
//do nothing
|
|
||||||
};
|
|
||||||
_middleware = new ResponderMiddleware(_next, _responder.Object, _loggerFactory.Object, _codeMapper.Object);
|
_middleware = new ResponderMiddleware(_next, _responder.Object, _loggerFactory.Object, _codeMapper.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user