mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 09:18:16 +08:00
Fix brace line spacing and remove multiple concurrent whitespace characters
SA1025, SA1505, SA1508, SA-1509, SA1513
This commit is contained in:
@ -177,7 +177,7 @@ namespace Ocelot.AcceptanceTests
|
||||
AuthenticationOptions = new FileAuthenticationOptions
|
||||
{
|
||||
AuthenticationProviderKey = "Test",
|
||||
AllowedScopes = new List<string>{ "api", "api.readOnly", "openid", "offline_access" },
|
||||
AllowedScopes = new List<string>{ "api", "api.readOnly", "openid", "offline_access" },
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -218,7 +218,7 @@ namespace Ocelot.AcceptanceTests
|
||||
AuthenticationOptions = new FileAuthenticationOptions
|
||||
{
|
||||
AuthenticationProviderKey = "Test",
|
||||
AllowedScopes = new List<string>{ "api", "openid", "offline_access" },
|
||||
AllowedScopes = new List<string>{ "api", "openid", "offline_access" },
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -356,7 +356,6 @@ namespace Ocelot.AcceptanceTests
|
||||
"CustomerId", "LocationId", "UserType", "UserId"
|
||||
}
|
||||
},
|
||||
|
||||
})
|
||||
.AddInMemoryClients(new List<Client>
|
||||
{
|
||||
@ -437,7 +436,6 @@ namespace Ocelot.AcceptanceTests
|
||||
"CustomerId", "LocationId", "UserType", "UserId", "Role"
|
||||
}
|
||||
},
|
||||
|
||||
})
|
||||
.AddInMemoryClients(new List<Client>
|
||||
{
|
||||
@ -450,7 +448,6 @@ namespace Ocelot.AcceptanceTests
|
||||
AccessTokenType = tokenType,
|
||||
Enabled = true,
|
||||
RequireClientSecret = false,
|
||||
|
||||
}
|
||||
})
|
||||
.AddTestUsers(users);
|
||||
|
@ -52,7 +52,7 @@ namespace Ocelot.AcceptanceTests
|
||||
UpstreamHttpMethod = new List<string> { "Get" },
|
||||
HttpHandlerOptions = new FileHttpHandlerOptions
|
||||
{
|
||||
UseTracing = true
|
||||
UseTracing = true
|
||||
},
|
||||
QoSOptions = new FileQoSOptions
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace Ocelot.AcceptanceTests
|
||||
UpstreamHttpMethod = new List<string> { "Get" },
|
||||
HttpHandlerOptions = new FileHttpHandlerOptions
|
||||
{
|
||||
UseTracing = true
|
||||
UseTracing = true
|
||||
},
|
||||
QoSOptions = new FileQoSOptions
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
new ApiResource
|
||||
{
|
||||
Name = apiName,
|
||||
Name = apiName,
|
||||
Description = "My API",
|
||||
Enabled = true,
|
||||
DisplayName = "test",
|
||||
|
@ -56,7 +56,7 @@ namespace Ocelot.AcceptanceTests
|
||||
UpstreamHttpMethod = new List<string> { "Get" },
|
||||
RequestIdKey = _steps.RequestIdKey,
|
||||
|
||||
RateLimitOptions = new FileRateLimitRule()
|
||||
RateLimitOptions = new FileRateLimitRule()
|
||||
{
|
||||
EnableRateLimiting = true,
|
||||
ClientWhitelist = new List<string>(),
|
||||
@ -75,7 +75,6 @@ namespace Ocelot.AcceptanceTests
|
||||
QuotaExceededMessage = "",
|
||||
RateLimitCounterPrefix = "",
|
||||
HttpStatusCode = 428
|
||||
|
||||
},
|
||||
RequestIdKey ="oceclientrequest"
|
||||
}
|
||||
@ -117,7 +116,7 @@ namespace Ocelot.AcceptanceTests
|
||||
UpstreamHttpMethod = new List<string> { "Get" },
|
||||
RequestIdKey = _steps.RequestIdKey,
|
||||
|
||||
RateLimitOptions = new FileRateLimitRule()
|
||||
RateLimitOptions = new FileRateLimitRule()
|
||||
{
|
||||
EnableRateLimiting = true,
|
||||
ClientWhitelist = new List<string>() { "ocelotclient1"},
|
||||
@ -172,7 +171,5 @@ namespace Ocelot.AcceptanceTests
|
||||
|
||||
_builder.Start();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +352,6 @@ namespace Ocelot.AcceptanceTests
|
||||
app.UsePathBase(basePath);
|
||||
app.Run(context =>
|
||||
{
|
||||
|
||||
if(string.IsNullOrEmpty(basePath))
|
||||
{
|
||||
context.Response.StatusCode = statusCode;
|
||||
|
@ -70,8 +70,7 @@ namespace Ocelot.AcceptanceTests
|
||||
}
|
||||
|
||||
class FakeHandler : DelegatingHandler
|
||||
{
|
||||
|
||||
{
|
||||
public DateTime TimeCalled { get; private set; }
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
@ -111,6 +110,5 @@ namespace Ocelot.AcceptanceTests
|
||||
|
||||
_builder.Start();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +159,7 @@ namespace Ocelot.AcceptanceTests
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
await context.Response.WriteAsync(exception.StackTrace);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
.Build();
|
||||
|
@ -51,8 +51,7 @@ namespace Ocelot.AcceptanceTests
|
||||
ExceptionsAllowedBeforeBreaking = 1,
|
||||
TimeoutValue = 500,
|
||||
DurationOfBreak = 1000
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -359,8 +359,7 @@ namespace Ocelot.AcceptanceTests
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
await context.Response.WriteAsync(exception.StackTrace);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
.Build();
|
||||
@ -406,4 +405,4 @@ namespace Ocelot.AcceptanceTests
|
||||
_steps.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +144,7 @@ namespace Ocelot.AcceptanceTests
|
||||
|
||||
_ocelotClient = _ocelotServer.CreateClient();
|
||||
}
|
||||
|
||||
/*
|
||||
public void GivenIHaveAddedXForwardedForHeader(string value)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ namespace Ocelot.Benchmarks
|
||||
{
|
||||
var switcher = new BenchmarkSwitcher(new[] {
|
||||
typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
|
||||
|
||||
});
|
||||
|
||||
switcher.Run(args);
|
||||
|
@ -124,7 +124,6 @@ namespace Ocelot.IntegrationTests
|
||||
{
|
||||
Host = "127.0.0.1",
|
||||
}
|
||||
|
||||
},
|
||||
ReRoutes = new List<FileReRoute>()
|
||||
{
|
||||
|
@ -45,6 +45,7 @@ namespace Ocelot.IntegrationTests
|
||||
_builders = new List<IWebHost>();
|
||||
_threads = new List<Thread>();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var builder in _builders)
|
||||
@ -194,7 +195,6 @@ namespace Ocelot.IntegrationTests
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
while(stopwatch.ElapsedMilliseconds < 10000)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,10 +204,9 @@ namespace Ocelot.IntegrationTests
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
while(stopwatch.ElapsedMilliseconds < 2000)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CommandCalledOnAllStateMachines()
|
||||
bool CommandCalledOnAllStateMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -225,6 +224,7 @@ namespace Ocelot.IntegrationTests
|
||||
index.ShouldBe(1);
|
||||
}
|
||||
}
|
||||
|
||||
_httpClientForAssertions.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken);
|
||||
var result = _httpClientForAssertions.GetAsync($"{peer.HostAndPort}/administration/configuration").Result;
|
||||
var json = result.Content.ReadAsStringAsync().Result;
|
||||
@ -248,6 +248,7 @@ namespace Ocelot.IntegrationTests
|
||||
response.ReRoutes[i].UpstreamPathTemplate.ShouldBe(expecteds.Configuration.ReRoutes[i].UpstreamPathTemplate);
|
||||
response.ReRoutes[i].UpstreamHttpMethod.ShouldBe(expecteds.Configuration.ReRoutes[i].UpstreamHttpMethod);
|
||||
}
|
||||
|
||||
passed++;
|
||||
}
|
||||
|
||||
@ -384,7 +385,6 @@ namespace Ocelot.IntegrationTests
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
while(stopwatch.ElapsedMilliseconds < 20000)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,6 +195,7 @@ namespace Ocelot.IntegrationTests
|
||||
result.Result.ShouldBe(result.Random);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_builder?.Dispose();
|
||||
@ -208,7 +209,6 @@ namespace Ocelot.IntegrationTests
|
||||
{
|
||||
Result = result;
|
||||
Random = random;
|
||||
|
||||
}
|
||||
|
||||
public int Result { get; private set; }
|
||||
|
@ -49,7 +49,7 @@ namespace Ocelot.UnitTests.Authentication
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void WhenICallTheMiddleware()
|
||||
private void WhenICallTheMiddleware()
|
||||
{
|
||||
_next = async (context) => {
|
||||
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
|
||||
@ -89,7 +89,7 @@ namespace Ocelot.UnitTests.Authentication
|
||||
{
|
||||
string text = reader.ReadToEnd();
|
||||
return text;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace Ocelot.UnitTests.Authorization
|
||||
this.Given(x => x.GivenAClaimsPrincipal(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
|
||||
{
|
||||
new Claim("UserType", "registered"),
|
||||
|
||||
}))))
|
||||
.And(x => x.GivenARouteClaimsRequirement(new Dictionary<string, string>
|
||||
{
|
||||
|
@ -110,7 +110,6 @@ namespace Ocelot.UnitTests.Cache
|
||||
private void GivenThereAreNoErrors()
|
||||
{
|
||||
_downstreamContext.Errors = new List<Error>();
|
||||
|
||||
}
|
||||
|
||||
private void ThenTheCacheGetIsCalledCorrectly()
|
||||
|
@ -129,7 +129,6 @@ namespace Ocelot.UnitTests.Claims
|
||||
|
||||
private void ThenTheResultIsError()
|
||||
{
|
||||
|
||||
_result.IsError.ShouldBe(true);
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
_result.Count.ShouldBeGreaterThan(0);
|
||||
}
|
||||
|
||||
private void GivenTheFollowingDictionary(Dictionary<string,string> claimsToThings)
|
||||
{
|
||||
_claimsToThings = claimsToThings;
|
||||
@ -107,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
.Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -981,7 +981,8 @@ namespace Ocelot.UnitTests.Configuration
|
||||
.And(x => x.ThenTheErrorMessageAtPositionIs(0, "When not using service discovery DownstreamHostAndPorts must be set and not empty or Ocelot cannot find your service!"))
|
||||
.BDDfy();
|
||||
}
|
||||
[Fact]
|
||||
|
||||
[Fact]
|
||||
public void configuration_is_not_valid_when_host_and_port_is_empty()
|
||||
{
|
||||
this.Given(x => x.GivenAConfiguration(new FileConfiguration
|
||||
|
@ -34,6 +34,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_repo.Setup(x => x.Get()).ReturnsAsync(new OkResponse<FileConfiguration>(_fileConfig));
|
||||
_poller = new ConsulFileConfigurationPoller(_factory.Object, _repo.Object, _setter.Object);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_poller.Dispose();
|
||||
@ -49,7 +50,6 @@ namespace Ocelot.UnitTests.Configuration
|
||||
[Fact]
|
||||
public void should_call_setter_when_gets_new_config()
|
||||
{
|
||||
|
||||
var newConfig = new FileConfiguration {
|
||||
ReRoutes = new List<FileReRoute>
|
||||
{
|
||||
|
@ -823,8 +823,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
result.DownstreamReRoute[0].ClaimsToClaims.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToClaims.Count);
|
||||
result.DownstreamReRoute[0].ClaimsToHeaders.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToHeaders.Count);
|
||||
result.DownstreamReRoute[0].ClaimsToQueries.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToQueries.Count);
|
||||
result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);
|
||||
|
||||
result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
private void GivenTheConfigurationIs(FileConfiguration fileConfiguration)
|
||||
private void GivenTheConfigurationIs(FileConfiguration fileConfiguration)
|
||||
{
|
||||
var configurationPath = $"{AppContext.BaseDirectory}/configuration{(string.IsNullOrEmpty(_environmentName) ? string.Empty : ".")}{_environmentName}.json";
|
||||
|
||||
|
@ -33,13 +33,11 @@ namespace Ocelot.UnitTests.Configuration
|
||||
UpstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
{"Test", "Test, Chicken"},
|
||||
|
||||
{"Moop", "o, a"}
|
||||
},
|
||||
DownstreamHeaderTransform = new Dictionary<string, string>
|
||||
{
|
||||
{"Pop", "West, East"},
|
||||
|
||||
{"Bop", "e, r"}
|
||||
}
|
||||
};
|
||||
@ -155,4 +153,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
|
||||
public class HttpHandlerOptionsCreatorTests
|
||||
{
|
||||
private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;
|
||||
|
@ -70,7 +70,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
[Fact]
|
||||
public void should_create_template_pattern_that_matches_anything_to_end_of_string()
|
||||
{
|
||||
var fileReRoute = new FileReRoute
|
||||
var fileReRoute = new FileReRoute
|
||||
{
|
||||
UpstreamPathTemplate = "/api/products/{productId}",
|
||||
ReRouteIsCaseSensitive = true
|
||||
@ -181,4 +181,4 @@ namespace Ocelot.UnitTests.Configuration
|
||||
_result.Priority.ShouldBe(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ namespace Ocelot.UnitTests.DependencyInjection
|
||||
_services.AddSingleton<IConfiguration>(_configRoot);
|
||||
_maxRetries = 100;
|
||||
}
|
||||
|
||||
private Exception _ex;
|
||||
|
||||
[Fact]
|
||||
@ -102,9 +103,7 @@ namespace Ocelot.UnitTests.DependencyInjection
|
||||
[Fact]
|
||||
public void should_set_up_administration_with_identity_server_options()
|
||||
{
|
||||
Action<IdentityServerAuthenticationOptions> options = o => {
|
||||
|
||||
};
|
||||
Action<IdentityServerAuthenticationOptions> options = o => {};
|
||||
|
||||
this.Given(x => WhenISetUpOcelotServices())
|
||||
.When(x => WhenISetUpAdministration(options))
|
||||
|
@ -135,7 +135,7 @@ namespace Ocelot.UnitTests.Errors
|
||||
|
||||
private void GivenTheConfigThrows()
|
||||
{
|
||||
var ex = new Exception("outer", new Exception("inner"));
|
||||
var ex = new Exception("outer", new Exception("inner"));
|
||||
_provider
|
||||
.Setup(x => x.Get()).ThrowsAsync(ex);
|
||||
}
|
||||
@ -192,7 +192,6 @@ namespace Ocelot.UnitTests.Errors
|
||||
|
||||
private void ThenTheResponseIsError()
|
||||
{
|
||||
|
||||
_downstreamContext.HttpContext.Response.StatusCode.ShouldBe(500);
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,6 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
private void ThenTheResultIsError()
|
||||
{
|
||||
|
||||
_result.IsError.ShouldBe(true);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,6 @@ namespace Ocelot.UnitTests.Headers
|
||||
|
||||
_downstreamContext.TemplatePlaceholderNameAndValues = dR.TemplatePlaceholderNameAndValues;
|
||||
_downstreamContext.DownstreamReRoute = dR.ReRoute.DownstreamReRoute[0];
|
||||
|
||||
}
|
||||
|
||||
private void ThenTheIHttpContextRequestHeaderReplacerIsCalledCorrectly()
|
||||
|
@ -22,6 +22,7 @@ namespace Ocelot.UnitTests.Headers
|
||||
{
|
||||
_replacer = new HttpResponseHeaderReplacer();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_replace_headers()
|
||||
{
|
||||
@ -232,4 +233,4 @@ namespace Ocelot.UnitTests.Headers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ namespace Ocelot.UnitTests.Infrastructure
|
||||
[Fact]
|
||||
public void get_returns_correct_key_from_http_context()
|
||||
{
|
||||
|
||||
this.Given(x => x.GivenAHttpContextContaining("key", "string"))
|
||||
.When(x => x.GetIsCalledWithKey<string>("key"))
|
||||
.Then(x => x.ThenTheResultIsAnOkResponse<string>("string"))
|
||||
@ -83,6 +82,5 @@ namespace Ocelot.UnitTests.Infrastructure
|
||||
_result.ShouldBeOfType<OkResponse<T>>();
|
||||
((OkResponse<T>)_result).Data.ShouldBe(resultValue);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ namespace Ocelot.UnitTests.LoadBalancer
|
||||
hostAndPortTwo.Data.DownstreamHost.ShouldBe("127.0.0.2");
|
||||
_leastConnection.Release(hostAndPortOne.Data);
|
||||
_leastConnection.Release(hostAndPortTwo.Data);
|
||||
|
||||
}
|
||||
|
||||
private async Task LeaseDelayAndRelease()
|
||||
|
@ -188,7 +188,6 @@ namespace Ocelot.UnitTests.LoadBalancer
|
||||
{
|
||||
_downstreamContext.IsError.ShouldBeTrue();
|
||||
_downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors);
|
||||
|
||||
}
|
||||
|
||||
private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri)
|
||||
|
@ -58,7 +58,6 @@ namespace Ocelot.UnitTests.Middleware
|
||||
private void WhenIMultiplex()
|
||||
{
|
||||
_multiplexer.Multiplex(_context, _reRoute, _pipeline).GetAwaiter().GetResult();
|
||||
|
||||
}
|
||||
|
||||
private void ThePipelineIsCalled(int expected)
|
||||
|
@ -36,7 +36,6 @@ namespace Ocelot.UnitTests.Request
|
||||
|
||||
public DownstreamRequestInitialiserMiddlewareTests()
|
||||
{
|
||||
|
||||
_httpContext = new Mock<HttpContext>();
|
||||
_httpRequest = new Mock<HttpRequest>();
|
||||
_requestMapper = new Mock<IRequestMapper>();
|
||||
|
@ -9,13 +9,13 @@ namespace Ocelot.UnitTests.Requester
|
||||
{
|
||||
public FakeDelegatingHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FakeDelegatingHandler(int order)
|
||||
{
|
||||
Order = order;
|
||||
}
|
||||
|
||||
public int Order {get;private set;}
|
||||
public DateTime TimeCalled {get;private set;}
|
||||
|
||||
@ -25,4 +25,4 @@ namespace Ocelot.UnitTests.Requester
|
||||
return new HttpResponseMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,8 +131,7 @@ namespace Ocelot.UnitTests.ServiceDiscovery
|
||||
else
|
||||
{
|
||||
_registeredServices[serviceNameAndAddress.Name] = new List<Service>(){ serviceNameAndAddress };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user