mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 20:28:15 +08:00
Removed unused usings, removed empty spaces, removed tons os warnings (#903)
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Moq;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Errors;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Infrastructure.Claims.Parser;
|
||||
using Ocelot.Request.Middleware;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Claims;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
using System.Net.Http;
|
||||
using Ocelot.Request.Middleware;
|
||||
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
@ -97,7 +97,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
.Then(x => x.ThenTheResultIsError())
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
|
||||
private void GivenClaims(List<Claim> claims)
|
||||
{
|
||||
_claims = claims;
|
||||
@ -119,8 +119,8 @@ namespace Ocelot.UnitTests.Headers
|
||||
_parser
|
||||
.Setup(
|
||||
x =>
|
||||
x.GetValue(It.IsAny<IEnumerable<Claim>>(),
|
||||
It.IsAny<string>(),
|
||||
x.GetValue(It.IsAny<IEnumerable<Claim>>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<int>()))
|
||||
.Returns(_claimValue);
|
||||
@ -147,9 +147,9 @@ namespace Ocelot.UnitTests.Headers
|
||||
header.Value.First().ShouldBe(_claimValue.Data);
|
||||
}
|
||||
|
||||
class AnyError : Error
|
||||
private class AnyError : Error
|
||||
{
|
||||
public AnyError()
|
||||
public AnyError()
|
||||
: base("blahh", OcelotErrorCode.UnknownError)
|
||||
{
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Logging;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Moq;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Infrastructure.Claims.Parser;
|
||||
using Ocelot.Logging;
|
||||
using Responder;
|
||||
using Responses;
|
||||
using Shouldly;
|
||||
@ -76,7 +76,6 @@
|
||||
_logger.Verify(x => x.LogWarning($"Unable to add header to response {key}: {value}"), Times.Once);
|
||||
}
|
||||
|
||||
|
||||
private void GivenHttpRequestWithoutHeaders()
|
||||
{
|
||||
_context = new DefaultHttpContext
|
||||
@ -109,7 +108,7 @@
|
||||
_addedHeader = new AddHeader(headerKey, headerValue);
|
||||
_addHeadersToRequest.SetHeadersOnDownstreamRequest(new[] { _addedHeader }, _context);
|
||||
}
|
||||
|
||||
|
||||
private void ThenTheHeaderGetsTakenOverToTheRequestHeaders()
|
||||
{
|
||||
var requestHeaders = _context.Request.Headers;
|
||||
|
@ -1,18 +1,17 @@
|
||||
using Xunit;
|
||||
using TestStack.BDDfy;
|
||||
using Ocelot.Headers;
|
||||
using System.Net.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Moq;
|
||||
using Ocelot.Responses;
|
||||
using Ocelot.Configuration.Creator;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.UnitTests.Responder;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Middleware.Multiplexer;
|
||||
using Ocelot.Responses;
|
||||
using Ocelot.UnitTests.Responder;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
@ -56,9 +55,9 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
new AddHeader("Trace-Id", "{TraceId}")
|
||||
};
|
||||
|
||||
var traceId = "123";
|
||||
|
||||
|
||||
var traceId = "123";
|
||||
|
||||
this.Given(_ => GivenAResponseMessage())
|
||||
.And(_ => GivenTheTraceIdIs(traceId))
|
||||
.And(_ => GivenTheAddHeaders(addHeaders))
|
||||
@ -94,7 +93,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
new AddHeader("Trace-Id", "{TraceId}")
|
||||
};
|
||||
|
||||
|
||||
this.Given(_ => GivenAResponseMessage())
|
||||
.And(_ => GivenTheTraceIdErrors())
|
||||
.And(_ => GivenTheAddHeaders(addHeaders))
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
@ -16,6 +13,9 @@ namespace Ocelot.UnitTests.Headers
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Request.Middleware;
|
||||
using Ocelot.Responses;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -91,7 +91,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
_addHeaders
|
||||
.Verify(x => x.SetHeadersOnDownstreamRequest(
|
||||
It.IsAny<List<ClaimToThing>>(),
|
||||
It.IsAny<IEnumerable<System.Security.Claims.Claim>>(),
|
||||
It.IsAny<IEnumerable<System.Security.Claims.Claim>>(),
|
||||
_downstreamContext.DownstreamRequest), Times.Once);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
using Xunit;
|
||||
using Shouldly;
|
||||
using Ocelot.Headers.Middleware;
|
||||
using TestStack.BDDfy;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Responses;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
@ -54,8 +53,8 @@ namespace Ocelot.UnitTests.Headers
|
||||
}
|
||||
|
||||
private void ThenTheHeadersAreNotReplaced()
|
||||
{
|
||||
_result.ShouldBeOfType<OkResponse>();
|
||||
{
|
||||
_result.ShouldBeOfType<OkResponse>();
|
||||
foreach (var f in _fAndRs)
|
||||
{
|
||||
_context.Request.Headers.TryGetValue(f.Key, out var values);
|
||||
@ -88,4 +87,4 @@ namespace Ocelot.UnitTests.Headers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,21 @@
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
using Xunit;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Headers.Middleware;
|
||||
using TestStack.BDDfy;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.DownstreamRouteFinder;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.Headers;
|
||||
using System.Net.Http;
|
||||
using Ocelot.Authorisation.Middleware;
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.DownstreamRouteFinder;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Headers.Middleware;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Middleware.Multiplexer;
|
||||
using System.Threading.Tasks;
|
||||
using Ocelot.Request.Middleware;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
public class HttpHeadersTransformationMiddlewareTests
|
||||
{
|
||||
@ -117,4 +116,4 @@ namespace Ocelot.UnitTests.Headers
|
||||
_downstreamContext.HttpContext.Request.Headers.Add("test", "test");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Infrastructure.RequestData;
|
||||
using Ocelot.Request.Middleware;
|
||||
using Xunit;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using System.Net.Http;
|
||||
using Ocelot.Headers;
|
||||
using Moq;
|
||||
using Ocelot.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Headers;
|
||||
using Ocelot.Infrastructure;
|
||||
using Ocelot.Infrastructure.RequestData;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Request.Middleware;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Moq;
|
||||
using System.Net.Http;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
public class HttpResponseHeaderReplacerTests
|
||||
{
|
||||
@ -47,7 +47,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
new KeyValuePair<string, IEnumerable<string>>("test", new List<string> {"test"})
|
||||
}, "");
|
||||
|
||||
var fAndRs = new List<HeaderFindAndReplace> {new HeaderFindAndReplace("test", "test", "chiken", 0)};
|
||||
var fAndRs = new List<HeaderFindAndReplace> { new HeaderFindAndReplace("test", "test", "chiken", 0) };
|
||||
|
||||
this.Given(x => GivenTheHttpResponse(response))
|
||||
.And(x => GivenTheFollowingHeaderReplacements(fAndRs))
|
||||
@ -80,7 +80,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
const string downstreamUrl = "http://downstream.com/";
|
||||
|
||||
var request =
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
|
||||
|
||||
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>()
|
||||
@ -107,7 +107,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
const string downstreamUrl = "http://downstream.com/";
|
||||
|
||||
var request =
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
|
||||
|
||||
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>()
|
||||
@ -134,7 +134,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
const string downstreamUrl = "http://downstream.com/test/product";
|
||||
|
||||
var request =
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
|
||||
|
||||
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>()
|
||||
@ -161,7 +161,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
const string downstreamUrl = "http://downstream.com/test/product";
|
||||
|
||||
var request =
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
|
||||
|
||||
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>()
|
||||
@ -188,7 +188,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
const string downstreamUrl = "http://downstream.com:123/test/product";
|
||||
|
||||
var request =
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
|
||||
|
||||
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>()
|
||||
@ -215,7 +215,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
const string downstreamUrl = "http://downstream.com:123/test/product";
|
||||
|
||||
var request =
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") {RequestUri = new System.Uri(downstreamUrl)};
|
||||
new HttpRequestMessage(HttpMethod.Get, "http://test.com") { RequestUri = new System.Uri(downstreamUrl) };
|
||||
|
||||
var response = new DownstreamResponse(new StringContent(string.Empty), HttpStatusCode.Accepted,
|
||||
new List<KeyValuePair<string, IEnumerable<string>>>()
|
||||
@ -243,7 +243,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
private void ThenTheHeadersAreNotReplaced()
|
||||
{
|
||||
_result.ShouldBeOfType<OkResponse>();
|
||||
_result.ShouldBeOfType<OkResponse>();
|
||||
foreach (var f in _headerFindAndReplaces)
|
||||
{
|
||||
var values = _response.Headers.First(x => x.Key == f.Key);
|
||||
@ -263,7 +263,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
private void WhenICallTheReplacer()
|
||||
{
|
||||
var context = new DownstreamContext(new DefaultHttpContext()) {DownstreamResponse = _response, DownstreamRequest = _request};
|
||||
var context = new DownstreamContext(new DefaultHttpContext()) { DownstreamResponse = _response, DownstreamRequest = _request };
|
||||
_result = _replacer.Replace(context, _headerFindAndReplaces);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Responses;
|
||||
using Shouldly;
|
||||
using System.Collections.Generic;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -49,4 +49,4 @@ namespace Ocelot.UnitTests.Headers
|
||||
_headers.ShouldNotContain(x => x.Key == "transfer-encoding");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user