Rename all ReRoute to Route to move closer to YARP +semver: breaking

This commit is contained in:
Tom Pallister
2020-05-23 20:50:05 +01:00
committed by GitHub
parent fe3e8bd23a
commit 3439be8927
269 changed files with 23591 additions and 23605 deletions

View File

@ -21,40 +21,40 @@
using TestStack.BDDfy;
using Xunit;
public class ReRouteRequestIdMiddlewareTests
public class RequestIdMiddlewareTests
{
private readonly HttpRequestMessage _downstreamRequest;
private string _value;
private string _key;
private Mock<IOcelotLoggerFactory> _loggerFactory;
private Mock<IOcelotLogger> _logger;
private readonly ReRouteRequestIdMiddleware _middleware;
private readonly RequestIdMiddleware _middleware;
private RequestDelegate _next;
private readonly Mock<IRequestScopedDataRepository> _repo;
private HttpContext _httpContext;
public ReRouteRequestIdMiddlewareTests()
public RequestIdMiddlewareTests()
{
_httpContext = new DefaultHttpContext();
_downstreamRequest = new HttpRequestMessage(HttpMethod.Get, "http://test.com");
_repo = new Mock<IRequestScopedDataRepository>();
_loggerFactory = new Mock<IOcelotLoggerFactory>();
_logger = new Mock<IOcelotLogger>();
_loggerFactory.Setup(x => x.CreateLogger<ReRouteRequestIdMiddleware>()).Returns(_logger.Object);
_loggerFactory.Setup(x => x.CreateLogger<RequestIdMiddleware>()).Returns(_logger.Object);
_next = context =>
{
_httpContext.Response.Headers.Add("LSRequestId", _httpContext.TraceIdentifier);
return Task.CompletedTask;
};
_middleware = new ReRouteRequestIdMiddleware(_next, _loggerFactory.Object, _repo.Object);
_middleware = new RequestIdMiddleware(_next, _loggerFactory.Object, _repo.Object);
_httpContext.Items.UpsertDownstreamRequest(new DownstreamRequest(_downstreamRequest));
}
[Fact]
public void should_pass_down_request_id_from_upstream_request()
{
var downstreamRoute = new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
var downstreamRoute = new DownstreamRouteHolder(new List<PlaceholderNameAndValue>(),
new RouteBuilder()
.WithDownstreamRoute(new DownstreamRouteBuilder()
.WithDownstreamPathTemplate("any old string")
.WithRequestIdKey("LSRequestId")
.WithUpstreamHttpMethod(new List<string> { "Get" })
@ -75,9 +75,9 @@
[Fact]
public void should_add_request_id_when_not_on_upstream_request()
{
var downstreamRoute = new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
var downstreamRoute = new DownstreamRouteHolder(new List<PlaceholderNameAndValue>(),
new RouteBuilder()
.WithDownstreamRoute(new DownstreamRouteBuilder()
.WithDownstreamPathTemplate("any old string")
.WithRequestIdKey("LSRequestId")
.WithUpstreamHttpMethod(new List<string> { "Get" })
@ -95,9 +95,9 @@
[Fact]
public void should_add_request_id_scoped_repo_for_logging_later()
{
var downstreamRoute = new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
var downstreamRoute = new DownstreamRouteHolder(new List<PlaceholderNameAndValue>(),
new RouteBuilder()
.WithDownstreamRoute(new DownstreamRouteBuilder()
.WithDownstreamPathTemplate("any old string")
.WithRequestIdKey("LSRequestId")
.WithUpstreamHttpMethod(new List<string> { "Get" })
@ -119,9 +119,9 @@
[Fact]
public void should_update_request_id_scoped_repo_for_logging_later()
{
var downstreamRoute = new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
var downstreamRoute = new DownstreamRouteHolder(new List<PlaceholderNameAndValue>(),
new RouteBuilder()
.WithDownstreamRoute(new DownstreamRouteBuilder()
.WithDownstreamPathTemplate("any old string")
.WithRequestIdKey("LSRequestId")
.WithUpstreamHttpMethod(new List<string> { "Get" })
@ -143,9 +143,9 @@
[Fact]
public void should_not_update_if_global_request_id_is_same_as_re_route_request_id()
{
var downstreamRoute = new DownstreamRoute(new List<PlaceholderNameAndValue>(),
new ReRouteBuilder()
.WithDownstreamReRoute(new DownstreamReRouteBuilder()
var downstreamRoute = new DownstreamRouteHolder(new List<PlaceholderNameAndValue>(),
new RouteBuilder()
.WithDownstreamRoute(new DownstreamRouteBuilder()
.WithDownstreamPathTemplate("any old string")
.WithRequestIdKey("LSRequestId")
.WithUpstreamHttpMethod(new List<string> { "Get" })
@ -194,11 +194,11 @@
_repo.Verify(x => x.Update("RequestId", _value), Times.Never);
}
private void GivenTheDownStreamRouteIs(DownstreamRoute downstreamRoute)
private void GivenTheDownStreamRouteIs(DownstreamRouteHolder downstreamRoute)
{
_httpContext.Items.UpsertTemplatePlaceholderNameAndValues(downstreamRoute.TemplatePlaceholderNameAndValues);
_httpContext.Items.UpsertDownstreamReRoute(downstreamRoute.ReRoute.DownstreamReRoute[0]);
_httpContext.Items.UpsertDownstreamRoute(downstreamRoute.Route.DownstreamRoute[0]);
}
private void GivenTheRequestIdIsAddedToTheRequest(string key, string value)