From df86052a31235d4dd740020dc8ddf574b3b1b81a Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sun, 25 Feb 2018 14:36:33 +0000 Subject: [PATCH 01/11] Add stylecop analyzers with default ruleset --- codeanalysis.ruleset | 120 ++++++++++++++++++ src/Ocelot/Ocelot.csproj | 4 + .../Ocelot.AcceptanceTests.csproj | 4 + .../Ocelot.Benchmarks.csproj | 4 + .../Ocelot.IntegrationTests.csproj | 44 ++++--- .../Ocelot.ManualTest.csproj | 4 + test/Ocelot.UnitTests/Ocelot.UnitTests.csproj | 4 + 7 files changed, 164 insertions(+), 20 deletions(-) create mode 100644 codeanalysis.ruleset diff --git a/codeanalysis.ruleset b/codeanalysis.ruleset new file mode 100644 index 00000000..f666b7e7 --- /dev/null +++ b/codeanalysis.ruleset @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Ocelot/Ocelot.csproj b/src/Ocelot/Ocelot.csproj index eb4ce773..8dc09d0e 100644 --- a/src/Ocelot/Ocelot.csproj +++ b/src/Ocelot/Ocelot.csproj @@ -17,6 +17,7 @@ True false Tom Pallister + ..\..\codeanalysis.ruleset full @@ -35,6 +36,9 @@ + + all + diff --git a/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj index ab7ae7ce..363e0dce 100644 --- a/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj +++ b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj @@ -12,6 +12,7 @@ false false false + ..\..\codeanalysis.ruleset @@ -34,6 +35,9 @@ + + all + diff --git a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj index ac2b0191..bc22e06c 100644 --- a/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj +++ b/test/Ocelot.Benchmarks/Ocelot.Benchmarks.csproj @@ -11,6 +11,7 @@ false false false + ..\..\codeanalysis.ruleset @@ -19,6 +20,9 @@ + + all + diff --git a/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj b/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj index 6e1fdb4b..8dc250b2 100644 --- a/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj +++ b/test/Ocelot.IntegrationTests/Ocelot.IntegrationTests.csproj @@ -11,6 +11,7 @@ false false false + ..\..\codeanalysis.ruleset @@ -18,29 +19,32 @@ - + - + - - - - - - - - - - - - - - - - - - + + + + all + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj b/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj index 7ec84c3d..ed0e2cb8 100644 --- a/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj +++ b/test/Ocelot.ManualTest/Ocelot.ManualTest.csproj @@ -9,6 +9,7 @@ Exe Ocelot.ManualTest osx.10.11-x64;osx.10.12-x64;win7-x64;win10-x64 + ..\..\codeanalysis.ruleset @@ -38,6 +39,9 @@ + + all + diff --git a/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj b/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj index 7993644f..9165347e 100644 --- a/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj +++ b/test/Ocelot.UnitTests/Ocelot.UnitTests.csproj @@ -12,6 +12,7 @@ false false false + ..\..\codeanalysis.ruleset @@ -37,6 +38,9 @@ + + all + From 9f458a878b54a53bddf4b1e6cdb41c6987f217ad Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sun, 25 Feb 2018 15:47:13 +0000 Subject: [PATCH 02/11] Disable all but the least contentious rules --- codeanalysis.ruleset | 229 ++++++++++++++++++++++++------------------- 1 file changed, 129 insertions(+), 100 deletions(-) diff --git a/codeanalysis.ruleset b/codeanalysis.ruleset index f666b7e7..e867f4e5 100644 --- a/codeanalysis.ruleset +++ b/codeanalysis.ruleset @@ -1,120 +1,149 @@  - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - - + + + + \ No newline at end of file From c61dc9fd110a5777f6ca3ccef1eb04b248ff039b Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 13:14:24 +0000 Subject: [PATCH 03/11] Fix brace line spacing and remove multiple concurrent whitespace characters SA1025, SA1505, SA1508, SA-1509, SA1513 --- src/Ocelot/Authorisation/ClaimsAuthoriser.cs | 3 ++- src/Ocelot/Cache/RegionCreator.cs | 3 +-- src/Ocelot/Cache/Regions.cs | 3 ++- .../Claims/Middleware/ClaimsBuilderMiddleware.cs | 1 + src/Ocelot/Configuration/DownstreamHostAndPort.cs | 1 + .../Configuration/File/FileRateLimitOptions.cs | 2 -- src/Ocelot/Configuration/File/FileRateLimitRule.cs | 2 +- src/Ocelot/Configuration/QoSOptions.cs | 1 - src/Ocelot/Configuration/ReRouteOptions.cs | 4 ++-- .../Repository/ConsulFileConfigurationPoller.cs | 1 - .../Repository/ConsulFileConfigurationRepository.cs | 3 +-- .../Configuration/Setter/FileConfigurationSetter.cs | 4 ++-- .../Validator/FileValidationFailedError.cs | 1 - .../Validator/ReRouteFluentValidator.cs | 1 + src/Ocelot/DependencyInjection/OcelotBuilder.cs | 3 +-- src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs | 3 ++- .../DownstreamRouteFinder/UrlMatcher/UrlMatch.cs | 3 ++- .../UrlMatcher/UrlPathPlaceholderNameAndValue.cs | 3 ++- .../UrlPathPlaceholderNameAndValueFinder.cs | 4 +++- .../Errors/Middleware/ExceptionHandlerMiddleware.cs | 1 + src/Ocelot/Headers/HttpResponseHeaderReplacer.cs | 3 ++- src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs | 1 + src/Ocelot/Logging/IOcelotLoggerFactory.cs | 1 + src/Ocelot/Middleware/OcelotPipelineConfiguration.cs | 3 +-- src/Ocelot/Raft/FakeCommand.cs | 2 +- src/Ocelot/Raft/FilePeersProvider.cs | 1 + src/Ocelot/Raft/HttpPeer.cs | 4 +++- src/Ocelot/Raft/SqlLiteLog.cs | 12 ++++++++---- src/Ocelot/RateLimit/ClientRateLimitProcessor.cs | 3 --- .../DistributedCacheRateLimitCounterHanlder.cs | 1 + .../Middleware/ClientRateLimitMiddleware.cs | 7 +++---- src/Ocelot/RateLimit/RateLimitCore.cs | 5 ++--- src/Ocelot/Requester/HttpClientHttpRequester.cs | 1 - src/Ocelot/Requester/MemoryHttpClientCache.cs | 1 + src/Ocelot/Requester/OcelotHttpTracingHandler.cs | 2 +- src/Ocelot/Responder/HttpContextResponder.cs | 1 - .../Responder/Middleware/ResponderMiddleware.cs | 1 - src/Ocelot/Responses/ErrorResponse.cs | 3 ++- src/Ocelot/Responses/ErrorResponseGeneric.cs | 6 +++--- src/Ocelot/Responses/ResponseGeneric.cs | 5 ++--- .../ServiceDiscoveryProviderFactory.cs | 2 +- src/Ocelot/Values/Service.cs | 1 + test/Ocelot.AcceptanceTests/AuthorisationTests.cs | 7 ++----- test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs | 4 ++-- .../ClaimsToQueryStringForwardingTests.cs | 2 +- test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs | 7 ++----- test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs | 1 - .../HttpDelegatingHandlersTests.cs | 4 +--- test/Ocelot.AcceptanceTests/LoadBalancerTests.cs | 3 +-- test/Ocelot.AcceptanceTests/QoSTests.cs | 3 +-- test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs | 5 ++--- test/Ocelot.AcceptanceTests/Steps.cs | 1 + test/Ocelot.Benchmarks/Program.cs | 1 - test/Ocelot.IntegrationTests/AdministrationTests.cs | 1 - test/Ocelot.IntegrationTests/RaftTests.cs | 8 ++++---- .../ThreadSafeHeadersTests.cs | 2 +- .../Authentication/AuthenticationMiddlewareTests.cs | 4 ++-- .../Authorization/ClaimsAuthoriserTests.cs | 1 - .../Cache/OutputCacheMiddlewareTests.cs | 1 - .../Claims/AddClaimsToRequestTests.cs | 1 - .../Configuration/ClaimsToThingCreatorTests.cs | 3 ++- .../ConfigurationFluentValidationTests.cs | 3 ++- .../ConsulFileConfigurationPollerTests.cs | 2 +- .../Configuration/FileConfigurationCreatorTests.cs | 3 +-- .../FileConfigurationRepositoryTests.cs | 2 +- .../HeaderFindAndReplaceCreatorTests.cs | 4 +--- .../Configuration/HttpHandlerOptionsCreatorTests.cs | 1 - .../UpstreamTemplatePatternCreatorTests.cs | 4 ++-- .../DependencyInjection/OcelotBuilderTests.cs | 5 ++--- .../Errors/ExceptionHandlerMiddlewareTests.cs | 3 +-- .../Headers/AddHeadersToRequestTests.cs | 1 - .../HttpHeadersTransformationMiddlewareTests.cs | 1 - .../Headers/HttpResponseHeaderReplacerTests.cs | 3 ++- .../Infrastructure/HttpDataRepositoryTests.cs | 2 -- .../LoadBalancer/LeastConnectionTests.cs | 1 - .../LoadBalancer/LoadBalancerMiddlewareTests.cs | 1 - test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs | 1 - .../DownstreamRequestInitialiserMiddlewareTests.cs | 1 - .../Requester/FakeDelegatingHandler.cs | 4 ++-- .../ServiceDiscovery/ServiceRegistryTests.cs | 3 +-- 80 files changed, 98 insertions(+), 119 deletions(-) diff --git a/src/Ocelot/Authorisation/ClaimsAuthoriser.cs b/src/Ocelot/Authorisation/ClaimsAuthoriser.cs index 4db1045c..3ca7809e 100644 --- a/src/Ocelot/Authorisation/ClaimsAuthoriser.cs +++ b/src/Ocelot/Authorisation/ClaimsAuthoriser.cs @@ -47,7 +47,8 @@ namespace Ocelot.Authorisation }); } } + return new OkResponse(true); } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Cache/RegionCreator.cs b/src/Ocelot/Cache/RegionCreator.cs index e2ca874b..f5a94c21 100644 --- a/src/Ocelot/Cache/RegionCreator.cs +++ b/src/Ocelot/Cache/RegionCreator.cs @@ -4,7 +4,6 @@ using Ocelot.Configuration.File; namespace Ocelot.Cache { - public class RegionCreator : IRegionCreator { public string Create(FileReRoute reRoute) @@ -21,4 +20,4 @@ namespace Ocelot.Cache return region; } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Cache/Regions.cs b/src/Ocelot/Cache/Regions.cs index f94cc306..baec6087 100644 --- a/src/Ocelot/Cache/Regions.cs +++ b/src/Ocelot/Cache/Regions.cs @@ -8,6 +8,7 @@ namespace Ocelot.Cache { Value = value; } + public List Value {get;private set;} } -} \ No newline at end of file +} diff --git a/src/Ocelot/Claims/Middleware/ClaimsBuilderMiddleware.cs b/src/Ocelot/Claims/Middleware/ClaimsBuilderMiddleware.cs index 5161b247..48f57834 100644 --- a/src/Ocelot/Claims/Middleware/ClaimsBuilderMiddleware.cs +++ b/src/Ocelot/Claims/Middleware/ClaimsBuilderMiddleware.cs @@ -39,6 +39,7 @@ namespace Ocelot.Claims.Middleware return; } } + await _next.Invoke(context); } } diff --git a/src/Ocelot/Configuration/DownstreamHostAndPort.cs b/src/Ocelot/Configuration/DownstreamHostAndPort.cs index 483e7523..186cce2f 100644 --- a/src/Ocelot/Configuration/DownstreamHostAndPort.cs +++ b/src/Ocelot/Configuration/DownstreamHostAndPort.cs @@ -7,6 +7,7 @@ Host = host; Port = port; } + public string Host { get; private set; } public int Port { get; private set; } } diff --git a/src/Ocelot/Configuration/File/FileRateLimitOptions.cs b/src/Ocelot/Configuration/File/FileRateLimitOptions.cs index b9277a3c..c7f99cb0 100644 --- a/src/Ocelot/Configuration/File/FileRateLimitOptions.cs +++ b/src/Ocelot/Configuration/File/FileRateLimitOptions.cs @@ -34,6 +34,4 @@ namespace Ocelot.Configuration.File /// public int HttpStatusCode { get; set; } = 429; } - - } diff --git a/src/Ocelot/Configuration/File/FileRateLimitRule.cs b/src/Ocelot/Configuration/File/FileRateLimitRule.cs index 55346d2e..2dda3084 100644 --- a/src/Ocelot/Configuration/File/FileRateLimitRule.cs +++ b/src/Ocelot/Configuration/File/FileRateLimitRule.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; namespace Ocelot.Configuration.File { - public class FileRateLimitRule { public FileRateLimitRule() @@ -38,6 +37,7 @@ namespace Ocelot.Configuration.File { return string.Empty; } + var sb = new StringBuilder(); sb.Append( $"{nameof(Period)}:{Period},{nameof(PeriodTimespan)}:{PeriodTimespan:F},{nameof(Limit)}:{Limit},{nameof(ClientWhitelist)}:["); diff --git a/src/Ocelot/Configuration/QoSOptions.cs b/src/Ocelot/Configuration/QoSOptions.cs index c518cfec..60e7cc03 100644 --- a/src/Ocelot/Configuration/QoSOptions.cs +++ b/src/Ocelot/Configuration/QoSOptions.cs @@ -24,6 +24,5 @@ namespace Ocelot.Configuration public int TimeoutValue { get; private set; } public TimeoutStrategy TimeoutStrategy { get; private set; } - } } diff --git a/src/Ocelot/Configuration/ReRouteOptions.cs b/src/Ocelot/Configuration/ReRouteOptions.cs index 5ec316c3..e3a7a7b1 100644 --- a/src/Ocelot/Configuration/ReRouteOptions.cs +++ b/src/Ocelot/Configuration/ReRouteOptions.cs @@ -9,12 +9,12 @@ namespace Ocelot.Configuration IsCached = isCached; IsQos = isQos; EnableRateLimiting = isEnableRateLimiting; - } + public bool IsAuthenticated { get; private set; } public bool IsAuthorised { get; private set; } public bool IsCached { get; private set; } public bool IsQos { get; private set; } public bool EnableRateLimiting { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Configuration/Repository/ConsulFileConfigurationPoller.cs b/src/Ocelot/Configuration/Repository/ConsulFileConfigurationPoller.cs index 7e78b3aa..a2780062 100644 --- a/src/Ocelot/Configuration/Repository/ConsulFileConfigurationPoller.cs +++ b/src/Ocelot/Configuration/Repository/ConsulFileConfigurationPoller.cs @@ -34,7 +34,6 @@ namespace Ocelot.Configuration.Repository _polling = true; await Poll(); _polling = false; - }, null, 0, 1000); } diff --git a/src/Ocelot/Configuration/Repository/ConsulFileConfigurationRepository.cs b/src/Ocelot/Configuration/Repository/ConsulFileConfigurationRepository.cs index 91b4bd9d..746df5da 100644 --- a/src/Ocelot/Configuration/Repository/ConsulFileConfigurationRepository.cs +++ b/src/Ocelot/Configuration/Repository/ConsulFileConfigurationRepository.cs @@ -9,7 +9,6 @@ using Ocelot.ServiceDiscovery; namespace Ocelot.Configuration.Repository { - public class ConsulFileConfigurationRepository : IFileConfigurationRepository { private readonly ConsulClient _consul; @@ -76,4 +75,4 @@ namespace Ocelot.Configuration.Repository return new ErrorResponse(new UnableToSetConfigInConsulError($"Unable to set FileConfiguration in consul, response status code from consul was {result.StatusCode}")); } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Configuration/Setter/FileConfigurationSetter.cs b/src/Ocelot/Configuration/Setter/FileConfigurationSetter.cs index 71f56277..38a7c1cb 100644 --- a/src/Ocelot/Configuration/Setter/FileConfigurationSetter.cs +++ b/src/Ocelot/Configuration/Setter/FileConfigurationSetter.cs @@ -12,7 +12,7 @@ namespace Ocelot.Configuration.Setter private readonly IOcelotConfigurationCreator _configCreator; private readonly IFileConfigurationRepository _repo; - public FileConfigurationSetter(IOcelotConfigurationRepository configRepo, + public FileConfigurationSetter(IOcelotConfigurationRepository configRepo, IOcelotConfigurationCreator configCreator, IFileConfigurationRepository repo) { _configRepo = configRepo; @@ -39,4 +39,4 @@ namespace Ocelot.Configuration.Setter return new ErrorResponse(config.Errors); } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs b/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs index b661e065..e90aa218 100644 --- a/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs +++ b/src/Ocelot/Configuration/Validator/FileValidationFailedError.cs @@ -9,7 +9,6 @@ namespace Ocelot.Configuration.Validator { public FileValidationFailedError(string message) : base(message, OcelotErrorCode.FileValidationFailedError) { - } } } diff --git a/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs b/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs index f2ebbace..c2f4dc62 100644 --- a/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs +++ b/src/Ocelot/Configuration/Validator/ReRouteFluentValidator.cs @@ -67,6 +67,7 @@ namespace Ocelot.Configuration.Validator { return true; } + var schemes = await _authenticationSchemeProvider.GetAllSchemesAsync(); var supportedSchemes = schemes.Select(scheme => scheme.Name).ToList(); diff --git a/src/Ocelot/DependencyInjection/OcelotBuilder.cs b/src/Ocelot/DependencyInjection/OcelotBuilder.cs index f4192713..6501b619 100644 --- a/src/Ocelot/DependencyInjection/OcelotBuilder.cs +++ b/src/Ocelot/DependencyInjection/OcelotBuilder.cs @@ -126,7 +126,7 @@ namespace Ocelot.DependencyInjection // see this for why we register this as singleton http://stackoverflow.com/questions/37371264/invalidoperationexception-unable-to-resolve-service-for-type-microsoft-aspnetc // could maybe use a scoped data repository - _services.TryAddSingleton(); + _services.TryAddSingleton(); _services.TryAddSingleton(); _services.AddMemoryCache(); _services.TryAddSingleton(); @@ -154,7 +154,6 @@ namespace Ocelot.DependencyInjection // We add this here so that we can always inject something into the factory for IoC.. _services.AddSingleton(); - } public IOcelotAdministrationBuilder AddAdministration(string path, string secret) diff --git a/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs b/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs index ed04daef..c7696ecf 100644 --- a/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs +++ b/src/Ocelot/DownstreamRouteFinder/DownstreamRoute.cs @@ -11,7 +11,8 @@ namespace Ocelot.DownstreamRouteFinder TemplatePlaceholderNameAndValues = templatePlaceholderNameAndValues; ReRoute = reRoute; } + public List TemplatePlaceholderNameAndValues { get; private set; } public ReRoute ReRoute { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs index bfbd6fdc..9236ae39 100644 --- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs +++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlMatch.cs @@ -6,6 +6,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher { Match = match; } + public bool Match {get;private set;} } -} \ No newline at end of file +} diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValue.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValue.cs index e299c770..f91faa1d 100644 --- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValue.cs +++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValue.cs @@ -7,7 +7,8 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher Name = name; Value = value; } + public string Name {get;private set;} public string Value {get;private set;} } -} \ No newline at end of file +} diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs index 70cf2272..4471618f 100644 --- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs +++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinder.cs @@ -50,6 +50,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher counterForTemplate = endOfPlaceholder; } + counterForPath++; } @@ -90,6 +91,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher return variableName; } + private int GetNextCounterPosition(string urlTemplate, int counterForTemplate, char delimiter) { var closingPlaceHolderPositionOnTemplate = urlTemplate.IndexOf(delimiter, counterForTemplate); @@ -111,4 +113,4 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher return character == '{'; } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs index 9b49c84a..2b9e22e2 100644 --- a/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs +++ b/src/Ocelot/Errors/Middleware/ExceptionHandlerMiddleware.cs @@ -100,6 +100,7 @@ namespace Ocelot.Errors.Middleware message = $"{message}, inner exception message {e.InnerException.Message}, inner exception stack {e.InnerException.StackTrace}"; } + return $"{message} RequestId: {context.HttpContext.TraceIdentifier}"; } } diff --git a/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs b/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs index 347923ed..cb45ffc3 100644 --- a/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs +++ b/src/Ocelot/Headers/HttpResponseHeaderReplacer.cs @@ -26,6 +26,7 @@ namespace Ocelot.Headers return $"{downstreamUrl}/"; }); } + public Response Replace(HttpResponseMessage response, List fAndRs, HttpRequestMessage httpRequestMessage) { foreach (var f in fAndRs) @@ -54,4 +55,4 @@ namespace Ocelot.Headers return new OkResponse(); } } -} \ No newline at end of file +} diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs b/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs index 583b3002..2713d44b 100644 --- a/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs +++ b/src/Ocelot/LoadBalancer/LoadBalancers/Lease.cs @@ -9,6 +9,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers HostAndPort = hostAndPort; Connections = connections; } + public ServiceHostAndPort HostAndPort { get; private set; } public int Connections { get; private set; } } diff --git a/src/Ocelot/Logging/IOcelotLoggerFactory.cs b/src/Ocelot/Logging/IOcelotLoggerFactory.cs index 29b4c9d0..3a145595 100644 --- a/src/Ocelot/Logging/IOcelotLoggerFactory.cs +++ b/src/Ocelot/Logging/IOcelotLoggerFactory.cs @@ -6,6 +6,7 @@ namespace Ocelot.Logging { IOcelotLogger CreateLogger(); } + /// /// Thin wrapper around the DotNet core logging framework, used to allow the scopedDataRepository to be injected giving access to the Ocelot RequestId /// diff --git a/src/Ocelot/Middleware/OcelotPipelineConfiguration.cs b/src/Ocelot/Middleware/OcelotPipelineConfiguration.cs index 3cfded9b..d58b8b09 100644 --- a/src/Ocelot/Middleware/OcelotPipelineConfiguration.cs +++ b/src/Ocelot/Middleware/OcelotPipelineConfiguration.cs @@ -37,7 +37,6 @@ /// /// This allows the user to implement there own query string manipulation logic /// - public Func, Task> PreQueryStringBuilderMiddleware { get; set; } - + public Func, Task> PreQueryStringBuilderMiddleware { get; set; } } } diff --git a/src/Ocelot/Raft/FakeCommand.cs b/src/Ocelot/Raft/FakeCommand.cs index 795ca7a5..45dd1045 100644 --- a/src/Ocelot/Raft/FakeCommand.cs +++ b/src/Ocelot/Raft/FakeCommand.cs @@ -8,8 +8,8 @@ namespace Ocelot.Raft public FakeCommand(string value) { this.Value = value; - } + public string Value { get; private set; } } } diff --git a/src/Ocelot/Raft/FilePeersProvider.cs b/src/Ocelot/Raft/FilePeersProvider.cs index aeca7b2c..1eddf5e3 100644 --- a/src/Ocelot/Raft/FilePeersProvider.cs +++ b/src/Ocelot/Raft/FilePeersProvider.cs @@ -37,6 +37,7 @@ namespace Ocelot.Raft _peers.Add(httpPeer); } } + public List Get() { return _peers; diff --git a/src/Ocelot/Raft/HttpPeer.cs b/src/Ocelot/Raft/HttpPeer.cs index ef76a583..34a94b27 100644 --- a/src/Ocelot/Raft/HttpPeer.cs +++ b/src/Ocelot/Raft/HttpPeer.cs @@ -28,7 +28,7 @@ namespace Ocelot.Raft { _identityServerConfiguration = identityServerConfiguration; _config = config; - Id = hostAndPort; + Id = hostAndPort; _hostAndPort = hostAndPort; _httpClient = httpClient; _jsonSerializerSettings = new JsonSerializerSettings() { @@ -68,6 +68,7 @@ namespace Ocelot.Raft { SetToken(); } + var json = JsonConvert.SerializeObject(appendEntries, _jsonSerializerSettings); var content = new StringContent(json); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); @@ -94,6 +95,7 @@ namespace Ocelot.Raft { SetToken(); } + var json = JsonConvert.SerializeObject(command, _jsonSerializerSettings); var content = new StringContent(json); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); diff --git a/src/Ocelot/Raft/SqlLiteLog.cs b/src/Ocelot/Raft/SqlLiteLog.cs index 098d9c06..9ca32af4 100644 --- a/src/Ocelot/Raft/SqlLiteLog.cs +++ b/src/Ocelot/Raft/SqlLiteLog.cs @@ -24,6 +24,7 @@ namespace Ocelot.Raft FileStream fs = File.Create(_path); fs.Dispose(); } + using(var connection = new SqliteConnection($"Data Source={_path};")) { connection.Open(); @@ -59,6 +60,7 @@ namespace Ocelot.Raft } } } + return result; } } @@ -88,6 +90,7 @@ namespace Ocelot.Raft } } } + return result; } } @@ -113,6 +116,7 @@ namespace Ocelot.Raft } } } + return result; } } @@ -222,15 +226,13 @@ namespace Ocelot.Raft }; var log = JsonConvert.DeserializeObject(data, jsonSerializerSettings); logsToReturn.Add((id, log)); - } } } } return logsToReturn; - } - + } } public long GetTermAtIndex(int index) @@ -256,9 +258,11 @@ namespace Ocelot.Raft } } } + return result; } } + public void Remove(int indexOfCommand) { lock(_lock) @@ -276,4 +280,4 @@ namespace Ocelot.Raft } } } -} \ No newline at end of file +} diff --git a/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs b/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs index 0415489c..9a4a4ce3 100644 --- a/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs +++ b/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; namespace Ocelot.RateLimit { - public class ClientRateLimitProcessor { private readonly IRateLimitCounterHandler _counterHandler; @@ -39,7 +38,5 @@ namespace Ocelot.RateLimit { return _core.ConvertToTimeSpan(timeSpan); } - } - } diff --git a/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs b/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs index ddcda184..91f933b7 100644 --- a/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs +++ b/src/Ocelot/RateLimit/DistributedCacheRateLimitCounterHanlder.cs @@ -34,6 +34,7 @@ namespace Ocelot.RateLimit { return JsonConvert.DeserializeObject(stored); } + return null; } diff --git a/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs b/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs index 064ec54b..2061decc 100644 --- a/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs +++ b/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs @@ -38,6 +38,7 @@ namespace Ocelot.RateLimit.Middleware await _next.Invoke(context); return; } + // compute identity from request var identity = SetIdentity(context.HttpContext, options); @@ -70,8 +71,8 @@ namespace Ocelot.RateLimit.Middleware return; } - } + //set X-Rate-Limit headers for the longest period if (!options.DisableRateLimitHeaders) { @@ -103,6 +104,7 @@ namespace Ocelot.RateLimit.Middleware { return true; } + return false; } @@ -134,8 +136,5 @@ namespace Ocelot.RateLimit.Middleware return Task.CompletedTask; } - } - } - diff --git a/src/Ocelot/RateLimit/RateLimitCore.cs b/src/Ocelot/RateLimit/RateLimitCore.cs index c3455682..cc027dfb 100644 --- a/src/Ocelot/RateLimit/RateLimitCore.cs +++ b/src/Ocelot/RateLimit/RateLimitCore.cs @@ -62,6 +62,7 @@ namespace Ocelot.RateLimit var expirationTime = ConvertToTimeSpan(rule.Period); _counterHandler.Set(counterId, counter, expirationTime); } + return counter; } @@ -92,7 +93,6 @@ namespace Ocelot.RateLimit rule.Period, rule.Limit.ToString(), (DateTime.UtcNow + ConvertToTimeSpan(rule.Period)).ToUniversalTime().ToString("o", DateTimeFormatInfo.InvariantInfo)); - } return headers; @@ -141,7 +141,6 @@ namespace Ocelot.RateLimit default: throw new FormatException($"{timeSpan} can't be converted to TimeSpan, unknown type {type}"); } - } - + } } } diff --git a/src/Ocelot/Requester/HttpClientHttpRequester.cs b/src/Ocelot/Requester/HttpClientHttpRequester.cs index a531d9b9..de9ea1c6 100644 --- a/src/Ocelot/Requester/HttpClientHttpRequester.cs +++ b/src/Ocelot/Requester/HttpClientHttpRequester.cs @@ -55,7 +55,6 @@ namespace Ocelot.Requester { _cacheHandlers.Set(cacheKey, httpClient, TimeSpan.FromHours(24)); } - } private IHttpClient GetHttpClient(string cacheKey, IHttpClientBuilder builder, DownstreamContext request) diff --git a/src/Ocelot/Requester/MemoryHttpClientCache.cs b/src/Ocelot/Requester/MemoryHttpClientCache.cs index 3ce1716b..e37a46a3 100644 --- a/src/Ocelot/Requester/MemoryHttpClientCache.cs +++ b/src/Ocelot/Requester/MemoryHttpClientCache.cs @@ -41,6 +41,7 @@ namespace Ocelot.Requester { connectionQueue.TryDequeue(out client); } + return client; } diff --git a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs index e2658c7f..fbd24fbf 100644 --- a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs +++ b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs @@ -35,7 +35,7 @@ namespace Ocelot.Requester { request.Headers.Remove(prefix_spanId); request.Headers.TryAddWithoutValidation(prefix_spanId, span.SpanContext.SpanId); - }; + } span.Tags.Client().Component("HttpClient") .HttpMethod(request.Method.Method) diff --git a/src/Ocelot/Responder/HttpContextResponder.cs b/src/Ocelot/Responder/HttpContextResponder.cs index fbfbc6c2..7bc55d94 100644 --- a/src/Ocelot/Responder/HttpContextResponder.cs +++ b/src/Ocelot/Responder/HttpContextResponder.cs @@ -50,7 +50,6 @@ namespace Ocelot.Responder httpContext.Response.StatusCode = (int)response.StatusCode; return Task.CompletedTask; - }, context); using (Stream stream = new MemoryStream(content)) diff --git a/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs b/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs index bac062f8..4bfbad7a 100644 --- a/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs +++ b/src/Ocelot/Responder/Middleware/ResponderMiddleware.cs @@ -29,7 +29,6 @@ namespace Ocelot.Responder.Middleware _responder = responder; _codeMapper = codeMapper; _logger = loggerFactory.CreateLogger(); - } public async Task Invoke(DownstreamContext context) diff --git a/src/Ocelot/Responses/ErrorResponse.cs b/src/Ocelot/Responses/ErrorResponse.cs index 28cd3f02..7a6688e7 100644 --- a/src/Ocelot/Responses/ErrorResponse.cs +++ b/src/Ocelot/Responses/ErrorResponse.cs @@ -8,8 +8,9 @@ namespace Ocelot.Responses public ErrorResponse(Error error) : base(new List{error}) { } + public ErrorResponse(List errors) : base(errors) { } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Responses/ErrorResponseGeneric.cs b/src/Ocelot/Responses/ErrorResponseGeneric.cs index 837c2e5d..90a16cdd 100644 --- a/src/Ocelot/Responses/ErrorResponseGeneric.cs +++ b/src/Ocelot/Responses/ErrorResponseGeneric.cs @@ -7,12 +7,12 @@ namespace Ocelot.Responses { public ErrorResponse(Error error) : base(new List {error}) - { - + { } + public ErrorResponse(List errors) : base(errors) { } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Responses/ResponseGeneric.cs b/src/Ocelot/Responses/ResponseGeneric.cs index 479dd08d..d06314bf 100644 --- a/src/Ocelot/Responses/ResponseGeneric.cs +++ b/src/Ocelot/Responses/ResponseGeneric.cs @@ -14,7 +14,6 @@ namespace Ocelot.Responses { } - public T Data { get; private set; } - + public T Data { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Ocelot/ServiceDiscovery/ServiceDiscoveryProviderFactory.cs b/src/Ocelot/ServiceDiscovery/ServiceDiscoveryProviderFactory.cs index 0e75cb1a..09db94e4 100644 --- a/src/Ocelot/ServiceDiscovery/ServiceDiscoveryProviderFactory.cs +++ b/src/Ocelot/ServiceDiscovery/ServiceDiscoveryProviderFactory.cs @@ -14,7 +14,7 @@ namespace Ocelot.ServiceDiscovery _factory = factory; } - public IServiceDiscoveryProvider Get(ServiceProviderConfiguration serviceConfig, DownstreamReRoute reRoute) + public IServiceDiscoveryProvider Get(ServiceProviderConfiguration serviceConfig, DownstreamReRoute reRoute) { if (reRoute.UseServiceDiscovery) { diff --git a/src/Ocelot/Values/Service.cs b/src/Ocelot/Values/Service.cs index 1acb26e6..abf5449b 100644 --- a/src/Ocelot/Values/Service.cs +++ b/src/Ocelot/Values/Service.cs @@ -16,6 +16,7 @@ namespace Ocelot.Values Version = version; Tags = tags; } + public string Id { get; private set; } public string Name { get; private set; } diff --git a/test/Ocelot.AcceptanceTests/AuthorisationTests.cs b/test/Ocelot.AcceptanceTests/AuthorisationTests.cs index aaa4faff..06fee4ef 100644 --- a/test/Ocelot.AcceptanceTests/AuthorisationTests.cs +++ b/test/Ocelot.AcceptanceTests/AuthorisationTests.cs @@ -177,7 +177,7 @@ namespace Ocelot.AcceptanceTests AuthenticationOptions = new FileAuthenticationOptions { AuthenticationProviderKey = "Test", - AllowedScopes = new List{ "api", "api.readOnly", "openid", "offline_access" }, + AllowedScopes = new List{ "api", "api.readOnly", "openid", "offline_access" }, }, } } @@ -218,7 +218,7 @@ namespace Ocelot.AcceptanceTests AuthenticationOptions = new FileAuthenticationOptions { AuthenticationProviderKey = "Test", - AllowedScopes = new List{ "api", "openid", "offline_access" }, + AllowedScopes = new List{ "api", "openid", "offline_access" }, }, } } @@ -356,7 +356,6 @@ namespace Ocelot.AcceptanceTests "CustomerId", "LocationId", "UserType", "UserId" } }, - }) .AddInMemoryClients(new List { @@ -437,7 +436,6 @@ namespace Ocelot.AcceptanceTests "CustomerId", "LocationId", "UserType", "UserId", "Role" } }, - }) .AddInMemoryClients(new List { @@ -450,7 +448,6 @@ namespace Ocelot.AcceptanceTests AccessTokenType = tokenType, Enabled = true, RequireClientSecret = false, - } }) .AddTestUsers(users); diff --git a/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs b/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs index 84346985..52a589c1 100644 --- a/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs +++ b/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs @@ -52,7 +52,7 @@ namespace Ocelot.AcceptanceTests UpstreamHttpMethod = new List { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { - UseTracing = true + UseTracing = true }, QoSOptions = new FileQoSOptions { @@ -77,7 +77,7 @@ namespace Ocelot.AcceptanceTests UpstreamHttpMethod = new List { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { - UseTracing = true + UseTracing = true }, QoSOptions = new FileQoSOptions { diff --git a/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs b/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs index b8c1a59e..f73a360e 100644 --- a/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs +++ b/test/Ocelot.AcceptanceTests/ClaimsToQueryStringForwardingTests.cs @@ -156,7 +156,7 @@ namespace Ocelot.AcceptanceTests { new ApiResource { - Name = apiName, + Name = apiName, Description = "My API", Enabled = true, DisplayName = "test", diff --git a/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs b/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs index 11ec83b1..fb09591b 100644 --- a/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs +++ b/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs @@ -56,7 +56,7 @@ namespace Ocelot.AcceptanceTests UpstreamHttpMethod = new List { "Get" }, RequestIdKey = _steps.RequestIdKey, - RateLimitOptions = new FileRateLimitRule() + RateLimitOptions = new FileRateLimitRule() { EnableRateLimiting = true, ClientWhitelist = new List(), @@ -75,7 +75,6 @@ namespace Ocelot.AcceptanceTests QuotaExceededMessage = "", RateLimitCounterPrefix = "", HttpStatusCode = 428 - }, RequestIdKey ="oceclientrequest" } @@ -117,7 +116,7 @@ namespace Ocelot.AcceptanceTests UpstreamHttpMethod = new List { "Get" }, RequestIdKey = _steps.RequestIdKey, - RateLimitOptions = new FileRateLimitRule() + RateLimitOptions = new FileRateLimitRule() { EnableRateLimiting = true, ClientWhitelist = new List() { "ocelotclient1"}, @@ -172,7 +171,5 @@ namespace Ocelot.AcceptanceTests _builder.Start(); } - - } } diff --git a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs index 0f30ba73..2171f72d 100644 --- a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs +++ b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs @@ -352,7 +352,6 @@ namespace Ocelot.AcceptanceTests app.UsePathBase(basePath); app.Run(context => { - if(string.IsNullOrEmpty(basePath)) { context.Response.StatusCode = statusCode; diff --git a/test/Ocelot.AcceptanceTests/HttpDelegatingHandlersTests.cs b/test/Ocelot.AcceptanceTests/HttpDelegatingHandlersTests.cs index bb2a43df..c54294cd 100644 --- a/test/Ocelot.AcceptanceTests/HttpDelegatingHandlersTests.cs +++ b/test/Ocelot.AcceptanceTests/HttpDelegatingHandlersTests.cs @@ -70,8 +70,7 @@ namespace Ocelot.AcceptanceTests } class FakeHandler : DelegatingHandler - { - + { public DateTime TimeCalled { get; private set; } protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) @@ -111,6 +110,5 @@ namespace Ocelot.AcceptanceTests _builder.Start(); } - } } diff --git a/test/Ocelot.AcceptanceTests/LoadBalancerTests.cs b/test/Ocelot.AcceptanceTests/LoadBalancerTests.cs index a5c5e07c..d67e7e41 100644 --- a/test/Ocelot.AcceptanceTests/LoadBalancerTests.cs +++ b/test/Ocelot.AcceptanceTests/LoadBalancerTests.cs @@ -159,8 +159,7 @@ namespace Ocelot.AcceptanceTests catch (System.Exception exception) { await context.Response.WriteAsync(exception.StackTrace); - } - + } }); }) .Build(); diff --git a/test/Ocelot.AcceptanceTests/QoSTests.cs b/test/Ocelot.AcceptanceTests/QoSTests.cs index e4f8a026..d11721b8 100644 --- a/test/Ocelot.AcceptanceTests/QoSTests.cs +++ b/test/Ocelot.AcceptanceTests/QoSTests.cs @@ -51,8 +51,7 @@ namespace Ocelot.AcceptanceTests ExceptionsAllowedBeforeBreaking = 1, TimeoutValue = 500, DurationOfBreak = 1000 - }, - + }, } } }; diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs index 572c7126..97e104c4 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs @@ -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(); } } -} \ No newline at end of file +} diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs index 6a6fa3c4..09f68998 100644 --- a/test/Ocelot.AcceptanceTests/Steps.cs +++ b/test/Ocelot.AcceptanceTests/Steps.cs @@ -144,6 +144,7 @@ namespace Ocelot.AcceptanceTests _ocelotClient = _ocelotServer.CreateClient(); } + /* public void GivenIHaveAddedXForwardedForHeader(string value) { diff --git a/test/Ocelot.Benchmarks/Program.cs b/test/Ocelot.Benchmarks/Program.cs index 231a816b..56b87404 100644 --- a/test/Ocelot.Benchmarks/Program.cs +++ b/test/Ocelot.Benchmarks/Program.cs @@ -8,7 +8,6 @@ namespace Ocelot.Benchmarks { var switcher = new BenchmarkSwitcher(new[] { typeof(UrlPathToUrlPathTemplateMatcherBenchmarks), - }); switcher.Run(args); diff --git a/test/Ocelot.IntegrationTests/AdministrationTests.cs b/test/Ocelot.IntegrationTests/AdministrationTests.cs index 3b2f6a35..e9fc390d 100644 --- a/test/Ocelot.IntegrationTests/AdministrationTests.cs +++ b/test/Ocelot.IntegrationTests/AdministrationTests.cs @@ -124,7 +124,6 @@ namespace Ocelot.IntegrationTests { Host = "127.0.0.1", } - }, ReRoutes = new List() { diff --git a/test/Ocelot.IntegrationTests/RaftTests.cs b/test/Ocelot.IntegrationTests/RaftTests.cs index e93e9ee4..b8c24d5a 100644 --- a/test/Ocelot.IntegrationTests/RaftTests.cs +++ b/test/Ocelot.IntegrationTests/RaftTests.cs @@ -45,6 +45,7 @@ namespace Ocelot.IntegrationTests _builders = new List(); _threads = new List(); } + 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) { - } } } diff --git a/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs b/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs index f8533a04..e61fa63b 100644 --- a/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs +++ b/test/Ocelot.IntegrationTests/ThreadSafeHeadersTests.cs @@ -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; } diff --git a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs index 07368127..1ab81895 100644 --- a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs @@ -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; - }; + } } } } diff --git a/test/Ocelot.UnitTests/Authorization/ClaimsAuthoriserTests.cs b/test/Ocelot.UnitTests/Authorization/ClaimsAuthoriserTests.cs index 0333268b..e2990864 100644 --- a/test/Ocelot.UnitTests/Authorization/ClaimsAuthoriserTests.cs +++ b/test/Ocelot.UnitTests/Authorization/ClaimsAuthoriserTests.cs @@ -28,7 +28,6 @@ namespace Ocelot.UnitTests.Authorization this.Given(x => x.GivenAClaimsPrincipal(new ClaimsPrincipal(new ClaimsIdentity(new List { new Claim("UserType", "registered"), - })))) .And(x => x.GivenARouteClaimsRequirement(new Dictionary { diff --git a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs index 42c1e695..31cc11a8 100644 --- a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareTests.cs @@ -110,7 +110,6 @@ namespace Ocelot.UnitTests.Cache private void GivenThereAreNoErrors() { _downstreamContext.Errors = new List(); - } private void ThenTheCacheGetIsCalledCorrectly() diff --git a/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs b/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs index ac60ee8b..cdb5c4c7 100644 --- a/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs +++ b/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs @@ -129,7 +129,6 @@ namespace Ocelot.UnitTests.Claims private void ThenTheResultIsError() { - _result.IsError.ShouldBe(true); } diff --git a/test/Ocelot.UnitTests/Configuration/ClaimsToThingCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/ClaimsToThingCreatorTests.cs index 656fe5dc..522d853f 100644 --- a/test/Ocelot.UnitTests/Configuration/ClaimsToThingCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ClaimsToThingCreatorTests.cs @@ -79,6 +79,7 @@ namespace Ocelot.UnitTests.Configuration { _result.Count.ShouldBeGreaterThan(0); } + private void GivenTheFollowingDictionary(Dictionary claimsToThings) { _claimsToThings = claimsToThings; @@ -107,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration .Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once); } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs b/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs index e7e56178..632461fc 100644 --- a/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs @@ -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 diff --git a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs index 64104871..10c8a012 100644 --- a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs @@ -34,6 +34,7 @@ namespace Ocelot.UnitTests.Configuration _repo.Setup(x => x.Get()).ReturnsAsync(new OkResponse(_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 { diff --git a/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs index 8bb0ecd2..cb6615bf 100644 --- a/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs @@ -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); } } diff --git a/test/Ocelot.UnitTests/Configuration/FileConfigurationRepositoryTests.cs b/test/Ocelot.UnitTests/Configuration/FileConfigurationRepositoryTests.cs index e74d0067..15dd3729 100644 --- a/test/Ocelot.UnitTests/Configuration/FileConfigurationRepositoryTests.cs +++ b/test/Ocelot.UnitTests/Configuration/FileConfigurationRepositoryTests.cs @@ -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"; diff --git a/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs index 76c3c47f..3c817295 100644 --- a/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs @@ -33,13 +33,11 @@ namespace Ocelot.UnitTests.Configuration UpstreamHeaderTransform = new Dictionary { {"Test", "Test, Chicken"}, - {"Moop", "o, a"} }, DownstreamHeaderTransform = new Dictionary { {"Pop", "West, East"}, - {"Bop", "e, r"} } }; @@ -155,4 +153,4 @@ namespace Ocelot.UnitTests.Configuration } } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/Configuration/HttpHandlerOptionsCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/HttpHandlerOptionsCreatorTests.cs index 3821ef6b..b0b11bfc 100644 --- a/test/Ocelot.UnitTests/Configuration/HttpHandlerOptionsCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/HttpHandlerOptionsCreatorTests.cs @@ -7,7 +7,6 @@ using Xunit; namespace Ocelot.UnitTests.Configuration { - public class HttpHandlerOptionsCreatorTests { private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator; diff --git a/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs index ab7fba4a..c8e79675 100644 --- a/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs @@ -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); } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs index 6f256d7f..e33ee812 100644 --- a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs +++ b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs @@ -38,6 +38,7 @@ namespace Ocelot.UnitTests.DependencyInjection _services.AddSingleton(_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 options = o => { - - }; + Action options = o => {}; this.Given(x => WhenISetUpOcelotServices()) .When(x => WhenISetUpAdministration(options)) diff --git a/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs b/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs index c5180f74..e6c3e7ca 100644 --- a/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs @@ -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); } diff --git a/test/Ocelot.UnitTests/Headers/AddHeadersToRequestTests.cs b/test/Ocelot.UnitTests/Headers/AddHeadersToRequestTests.cs index f69c6b9e..0a8290bc 100644 --- a/test/Ocelot.UnitTests/Headers/AddHeadersToRequestTests.cs +++ b/test/Ocelot.UnitTests/Headers/AddHeadersToRequestTests.cs @@ -130,7 +130,6 @@ namespace Ocelot.UnitTests.Headers private void ThenTheResultIsError() { - _result.IsError.ShouldBe(true); } diff --git a/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs b/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs index 90a24eaa..0a69bf89 100644 --- a/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Headers/HttpHeadersTransformationMiddlewareTests.cs @@ -80,7 +80,6 @@ namespace Ocelot.UnitTests.Headers _downstreamContext.TemplatePlaceholderNameAndValues = dR.TemplatePlaceholderNameAndValues; _downstreamContext.DownstreamReRoute = dR.ReRoute.DownstreamReRoute[0]; - } private void ThenTheIHttpContextRequestHeaderReplacerIsCalledCorrectly() diff --git a/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs b/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs index de8161c9..6b65bb67 100644 --- a/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs +++ b/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs @@ -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 } } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs b/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs index df5068d3..407e9f47 100644 --- a/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs +++ b/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs @@ -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("key")) .Then(x => x.ThenTheResultIsAnOkResponse("string")) @@ -83,6 +82,5 @@ namespace Ocelot.UnitTests.Infrastructure _result.ShouldBeOfType>(); ((OkResponse)_result).Data.ShouldBe(resultValue); } - } } diff --git a/test/Ocelot.UnitTests/LoadBalancer/LeastConnectionTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LeastConnectionTests.cs index e372ac4e..687f8f40 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LeastConnectionTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LeastConnectionTests.cs @@ -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() diff --git a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs index 310c1818..0af8b3af 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs @@ -188,7 +188,6 @@ namespace Ocelot.UnitTests.LoadBalancer { _downstreamContext.IsError.ShouldBeTrue(); _downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors); - } private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri) diff --git a/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs b/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs index 8a0e5670..adef00d5 100644 --- a/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs +++ b/test/Ocelot.UnitTests/Middleware/MultiplexerTests.cs @@ -58,7 +58,6 @@ namespace Ocelot.UnitTests.Middleware private void WhenIMultiplex() { _multiplexer.Multiplex(_context, _reRoute, _pipeline).GetAwaiter().GetResult(); - } private void ThePipelineIsCalled(int expected) diff --git a/test/Ocelot.UnitTests/Request/DownstreamRequestInitialiserMiddlewareTests.cs b/test/Ocelot.UnitTests/Request/DownstreamRequestInitialiserMiddlewareTests.cs index 5661ace6..2bd26a4b 100644 --- a/test/Ocelot.UnitTests/Request/DownstreamRequestInitialiserMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Request/DownstreamRequestInitialiserMiddlewareTests.cs @@ -36,7 +36,6 @@ namespace Ocelot.UnitTests.Request public DownstreamRequestInitialiserMiddlewareTests() { - _httpContext = new Mock(); _httpRequest = new Mock(); _requestMapper = new Mock(); diff --git a/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs b/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs index 545e956e..a53487a3 100644 --- a/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs +++ b/test/Ocelot.UnitTests/Requester/FakeDelegatingHandler.cs @@ -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(); } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/ServiceDiscovery/ServiceRegistryTests.cs b/test/Ocelot.UnitTests/ServiceDiscovery/ServiceRegistryTests.cs index 8a41fe7e..1079f201 100644 --- a/test/Ocelot.UnitTests/ServiceDiscovery/ServiceRegistryTests.cs +++ b/test/Ocelot.UnitTests/ServiceDiscovery/ServiceRegistryTests.cs @@ -131,8 +131,7 @@ namespace Ocelot.UnitTests.ServiceDiscovery else { _registeredServices[serviceNameAndAddress.Name] = new List(){ serviceNameAndAddress }; - } - + } } } } From edbed051deaba9caf2fb7c359f6ff6894a6e646a Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 13:16:26 +0000 Subject: [PATCH 04/11] Remove blank lines at start/end of files SA1517, SA1518 --- .../Authentication/Middleware/AuthenticationMiddleware.cs | 1 - src/Ocelot/Configuration/File/FileGlobalConfiguration.cs | 3 +-- src/Ocelot/Request/Mapper/RequestMapper.cs | 1 - test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs index ffdd1ac6..bd4683d0 100644 --- a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs +++ b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs @@ -63,4 +63,3 @@ namespace Ocelot.Authentication.Middleware } } } - diff --git a/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs b/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs index adbbdce1..8dea9ed6 100644 --- a/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs +++ b/src/Ocelot/Configuration/File/FileGlobalConfiguration.cs @@ -1,5 +1,4 @@ - -namespace Ocelot.Configuration.File +namespace Ocelot.Configuration.File { public class FileGlobalConfiguration { diff --git a/src/Ocelot/Request/Mapper/RequestMapper.cs b/src/Ocelot/Request/Mapper/RequestMapper.cs index a6f22d6d..9af0d08e 100644 --- a/src/Ocelot/Request/Mapper/RequestMapper.cs +++ b/src/Ocelot/Request/Mapper/RequestMapper.cs @@ -92,4 +92,3 @@ } } } - diff --git a/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs b/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs index a4dfcac6..f6c77b1c 100644 --- a/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs +++ b/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs @@ -1,4 +1,3 @@ - using System; using System.Collections.Generic; using Microsoft.AspNetCore.Hosting; @@ -55,4 +54,4 @@ namespace Ocelot.AcceptanceTests _steps.Dispose(); } } -} \ No newline at end of file +} From 167fbb3dafb76abab4969bf9255d428282473518 Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 13:26:27 +0000 Subject: [PATCH 05/11] Remove multiple concurrent blank lines SA1507 --- src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs | 1 - src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs | 1 - .../Configuration/Creator/FileOcelotConfigurationCreator.cs | 1 - .../Configuration/Creator/UpstreamTemplatePatternCreator.cs | 1 - src/Ocelot/Configuration/QoSOptions.cs | 3 +-- src/Ocelot/DependencyInjection/OcelotBuilder.cs | 3 +-- .../Middleware/DownstreamRouteFinderMiddleware.cs | 1 - src/Ocelot/DownstreamUrlCreator/UrlBuilder.cs | 1 - src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs | 2 -- src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs | 1 - src/Ocelot/RateLimit/ClientRateLimitProcessor.cs | 1 - src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs | 1 - test/Ocelot.AcceptanceTests/AggregateTests.cs | 1 - test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs | 1 - test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs | 4 ---- test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs | 1 - test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs | 1 - test/Ocelot.AcceptanceTests/HeaderTests.cs | 1 - test/Ocelot.AcceptanceTests/RoutingTests.cs | 3 --- test/Ocelot.AcceptanceTests/UpstreamHostTests.cs | 1 - test/Ocelot.IntegrationTests/AdministrationTests.cs | 1 - test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs | 1 - test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs | 1 - .../Configuration/ConfigurationFluentValidationTests.cs | 2 -- .../Configuration/ConsulFileConfigurationPollerTests.cs | 1 - .../Configuration/FileConfigurationCreatorTests.cs | 3 --- .../Configuration/FileConfigurationProviderTests.cs | 4 +--- .../Configuration/FileConfigurationSetterTests.cs | 3 +-- .../Configuration/HeaderFindAndReplaceCreatorTests.cs | 1 - .../Configuration/UpstreamTemplatePatternCreatorTests.cs | 1 - .../Controllers/FileConfigurationControllerTests.cs | 1 - .../DependencyInjection/OcelotBuilderTests.cs | 2 -- .../DownstreamRouteFinder/DownstreamRouteFinderTests.cs | 3 --- .../UrlMatcher/UrlPathPlaceholderNameAndValueFinderTests.cs | 3 +-- .../Errors/ExceptionHandlerMiddlewareTests.cs | 2 -- .../Headers/HttpResponseHeaderReplacerTests.cs | 1 - test/Ocelot.UnitTests/Infrastructure/ScopesAuthoriserTests.cs | 3 +-- test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs | 1 - .../Middleware/SimpleJsonResponseAggregatorTests.cs | 1 - .../RateLimit/ClientRateLimitMiddlewareTests.cs | 1 - .../RequestId/ReRouteRequestIdMiddlewareTests.cs | 1 - .../Requester/DelegatingHandlerHandlerProviderFactoryTests.cs | 1 - test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs | 1 - .../Responder/ErrorsToHttpStatusCodeMapperTests.cs | 1 - test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs | 1 - 45 files changed, 6 insertions(+), 65 deletions(-) diff --git a/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs b/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs index 873c4cf7..3d128b72 100644 --- a/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs +++ b/src/Ocelot/Cache/Middleware/OutputCacheMiddleware.cs @@ -123,7 +123,6 @@ namespace Ocelot.Cache.Middleware var contentHeaders = response?.Content?.Headers.ToDictionary(v => v.Key, v => v.Value); - var cached = new CachedResponse(statusCode, headers, body, contentHeaders); return cached; } diff --git a/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs b/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs index bc860424..ca98a823 100644 --- a/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs +++ b/src/Ocelot/Configuration/Builder/DownstreamReRouteBuilder.cs @@ -216,7 +216,6 @@ namespace Ocelot.Configuration.Builder return this; } - public DownstreamReRoute Build() { return new DownstreamReRoute( diff --git a/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs b/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs index fbc58020..a35c7d54 100644 --- a/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs +++ b/src/Ocelot/Configuration/Creator/FileOcelotConfigurationCreator.cs @@ -35,7 +35,6 @@ namespace Ocelot.Configuration.Creator private readonly IHeaderFindAndReplaceCreator _headerFAndRCreator; private readonly IDownstreamAddressesCreator _downstreamAddressesCreator; - public FileOcelotConfigurationCreator( IOptions options, IConfigurationValidator configurationValidator, diff --git a/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs b/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs index 1700472a..833c61db 100644 --- a/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs +++ b/src/Ocelot/Configuration/Creator/UpstreamTemplatePatternCreator.cs @@ -67,7 +67,6 @@ namespace Ocelot.Configuration.Creator return false; } - private bool IsPlaceHolder(string upstreamTemplate, int i) { return upstreamTemplate[i] == '{'; diff --git a/src/Ocelot/Configuration/QoSOptions.cs b/src/Ocelot/Configuration/QoSOptions.cs index 60e7cc03..651bd506 100644 --- a/src/Ocelot/Configuration/QoSOptions.cs +++ b/src/Ocelot/Configuration/QoSOptions.cs @@ -14,8 +14,7 @@ namespace Ocelot.Configuration DurationOfBreak = durationofBreak; TimeoutValue = timeoutValue; TimeoutStrategy = timeoutStrategy; - } - + } public int ExceptionsAllowedBeforeBreaking { get; private set; } diff --git a/src/Ocelot/DependencyInjection/OcelotBuilder.cs b/src/Ocelot/DependencyInjection/OcelotBuilder.cs index 6501b619..350eb566 100644 --- a/src/Ocelot/DependencyInjection/OcelotBuilder.cs +++ b/src/Ocelot/DependencyInjection/OcelotBuilder.cs @@ -264,8 +264,7 @@ namespace Ocelot.DependencyInjection var urlFinder = new BaseUrlFinder(_configurationRoot); var baseSchemeUrlAndPort = urlFinder.Find(); - JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); - + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); _services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme) .AddIdentityServerAuthentication(o => diff --git a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs index 4b467b95..e5348410 100644 --- a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs +++ b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs @@ -17,7 +17,6 @@ namespace Ocelot.DownstreamRouteFinder.Middleware private readonly IOcelotConfigurationProvider _configProvider; private readonly IMultiplexer _multiplexer; - public DownstreamRouteFinderMiddleware(OcelotRequestDelegate next, IOcelotLoggerFactory loggerFactory, IDownstreamRouteFinder downstreamRouteFinder, diff --git a/src/Ocelot/DownstreamUrlCreator/UrlBuilder.cs b/src/Ocelot/DownstreamUrlCreator/UrlBuilder.cs index 80f2507d..3a2f8d2e 100644 --- a/src/Ocelot/DownstreamUrlCreator/UrlBuilder.cs +++ b/src/Ocelot/DownstreamUrlCreator/UrlBuilder.cs @@ -25,7 +25,6 @@ namespace Ocelot.DownstreamUrlCreator return new ErrorResponse(new List { new DownstreamHostNullOrEmptyError() }); } - var builder = new UriBuilder { Host = downstreamHostAndPort.DownstreamHost, diff --git a/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs b/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs index b3a028b3..1af0acbc 100644 --- a/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs +++ b/src/Ocelot/Infrastructure/Claims/Parser/ClaimsParser.cs @@ -37,7 +37,6 @@ return new OkResponse(value); } - public Response> GetValuesByClaimType(IEnumerable claims, string claimType) { List values = new List(); @@ -47,7 +46,6 @@ return new OkResponse>(values); } - private Response GetValue(IEnumerable claims, string key) { var claim = claims.FirstOrDefault(c => c.Type == key); diff --git a/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs b/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs index efc00e5e..26d55b1f 100644 --- a/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs +++ b/src/Ocelot/LoadBalancer/LoadBalancers/RoundRobin.cs @@ -17,7 +17,6 @@ namespace Ocelot.LoadBalancer.LoadBalancers _services = services; } - public async Task> Lease() { var services = await _services.Invoke(); diff --git a/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs b/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs index 9a4a4ce3..65a04504 100644 --- a/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs +++ b/src/Ocelot/RateLimit/ClientRateLimitProcessor.cs @@ -23,7 +23,6 @@ namespace Ocelot.RateLimit return _core.ProcessRequest(requestIdentity, option); } - public int RetryAfterFrom(DateTime timestamp, RateLimitRule rule) { return _core.RetryAfterFrom(timestamp, rule); diff --git a/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs b/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs index 0b146b27..32ee6c68 100644 --- a/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs +++ b/src/Ocelot/RequestId/Middleware/ReRouteRequestIdMiddleware.cs @@ -18,7 +18,6 @@ namespace Ocelot.RequestId.Middleware private readonly IOcelotLogger _logger; private readonly IRequestScopedDataRepository _requestScopedDataRepository; - public ReRouteRequestIdMiddleware(OcelotRequestDelegate next, IOcelotLoggerFactory loggerFactory, IRequestScopedDataRepository requestScopedDataRepository) diff --git a/test/Ocelot.AcceptanceTests/AggregateTests.cs b/test/Ocelot.AcceptanceTests/AggregateTests.cs index c0ed2de2..8510fd1b 100644 --- a/test/Ocelot.AcceptanceTests/AggregateTests.cs +++ b/test/Ocelot.AcceptanceTests/AggregateTests.cs @@ -229,7 +229,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - [Fact] public void should_be_thread_safe() { diff --git a/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs b/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs index 52a589c1..a7411ebe 100644 --- a/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs +++ b/test/Ocelot.AcceptanceTests/ButterflyTracingTests.cs @@ -104,7 +104,6 @@ namespace Ocelot.AcceptanceTests .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Tom")) .BDDfy(); - var commandOnAllStateMachines = WaitFor(5000).Until(() => _butterflyCalled == 4); commandOnAllStateMachines.ShouldBeTrue(); diff --git a/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs b/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs index fb09591b..dc9d5eef 100644 --- a/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs +++ b/test/Ocelot.AcceptanceTests/ClientRateLimitTests.cs @@ -20,13 +20,11 @@ namespace Ocelot.AcceptanceTests private readonly Steps _steps; private int _counterOne; - public ClientRateLimitTests() { _steps = new Steps(); } - public void Dispose() { _builder?.Dispose(); @@ -92,7 +90,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - [Fact] public void should_call_middleware_withWhitelistClient() { @@ -147,7 +144,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath) { _builder = new WebHostBuilder() diff --git a/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs b/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs index db617718..c0dfe1ef 100644 --- a/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs +++ b/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs @@ -175,7 +175,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - [Fact] public void should_load_configuration_out_of_consul_if_it_is_changed() { diff --git a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs index 2171f72d..0cf33d4b 100644 --- a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs +++ b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs @@ -286,7 +286,6 @@ namespace Ocelot.AcceptanceTests .And(x => x.ThenTheCounterIs(1)) .BDDfy(); } - [Fact(Skip = "This is just an example to show how you could hook into Ocelot pipeline with your own middleware. At the moment you must use Response.OnCompleted callback and cannot change the response :( I will see if this can be changed one day!")] public void should_fix_issue_237() diff --git a/test/Ocelot.AcceptanceTests/HeaderTests.cs b/test/Ocelot.AcceptanceTests/HeaderTests.cs index e0bd67c8..b5a2711e 100644 --- a/test/Ocelot.AcceptanceTests/HeaderTests.cs +++ b/test/Ocelot.AcceptanceTests/HeaderTests.cs @@ -186,7 +186,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath, int statusCode, string headerKey) { _builder = new WebHostBuilder() diff --git a/test/Ocelot.AcceptanceTests/RoutingTests.cs b/test/Ocelot.AcceptanceTests/RoutingTests.cs index ea748a04..0a16e565 100644 --- a/test/Ocelot.AcceptanceTests/RoutingTests.cs +++ b/test/Ocelot.AcceptanceTests/RoutingTests.cs @@ -543,7 +543,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - [Fact] public void should_return_response_200_with_complex_url_that_starts_with_placeholder() { @@ -578,7 +577,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - [Fact] public void should_not_add_trailing_slash_to_downstream_url() { @@ -834,7 +832,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - [Fact] public void should_fix_145() { diff --git a/test/Ocelot.AcceptanceTests/UpstreamHostTests.cs b/test/Ocelot.AcceptanceTests/UpstreamHostTests.cs index 16e123a7..a6a495a1 100644 --- a/test/Ocelot.AcceptanceTests/UpstreamHostTests.cs +++ b/test/Ocelot.AcceptanceTests/UpstreamHostTests.cs @@ -58,7 +58,6 @@ namespace Ocelot.AcceptanceTests .BDDfy(); } - [Fact] public void should_return_response_200_with_simple_url_and_hosts_match_multiple_re_routes() { diff --git a/test/Ocelot.IntegrationTests/AdministrationTests.cs b/test/Ocelot.IntegrationTests/AdministrationTests.cs index e9fc390d..763d642c 100644 --- a/test/Ocelot.IntegrationTests/AdministrationTests.cs +++ b/test/Ocelot.IntegrationTests/AdministrationTests.cs @@ -484,7 +484,6 @@ namespace Ocelot.IntegrationTests app.UseOcelot().Wait(); }); - _builderTwo = _webHostBuilderTwo.Build(); _builderTwo.Start(); diff --git a/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs b/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs index cdb5c4c7..33ff1e06 100644 --- a/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs +++ b/test/Ocelot.UnitTests/Claims/AddClaimsToRequestTests.cs @@ -93,7 +93,6 @@ namespace Ocelot.UnitTests.Claims .BDDfy(); } - private void GivenClaimsToThings(List configuration) { _claimsToThings = configuration; diff --git a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs index be266f9e..5b5e386c 100644 --- a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs @@ -68,7 +68,6 @@ namespace Ocelot.UnitTests.Claims _middleware.Invoke(_downstreamContext).GetAwaiter().GetResult(); } - private void GivenTheDownStreamRouteIs(DownstreamRoute downstreamRoute) { _downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues; diff --git a/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs b/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs index 632461fc..b4dc45b0 100644 --- a/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs @@ -869,7 +869,6 @@ namespace Ocelot.UnitTests.Configuration .BDDfy(); } - [Theory] [InlineData(null)] [InlineData("")] @@ -1008,7 +1007,6 @@ namespace Ocelot.UnitTests.Configuration .BDDfy(); } - private void GivenAConfiguration(FileConfiguration fileConfiguration) { _fileConfiguration = fileConfiguration; diff --git a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs index 10c8a012..b743b598 100644 --- a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs @@ -12,7 +12,6 @@ using Xunit; using Shouldly; using static Ocelot.UnitTests.Wait; - namespace Ocelot.UnitTests.Configuration { public class ConsulFileConfigurationPollerTests : IDisposable diff --git a/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs index cb6615bf..4de07053 100644 --- a/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/FileConfigurationCreatorTests.cs @@ -502,7 +502,6 @@ namespace Ocelot.UnitTests.Configuration .WithUseServiceDiscovery(false) .Build(); - this.Given(x => x.GivenTheConfigIs(new FileConfiguration { ReRoutes = new List @@ -545,7 +544,6 @@ namespace Ocelot.UnitTests.Configuration .WithUpstreamTemplatePattern(new UpstreamPathTemplate("(?i)/api/products/.*/$", 1)) .Build(); - this.Given(x => x.GivenTheConfigIs(new FileConfiguration { ReRoutes = new List @@ -915,7 +913,6 @@ namespace Ocelot.UnitTests.Configuration .Setup(x => x.Create(It.IsAny())).Returns(serviceProviderConfiguration); } - private void GivenTheFollowingRegionIsReturned(string region) { _regionCreator diff --git a/test/Ocelot.UnitTests/Configuration/FileConfigurationProviderTests.cs b/test/Ocelot.UnitTests/Configuration/FileConfigurationProviderTests.cs index be3df6cc..506da50c 100644 --- a/test/Ocelot.UnitTests/Configuration/FileConfigurationProviderTests.cs +++ b/test/Ocelot.UnitTests/Configuration/FileConfigurationProviderTests.cs @@ -38,8 +38,6 @@ namespace Ocelot.UnitTests.Configuration .BDDfy(); } - - private void GivenTheConfigurationIs(FileConfiguration fileConfiguration) { _fileConfiguration = fileConfiguration; @@ -59,4 +57,4 @@ namespace Ocelot.UnitTests.Configuration .Verify(x => x.Get(), Times.Once); } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/Configuration/FileConfigurationSetterTests.cs b/test/Ocelot.UnitTests/Configuration/FileConfigurationSetterTests.cs index 60365661..e16148f2 100644 --- a/test/Ocelot.UnitTests/Configuration/FileConfigurationSetterTests.cs +++ b/test/Ocelot.UnitTests/Configuration/FileConfigurationSetterTests.cs @@ -48,7 +48,6 @@ namespace Ocelot.UnitTests.Configuration .BDDfy(); } - [Fact] public void should_return_error_if_unable_to_set_file_configuration() { @@ -110,4 +109,4 @@ namespace Ocelot.UnitTests.Configuration .Verify(x => x.AddOrReplace(_configuration.Data), Times.Once); } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs index 3c817295..37ee8957 100644 --- a/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/HeaderFindAndReplaceCreatorTests.cs @@ -84,7 +84,6 @@ namespace Ocelot.UnitTests.Configuration .BDDfy(); } - [Fact] public void should_use_base_url_partial_placeholder() { diff --git a/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs index c8e79675..9dce0e50 100644 --- a/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/UpstreamTemplatePatternCreatorTests.cs @@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.Configuration .BDDfy(); } - [Fact] public void should_match_forward_slash_or_no_forward_slash_if_template_end_with_forward_slash() { diff --git a/test/Ocelot.UnitTests/Controllers/FileConfigurationControllerTests.cs b/test/Ocelot.UnitTests/Controllers/FileConfigurationControllerTests.cs index 0d95f0ea..c0ae8b87 100644 --- a/test/Ocelot.UnitTests/Controllers/FileConfigurationControllerTests.cs +++ b/test/Ocelot.UnitTests/Controllers/FileConfigurationControllerTests.cs @@ -111,7 +111,6 @@ namespace Ocelot.UnitTests.Controllers .BDDfy(); } - private void ThenTheNodeIsCalledCorrectly() { _node.Verify(x => x.Accept(It.IsAny()), Times.Once); diff --git a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs index e33ee812..8ed1a327 100644 --- a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs +++ b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs @@ -70,7 +70,6 @@ namespace Ocelot.UnitTests.DependencyInjection .BDDfy(); } - [Fact] public void should_set_up_cache_manager() { @@ -151,7 +150,6 @@ namespace Ocelot.UnitTests.DependencyInjection .BDDfy(); } - [Fact] public void should_set_up_without_passing_in_config() { diff --git a/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs b/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs index b7761c60..cb5c2a67 100644 --- a/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs +++ b/test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteFinderTests.cs @@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder _downstreamRouteFinder = new Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder(_mockMatcher.Object, _finder.Object); } - [Fact] public void should_return_highest_priority_when_first() { @@ -182,7 +181,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder .BDDfy(); } - [Fact] public void should_not_append_slash_to_upstream_url_path() { @@ -598,7 +596,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder .BDDfy(); } - [Fact] public void should_return_route_when_host_matches_but_null_host_on_same_path_first() { diff --git a/test/Ocelot.UnitTests/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinderTests.cs b/test/Ocelot.UnitTests/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinderTests.cs index afd1b3ae..29bc8fcd 100644 --- a/test/Ocelot.UnitTests/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinderTests.cs +++ b/test/Ocelot.UnitTests/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValueFinderTests.cs @@ -30,7 +30,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher .BDDfy(); } - [Fact] public void can_match_down_stream_url_with_nothing_then_placeholder_no_value_is_blank() { @@ -264,4 +263,4 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher _result = _finder.Find(_downstreamUrlPath, _downstreamPathTemplate); } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs b/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs index e6c3e7ca..89eaaa38 100644 --- a/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Errors/ExceptionHandlerMiddlewareTests.cs @@ -29,7 +29,6 @@ namespace Ocelot.UnitTests.Errors private DownstreamContext _downstreamContext; private OcelotRequestDelegate _next; - public ExceptionHandlerMiddlewareTests() { _provider = new Mock(); @@ -174,7 +173,6 @@ namespace Ocelot.UnitTests.Errors .Setup(x => x.Get()).ReturnsAsync(response); } - private void GivenAnExceptionWillNotBeThrownDownstream() { _shouldThrowAnException = false; diff --git a/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs b/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs index 6b65bb67..95ae6e6d 100644 --- a/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs +++ b/test/Ocelot.UnitTests/Headers/HttpResponseHeaderReplacerTests.cs @@ -98,7 +98,6 @@ namespace Ocelot.UnitTests.Headers .BDDfy(); } - [Fact] public void should_replace_downstream_base_url_with_ocelot_base_url_and_path() { diff --git a/test/Ocelot.UnitTests/Infrastructure/ScopesAuthoriserTests.cs b/test/Ocelot.UnitTests/Infrastructure/ScopesAuthoriserTests.cs index 1d476db3..08f6a46d 100644 --- a/test/Ocelot.UnitTests/Infrastructure/ScopesAuthoriserTests.cs +++ b/test/Ocelot.UnitTests/Infrastructure/ScopesAuthoriserTests.cs @@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.Infrastructure .BDDfy(); } - [Fact] public void should_return_ok_if_null_allowed_scopes() { @@ -121,4 +120,4 @@ namespace Ocelot.UnitTests.Infrastructure { } } -} \ No newline at end of file +} diff --git a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs index f5604ab1..2a4d3a24 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs @@ -116,7 +116,6 @@ namespace Ocelot.UnitTests.LoadBalancer _factory.Verify(x => x.Get(_reRoute, _serviceProviderConfig), Times.Once); } - private void GivenThereIsALoadBalancer(DownstreamReRoute reRoute, ILoadBalancer loadBalancer) { _reRoute = reRoute; diff --git a/test/Ocelot.UnitTests/Middleware/SimpleJsonResponseAggregatorTests.cs b/test/Ocelot.UnitTests/Middleware/SimpleJsonResponseAggregatorTests.cs index b5fabaee..27d1b7e0 100644 --- a/test/Ocelot.UnitTests/Middleware/SimpleJsonResponseAggregatorTests.cs +++ b/test/Ocelot.UnitTests/Middleware/SimpleJsonResponseAggregatorTests.cs @@ -42,7 +42,6 @@ namespace Ocelot.UnitTests.Middleware .WithDownstreamReRoutes(downstreamReRoutes) .Build(); - var billDownstreamContext = new DownstreamContext(new DefaultHttpContext()) { DownstreamResponse = diff --git a/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs b/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs index 168781bc..57d2fdc8 100644 --- a/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/RateLimit/ClientRateLimitMiddlewareTests.cs @@ -19,7 +19,6 @@ namespace Ocelot.UnitTests.RateLimit using Microsoft.Extensions.Caching.Memory; using System.IO; - public class ClientRateLimitMiddlewareTests { private int _responseStatusCode; diff --git a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs index 40276547..c49f2c6a 100644 --- a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs @@ -165,7 +165,6 @@ namespace Ocelot.UnitTests.RequestId _repo.Verify(x => x.Update("RequestId", _value), Times.Once); } - private void GivenTheDownStreamRouteIs(DownstreamRoute downstreamRoute) { _downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues; diff --git a/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs b/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs index e6942681..c63e04d2 100644 --- a/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs +++ b/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs @@ -41,7 +41,6 @@ namespace Ocelot.UnitTests.Requester .Returns(qosProvider); } - [Fact] public void should_all_from_all_routes_provider_and_qos() { diff --git a/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs b/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs index 487a3509..f6095034 100644 --- a/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs +++ b/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs @@ -111,7 +111,6 @@ namespace Ocelot.UnitTests.Requester _getResult.Data.ShouldBe(_qoSProvider); } - private void GivenThereIsAQoSProvider(DownstreamReRoute reRoute, IQoSProvider qoSProvider) { _reRoute = reRoute; diff --git a/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs b/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs index 9922df6a..977a0b12 100644 --- a/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs +++ b/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs @@ -45,7 +45,6 @@ namespace Ocelot.UnitTests.Responder ShouldMapErrorToStatusCode(OcelotErrorCode.RequestTimedOutError, HttpStatusCode.ServiceUnavailable); } - [Theory] [InlineData(OcelotErrorCode.CannotAddDataError)] [InlineData(OcelotErrorCode.CannotFindDataError)] diff --git a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs index fb0720b4..28a0707a 100644 --- a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs @@ -27,7 +27,6 @@ namespace Ocelot.UnitTests.Responder private readonly DownstreamContext _downstreamContext; private OcelotRequestDelegate _next; - public ResponderMiddlewareTests() { _responder = new Mock(); From f24c0a05107ba73040ecaf496db9235956bb0923 Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 13:29:05 +0000 Subject: [PATCH 06/11] Fix multiple statements on single line SA1107 --- src/Ocelot/Raft/OcelotFiniteStateMachine.cs | 4 ++-- src/Ocelot/Requester/OcelotHttpTracingHandler.cs | 2 +- test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs | 4 ++-- .../Configuration/ConfigurationFluentValidationTests.cs | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Ocelot/Raft/OcelotFiniteStateMachine.cs b/src/Ocelot/Raft/OcelotFiniteStateMachine.cs index f63695f2..feecd7d7 100644 --- a/src/Ocelot/Raft/OcelotFiniteStateMachine.cs +++ b/src/Ocelot/Raft/OcelotFiniteStateMachine.cs @@ -19,7 +19,7 @@ namespace Ocelot.Raft //todo - handle an error //hack it to just cast as at the moment we know this is the only command :P var hack = (UpdateFileConfiguration)log.CommandData; - _setter.Set(hack.Configuration).GetAwaiter().GetResult();; + _setter.Set(hack.Configuration).GetAwaiter().GetResult(); } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs index fbd24fbf..0eb22462 100644 --- a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs +++ b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs @@ -51,7 +51,7 @@ namespace Ocelot.Requester if (!c.Contains(k)) { c.Add(k, v); - }; + } }); span.Log(LogField.CreateNew().ClientSend()); diff --git a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs index 0cf33d4b..341986fe 100644 --- a/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs +++ b/test/Ocelot.AcceptanceTests/CustomMiddlewareTests.cs @@ -25,7 +25,7 @@ namespace Ocelot.AcceptanceTests public CustomMiddlewareTests() { _counter = 0; - _steps = new Steps();; + _steps = new Steps(); _configurationPath = "configuration.json"; } @@ -357,7 +357,7 @@ namespace Ocelot.AcceptanceTests } else if(context.Request.Path.Value != basePath) { - context.Response.StatusCode = 404;; + context.Response.StatusCode = 404; } return Task.CompletedTask; diff --git a/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs b/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs index b4dc45b0..70f115c1 100644 --- a/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ConfigurationFluentValidationTests.cs @@ -588,7 +588,8 @@ namespace Ocelot.UnitTests.Configuration AuthenticationOptions = new FileAuthenticationOptions() { AuthenticationProviderKey = "Test" - } } + } + } } })) .When(x => x.WhenIValidateTheConfiguration()) From b18c8e5f2b0951a10608e476f614117fcae497e7 Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 13:34:19 +0000 Subject: [PATCH 07/11] Fix single-line comment spacing SA1512, SA1515 --- src/Ocelot/Configuration/File/FileConfiguration.cs | 1 + src/Ocelot/Configuration/File/FileRateLimitRule.cs | 1 + src/Ocelot/Configuration/RateLimitRule.cs | 3 ++- .../Middleware/DownstreamRouteFinderMiddleware.cs | 4 ++-- src/Ocelot/Middleware/DownstreamContext.cs | 2 -- src/Ocelot/Middleware/OcelotMiddlewareExtensions.cs | 8 +++++--- src/Ocelot/Raft/FilePeersProvider.cs | 2 ++ src/Ocelot/Raft/SqlLiteLog.cs | 6 ++++++ .../RateLimit/Middleware/ClientRateLimitMiddleware.cs | 2 ++ src/Ocelot/RateLimit/RateLimitCore.cs | 2 ++ .../Infrastructure/HttpDataRepositoryTests.cs | 6 ++++-- 11 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Ocelot/Configuration/File/FileConfiguration.cs b/src/Ocelot/Configuration/File/FileConfiguration.cs index 6d73ce3f..e38ae6cb 100644 --- a/src/Ocelot/Configuration/File/FileConfiguration.cs +++ b/src/Ocelot/Configuration/File/FileConfiguration.cs @@ -12,6 +12,7 @@ namespace Ocelot.Configuration.File } public List ReRoutes { get; set; } + // Seperate field for aggregates because this let's you re-use ReRoutes in multiple Aggregates public List Aggregates { get;set; } public FileGlobalConfiguration GlobalConfiguration { get; set; } diff --git a/src/Ocelot/Configuration/File/FileRateLimitRule.cs b/src/Ocelot/Configuration/File/FileRateLimitRule.cs index 2dda3084..5e1616e6 100644 --- a/src/Ocelot/Configuration/File/FileRateLimitRule.cs +++ b/src/Ocelot/Configuration/File/FileRateLimitRule.cs @@ -26,6 +26,7 @@ namespace Ocelot.Configuration.File public string Period { get; set; } public double PeriodTimespan { get; set; } + /// /// Maximum number of requests that a client can make in a defined period /// diff --git a/src/Ocelot/Configuration/RateLimitRule.cs b/src/Ocelot/Configuration/RateLimitRule.cs index d77919ae..9240087c 100644 --- a/src/Ocelot/Configuration/RateLimitRule.cs +++ b/src/Ocelot/Configuration/RateLimitRule.cs @@ -17,9 +17,10 @@ namespace Ocelot.Configuration public string Period { get; private set; } public double PeriodTimespan { get; private set; } + /// /// Maximum number of requests that a client can make in a defined period /// public long Limit { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs index e5348410..c9da50a4 100644 --- a/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs +++ b/src/Ocelot/DownstreamRouteFinder/Middleware/DownstreamRouteFinderMiddleware.cs @@ -59,8 +59,8 @@ namespace Ocelot.DownstreamRouteFinder.Middleware return; } - //todo - put this back in - // _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamReRoute.DownstreamPathTemplate); + // todo - put this back in + //// _logger.LogDebug("downstream template is {downstreamRoute.Data.ReRoute.DownstreamPath}", downstreamRoute.Data.ReRoute.DownstreamReRoute.DownstreamPathTemplate); context.TemplatePlaceholderNameAndValues = downstreamRoute.Data.TemplatePlaceholderNameAndValues; diff --git a/src/Ocelot/Middleware/DownstreamContext.cs b/src/Ocelot/Middleware/DownstreamContext.cs index 84ebc77a..1c805deb 100644 --- a/src/Ocelot/Middleware/DownstreamContext.cs +++ b/src/Ocelot/Middleware/DownstreamContext.cs @@ -22,8 +22,6 @@ namespace Ocelot.Middleware public HttpRequestMessage DownstreamRequest { get; set; } public HttpResponseMessage DownstreamResponse { get; set; } public List Errors { get;set; } - //public string RequestId {get;set;} - //public string PreviousRequestId {get;set;} public bool IsError => Errors.Count > 0; } } diff --git a/src/Ocelot/Middleware/OcelotMiddlewareExtensions.cs b/src/Ocelot/Middleware/OcelotMiddlewareExtensions.cs index 541a8e93..cda82bef 100644 --- a/src/Ocelot/Middleware/OcelotMiddlewareExtensions.cs +++ b/src/Ocelot/Middleware/OcelotMiddlewareExtensions.cs @@ -59,9 +59,11 @@ var firstDelegate = pipelineBuilder.Build(); - //inject first delegate into first piece of asp.net middleware..maybe not like this - //then because we are updating the http context in ocelot it comes out correct for - //rest of asp.net.. + /* + inject first delegate into first piece of asp.net middleware..maybe not like this + then because we are updating the http context in ocelot it comes out correct for + rest of asp.net.. + */ builder.Use(async (context, task) => { diff --git a/src/Ocelot/Raft/FilePeersProvider.cs b/src/Ocelot/Raft/FilePeersProvider.cs index 1eddf5e3..d31dc2ca 100644 --- a/src/Ocelot/Raft/FilePeersProvider.cs +++ b/src/Ocelot/Raft/FilePeersProvider.cs @@ -27,11 +27,13 @@ namespace Ocelot.Raft _finder = finder; _options = options; _peers = new List(); + //todo - sort out async nonsense.. var config = _provider.Get().GetAwaiter().GetResult(); foreach (var item in _options.Value.Peers) { var httpClient = new HttpClient(); + //todo what if this errors? var httpPeer = new HttpPeer(item.HostAndPort, httpClient, _finder, config.Data, _identityServerConfig); _peers.Add(httpPeer); diff --git a/src/Ocelot/Raft/SqlLiteLog.cs b/src/Ocelot/Raft/SqlLiteLog.cs index 9ca32af4..aff04bf5 100644 --- a/src/Ocelot/Raft/SqlLiteLog.cs +++ b/src/Ocelot/Raft/SqlLiteLog.cs @@ -133,6 +133,7 @@ namespace Ocelot.Raft TypeNameHandling = TypeNameHandling.All }; var data = JsonConvert.SerializeObject(log, jsonSerializerSettings); + //todo - sql injection dont copy this.. var sql = $"insert into logs (data) values ('{data}')"; using(var command = new SqliteCommand(sql, connection)) @@ -157,6 +158,7 @@ namespace Ocelot.Raft using(var connection = new SqliteConnection($"Data Source={_path};")) { connection.Open(); + //todo - sql injection dont copy this.. var sql = $"select data from logs where id = {index};"; using(var command = new SqliteCommand(sql, connection)) @@ -187,6 +189,7 @@ namespace Ocelot.Raft using(var connection = new SqliteConnection($"Data Source={_path};")) { connection.Open(); + //todo - sql injection dont copy this.. var sql = $"select data from logs where id = {index}"; using(var command = new SqliteCommand(sql, connection)) @@ -211,6 +214,7 @@ namespace Ocelot.Raft using(var connection = new SqliteConnection($"Data Source={_path};")) { connection.Open(); + //todo - sql injection dont copy this.. var sql = $"select id, data from logs where id >= {index}"; using(var command = new SqliteCommand(sql, connection)) @@ -243,6 +247,7 @@ namespace Ocelot.Raft using(var connection = new SqliteConnection($"Data Source={_path};")) { connection.Open(); + //todo - sql injection dont copy this.. var sql = $"select data from logs where id = {index}"; using(var command = new SqliteCommand(sql, connection)) @@ -270,6 +275,7 @@ namespace Ocelot.Raft using(var connection = new SqliteConnection($"Data Source={_path};")) { connection.Open(); + //todo - sql injection dont copy this.. var deleteSql = $"delete from logs where id >= {indexOfCommand};"; using(var deleteCommand = new SqliteCommand(deleteSql, connection)) diff --git a/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs b/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs index 2061decc..4ceb91f8 100644 --- a/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs +++ b/src/Ocelot/RateLimit/Middleware/ClientRateLimitMiddleware.cs @@ -31,6 +31,7 @@ namespace Ocelot.RateLimit.Middleware public async Task Invoke(DownstreamContext context) { var options = context.DownstreamReRoute.RateLimitOptions; + // check if rate limiting is enabled if (!context.DownstreamReRoute.EnableEndpointEndpointRateLimiting) { @@ -66,6 +67,7 @@ namespace Ocelot.RateLimit.Middleware LogBlockedRequest(context.HttpContext, identity, counter, rule, context.DownstreamReRoute); var retrystring = retryAfter.ToString(System.Globalization.CultureInfo.InvariantCulture); + // break execution await ReturnQuotaExceededResponse(context.HttpContext, options, retrystring); diff --git a/src/Ocelot/RateLimit/RateLimitCore.cs b/src/Ocelot/RateLimit/RateLimitCore.cs index cc027dfb..82124c85 100644 --- a/src/Ocelot/RateLimit/RateLimitCore.cs +++ b/src/Ocelot/RateLimit/RateLimitCore.cs @@ -38,6 +38,7 @@ namespace Ocelot.RateLimit { // increment request count var totalRequests = entry.Value.TotalRequests + 1; + // deep copy counter = new RateLimitCounter(entry.Value.Timestamp, totalRequests); } @@ -70,6 +71,7 @@ namespace Ocelot.RateLimit { var counterId = ComputeCounterKey(requestIdentity, option); var rule = option.RateLimitRule; + // stores: id (string) - timestamp (datetime) - total_requests (long) _counterHandler.Set(counterId, counter, expirationTime); } diff --git a/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs b/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs index 407e9f47..c9f66009 100644 --- a/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs +++ b/test/Ocelot.UnitTests/Infrastructure/HttpDataRepositoryTests.cs @@ -21,8 +21,10 @@ namespace Ocelot.UnitTests.Infrastructure _httpDataRepository = new HttpDataRepository(_httpContextAccessor); } - //TODO - Additional tests -> Type mistmatch aka Add string, request int - //TODO - Additional tests -> HttpContent null. This should never happen + /* + TODO - Additional tests -> Type mistmatch aka Add string, request int + TODO - Additional tests -> HttpContent null. This should never happen + */ [Fact] public void get_returns_correct_key_from_http_context() From c7dbfc044fde93d30b7813e53d5811a15f438caa Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 13:36:09 +0000 Subject: [PATCH 08/11] Fix else statement spacing SA1510 --- test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs b/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs index c0dfe1ef..7c9ac239 100644 --- a/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs +++ b/test/Ocelot.AcceptanceTests/ConfigurationInConsulTests.cs @@ -306,8 +306,7 @@ namespace Ocelot.AcceptanceTests var kvp = new FakeConsulGetResponse(base64); await context.Response.WriteJsonAsync(new FakeConsulGetResponse[] { kvp }); - } - + } else if (context.Request.Method.ToLower() == "put" && context.Request.Path.Value == "/v1/kv/OcelotConfiguration") { try From a64e263a266be32cf1287653b1a690edaa728b03 Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 13:48:30 +0000 Subject: [PATCH 09/11] Fix file names to match class names SA1649 --- ...ion.cs => ServiceProviderConfiguration.cs} | 26 +++++----- ...r.cs => IPlaceholderNameAndValueFinder.cs} | 20 ++++---- ...AndValue.cs => PlaceholderNameAndValue.cs} | 28 +++++------ ...nstreamTemplatePathPlaceholderReplacer.cs} | 48 +++++++++---------- ... => IDownstreamPathPlaceholderReplacer.cs} | 22 ++++----- ...age.cs => ExcludeFromCoverageAttribute.cs} | 12 ++--- src/Ocelot/Requester/ITracingHandler.cs | 6 +++ .../Requester/OcelotHttpTracingHandler.cs | 4 -- src/Ocelot/Responses/ErrorResponseGeneric.cs | 2 + src/Ocelot/Responses/OkResponseGeneric.cs | 4 +- src/Ocelot/Responses/ResponseGeneric.cs | 2 + test/Ocelot.UnitTests/Wait.cs | 10 ++++ test/Ocelot.UnitTests/Waiter.cs | 10 +--- 13 files changed, 102 insertions(+), 92 deletions(-) rename src/Ocelot/Configuration/{ServiceProviderConfiguraion.cs => ServiceProviderConfiguration.cs} (97%) rename src/Ocelot/DownstreamRouteFinder/UrlMatcher/{IUrlPathPlaceholderNameAndValueFinder.cs => IPlaceholderNameAndValueFinder.cs} (96%) rename src/Ocelot/DownstreamRouteFinder/UrlMatcher/{UrlPathPlaceholderNameAndValue.cs => PlaceholderNameAndValue.cs} (96%) rename src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/{DownstreamUrlTemplateVariableReplacer.cs => DownstreamTemplatePathPlaceholderReplacer.cs} (97%) rename src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/{IDownstreamUrlPathTemplateVariableReplacer.cs => IDownstreamPathPlaceholderReplacer.cs} (97%) rename src/Ocelot/Raft/{ExcludeFromCoverage.cs => ExcludeFromCoverageAttribute.cs} (97%) create mode 100644 src/Ocelot/Requester/ITracingHandler.cs create mode 100644 test/Ocelot.UnitTests/Wait.cs diff --git a/src/Ocelot/Configuration/ServiceProviderConfiguraion.cs b/src/Ocelot/Configuration/ServiceProviderConfiguration.cs similarity index 97% rename from src/Ocelot/Configuration/ServiceProviderConfiguraion.cs rename to src/Ocelot/Configuration/ServiceProviderConfiguration.cs index 272d2205..d5ddea6a 100644 --- a/src/Ocelot/Configuration/ServiceProviderConfiguraion.cs +++ b/src/Ocelot/Configuration/ServiceProviderConfiguration.cs @@ -1,14 +1,14 @@ -namespace Ocelot.Configuration -{ - public class ServiceProviderConfiguration - { - public ServiceProviderConfiguration(string serviceProviderHost, int serviceProviderPort) - { - ServiceProviderHost = serviceProviderHost; - ServiceProviderPort = serviceProviderPort; - } - - public string ServiceProviderHost { get; private set; } - public int ServiceProviderPort { get; private set; } - } +namespace Ocelot.Configuration +{ + public class ServiceProviderConfiguration + { + public ServiceProviderConfiguration(string serviceProviderHost, int serviceProviderPort) + { + ServiceProviderHost = serviceProviderHost; + ServiceProviderPort = serviceProviderPort; + } + + public string ServiceProviderHost { get; private set; } + public int ServiceProviderPort { get; private set; } + } } \ No newline at end of file diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IUrlPathPlaceholderNameAndValueFinder.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IPlaceholderNameAndValueFinder.cs similarity index 96% rename from src/Ocelot/DownstreamRouteFinder/UrlMatcher/IUrlPathPlaceholderNameAndValueFinder.cs rename to src/Ocelot/DownstreamRouteFinder/UrlMatcher/IPlaceholderNameAndValueFinder.cs index d2cb4167..678b1081 100644 --- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IUrlPathPlaceholderNameAndValueFinder.cs +++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/IPlaceholderNameAndValueFinder.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; -using Ocelot.Responses; - -namespace Ocelot.DownstreamRouteFinder.UrlMatcher -{ - public interface IPlaceholderNameAndValueFinder - { - Response> Find(string path, string pathTemplate); - } -} +using System.Collections.Generic; +using Ocelot.Responses; + +namespace Ocelot.DownstreamRouteFinder.UrlMatcher +{ + public interface IPlaceholderNameAndValueFinder + { + Response> Find(string path, string pathTemplate); + } +} diff --git a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValue.cs b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/PlaceholderNameAndValue.cs similarity index 96% rename from src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValue.cs rename to src/Ocelot/DownstreamRouteFinder/UrlMatcher/PlaceholderNameAndValue.cs index f91faa1d..90099d58 100644 --- a/src/Ocelot/DownstreamRouteFinder/UrlMatcher/UrlPathPlaceholderNameAndValue.cs +++ b/src/Ocelot/DownstreamRouteFinder/UrlMatcher/PlaceholderNameAndValue.cs @@ -1,14 +1,14 @@ -namespace Ocelot.DownstreamRouteFinder.UrlMatcher -{ - public class PlaceholderNameAndValue - { - public PlaceholderNameAndValue(string name, string value) - { - Name = name; - Value = value; - } - - public string Name {get;private set;} - public string Value {get;private set;} - } -} +namespace Ocelot.DownstreamRouteFinder.UrlMatcher +{ + public class PlaceholderNameAndValue + { + public PlaceholderNameAndValue(string name, string value) + { + Name = name; + Value = value; + } + + public string Name {get;private set;} + public string Value {get;private set;} + } +} diff --git a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamUrlTemplateVariableReplacer.cs b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamTemplatePathPlaceholderReplacer.cs similarity index 97% rename from src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamUrlTemplateVariableReplacer.cs rename to src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamTemplatePathPlaceholderReplacer.cs index dfd70eed..1b744819 100644 --- a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamUrlTemplateVariableReplacer.cs +++ b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/DownstreamTemplatePathPlaceholderReplacer.cs @@ -1,25 +1,25 @@ -using System.Collections.Generic; -using System.Text; -using Ocelot.DownstreamRouteFinder.UrlMatcher; -using Ocelot.Responses; -using Ocelot.Values; - -namespace Ocelot.DownstreamUrlCreator.UrlTemplateReplacer -{ - public class DownstreamTemplatePathPlaceholderReplacer : IDownstreamPathPlaceholderReplacer - { - public Response Replace(PathTemplate downstreamPathTemplate, List urlPathPlaceholderNameAndValues) - { - var downstreamPath = new StringBuilder(); - - downstreamPath.Append(downstreamPathTemplate.Value); - - foreach (var placeholderVariableAndValue in urlPathPlaceholderNameAndValues) - { - downstreamPath.Replace(placeholderVariableAndValue.Name, placeholderVariableAndValue.Value); - } - - return new OkResponse(new DownstreamPath(downstreamPath.ToString())); - } - } +using System.Collections.Generic; +using System.Text; +using Ocelot.DownstreamRouteFinder.UrlMatcher; +using Ocelot.Responses; +using Ocelot.Values; + +namespace Ocelot.DownstreamUrlCreator.UrlTemplateReplacer +{ + public class DownstreamTemplatePathPlaceholderReplacer : IDownstreamPathPlaceholderReplacer + { + public Response Replace(PathTemplate downstreamPathTemplate, List urlPathPlaceholderNameAndValues) + { + var downstreamPath = new StringBuilder(); + + downstreamPath.Append(downstreamPathTemplate.Value); + + foreach (var placeholderVariableAndValue in urlPathPlaceholderNameAndValues) + { + downstreamPath.Replace(placeholderVariableAndValue.Name, placeholderVariableAndValue.Value); + } + + return new OkResponse(new DownstreamPath(downstreamPath.ToString())); + } + } } \ No newline at end of file diff --git a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamUrlPathTemplateVariableReplacer.cs b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamPathPlaceholderReplacer.cs similarity index 97% rename from src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamUrlPathTemplateVariableReplacer.cs rename to src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamPathPlaceholderReplacer.cs index 9e12b580..46e998d4 100644 --- a/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamUrlPathTemplateVariableReplacer.cs +++ b/src/Ocelot/DownstreamUrlCreator/UrlTemplateReplacer/IDownstreamPathPlaceholderReplacer.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; -using Ocelot.DownstreamRouteFinder.UrlMatcher; -using Ocelot.Responses; -using Ocelot.Values; - -namespace Ocelot.DownstreamUrlCreator.UrlTemplateReplacer -{ - public interface IDownstreamPathPlaceholderReplacer - { - Response Replace(PathTemplate downstreamPathTemplate, List urlPathPlaceholderNameAndValues); - } +using System.Collections.Generic; +using Ocelot.DownstreamRouteFinder.UrlMatcher; +using Ocelot.Responses; +using Ocelot.Values; + +namespace Ocelot.DownstreamUrlCreator.UrlTemplateReplacer +{ + public interface IDownstreamPathPlaceholderReplacer + { + Response Replace(PathTemplate downstreamPathTemplate, List urlPathPlaceholderNameAndValues); + } } \ No newline at end of file diff --git a/src/Ocelot/Raft/ExcludeFromCoverage.cs b/src/Ocelot/Raft/ExcludeFromCoverageAttribute.cs similarity index 97% rename from src/Ocelot/Raft/ExcludeFromCoverage.cs rename to src/Ocelot/Raft/ExcludeFromCoverageAttribute.cs index 70d42167..9ea5544a 100644 --- a/src/Ocelot/Raft/ExcludeFromCoverage.cs +++ b/src/Ocelot/Raft/ExcludeFromCoverageAttribute.cs @@ -1,7 +1,7 @@ -using System; - -namespace Ocelot.Raft -{ - [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Property)] - public class ExcludeFromCoverageAttribute : Attribute{} +using System; + +namespace Ocelot.Raft +{ + [AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Property)] + public class ExcludeFromCoverageAttribute : Attribute{} } \ No newline at end of file diff --git a/src/Ocelot/Requester/ITracingHandler.cs b/src/Ocelot/Requester/ITracingHandler.cs new file mode 100644 index 00000000..87593303 --- /dev/null +++ b/src/Ocelot/Requester/ITracingHandler.cs @@ -0,0 +1,6 @@ +namespace Ocelot.Requester +{ + public interface ITracingHandler + { + } +} diff --git a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs index 0eb22462..33bd4caf 100644 --- a/src/Ocelot/Requester/OcelotHttpTracingHandler.cs +++ b/src/Ocelot/Requester/OcelotHttpTracingHandler.cs @@ -8,10 +8,6 @@ using Butterfly.OpenTracing; namespace Ocelot.Requester { - public interface ITracingHandler - { - } - public class OcelotHttpTracingHandler : DelegatingHandler, ITracingHandler { private readonly IServiceTracer _tracer; diff --git a/src/Ocelot/Responses/ErrorResponseGeneric.cs b/src/Ocelot/Responses/ErrorResponseGeneric.cs index 90a16cdd..f57de97f 100644 --- a/src/Ocelot/Responses/ErrorResponseGeneric.cs +++ b/src/Ocelot/Responses/ErrorResponseGeneric.cs @@ -3,7 +3,9 @@ using Ocelot.Errors; namespace Ocelot.Responses { +#pragma warning disable SA1649 // File name must match first type name public class ErrorResponse : Response +#pragma warning restore SA1649 // File name must match first type name { public ErrorResponse(Error error) : base(new List {error}) diff --git a/src/Ocelot/Responses/OkResponseGeneric.cs b/src/Ocelot/Responses/OkResponseGeneric.cs index 7445d2d9..73fcf1e2 100644 --- a/src/Ocelot/Responses/OkResponseGeneric.cs +++ b/src/Ocelot/Responses/OkResponseGeneric.cs @@ -1,9 +1,11 @@ namespace Ocelot.Responses { +#pragma warning disable SA1649 // File name must match first type name public class OkResponse : Response +#pragma warning restore SA1649 // File name must match first type name { public OkResponse(T data) : base(data) { } } -} \ No newline at end of file +} diff --git a/src/Ocelot/Responses/ResponseGeneric.cs b/src/Ocelot/Responses/ResponseGeneric.cs index d06314bf..0b2514e9 100644 --- a/src/Ocelot/Responses/ResponseGeneric.cs +++ b/src/Ocelot/Responses/ResponseGeneric.cs @@ -3,7 +3,9 @@ using Ocelot.Errors; namespace Ocelot.Responses { +#pragma warning disable SA1649 // File name must match first type name public abstract class Response : Response +#pragma warning restore SA1649 // File name must match first type name { protected Response(T data) { diff --git a/test/Ocelot.UnitTests/Wait.cs b/test/Ocelot.UnitTests/Wait.cs new file mode 100644 index 00000000..d8fd3a88 --- /dev/null +++ b/test/Ocelot.UnitTests/Wait.cs @@ -0,0 +1,10 @@ +namespace Ocelot.UnitTests +{ + public class Wait + { + public static Waiter WaitFor(int milliSeconds) + { + return new Waiter(milliSeconds); + } + } +} \ No newline at end of file diff --git a/test/Ocelot.UnitTests/Waiter.cs b/test/Ocelot.UnitTests/Waiter.cs index 8fb51ae5..8847c5b9 100644 --- a/test/Ocelot.UnitTests/Waiter.cs +++ b/test/Ocelot.UnitTests/Waiter.cs @@ -3,14 +3,6 @@ using System.Diagnostics; namespace Ocelot.UnitTests { - public class Wait - { - public static Waiter WaitFor(int milliSeconds) - { - return new Waiter(milliSeconds); - } - } - public class Waiter { private readonly int _milliSeconds; @@ -52,4 +44,4 @@ namespace Ocelot.UnitTests return passed; } } -} \ No newline at end of file +} From 50980fda9391e0733fd1f8f962d0d45e07478d2f Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 14:08:52 +0000 Subject: [PATCH 10/11] Fix various violations SA1216, CS0105, CS0169, CS0414, CS0649 --- src/Ocelot/Raft/HttpPeer.cs | 3 ++- test/Ocelot.AcceptanceTests/AggregateTests.cs | 2 -- test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs | 5 ----- test/Ocelot.AcceptanceTests/Steps.cs | 8 -------- .../Authentication/AuthenticationMiddlewareTests.cs | 7 ------- .../Cache/OutputCacheMiddlewareRealCacheTests.cs | 8 -------- .../Claims/ClaimsBuilderMiddlewareTests.cs | 2 -- .../Configuration/ConsulFileConfigurationPollerTests.cs | 2 +- .../DependencyInjection/OcelotBuilderTests.cs | 1 - .../LoadBalancer/LoadBalancerHouseTests.cs | 2 -- .../LoadBalancer/LoadBalancerMiddlewareTests.cs | 6 ------ .../Middleware/OcelotPiplineBuilderTests.cs | 3 --- .../RequestId/ReRouteRequestIdMiddlewareTests.cs | 2 -- test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs | 1 - test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs | 1 - .../Responder/ErrorsToHttpStatusCodeMapperTests.cs | 2 +- .../Responder/ResponderMiddlewareTests.cs | 3 --- 17 files changed, 4 insertions(+), 54 deletions(-) diff --git a/src/Ocelot/Raft/HttpPeer.cs b/src/Ocelot/Raft/HttpPeer.cs index 34a94b27..cd5ceef5 100644 --- a/src/Ocelot/Raft/HttpPeer.cs +++ b/src/Ocelot/Raft/HttpPeer.cs @@ -89,7 +89,8 @@ namespace Ocelot.Raft } } - public Response Request(T command) where T : ICommand + public Response Request(T command) + where T : ICommand { if(_token == null) { diff --git a/test/Ocelot.AcceptanceTests/AggregateTests.cs b/test/Ocelot.AcceptanceTests/AggregateTests.cs index 8510fd1b..3944adfc 100644 --- a/test/Ocelot.AcceptanceTests/AggregateTests.cs +++ b/test/Ocelot.AcceptanceTests/AggregateTests.cs @@ -15,7 +15,6 @@ namespace Ocelot.AcceptanceTests public class AggregateTests : IDisposable { private IWebHost _serviceOneBuilder; - private IWebHost _serviceTwoBuilder; private readonly Steps _steps; private string _downstreamPathOne; private string _downstreamPathTwo; @@ -364,7 +363,6 @@ namespace Ocelot.AcceptanceTests public void Dispose() { _serviceOneBuilder?.Dispose(); - _serviceTwoBuilder?.Dispose(); _steps.Dispose(); } } diff --git a/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs b/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs index f6c77b1c..e555ade7 100644 --- a/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs +++ b/test/Ocelot.AcceptanceTests/CannotStartOcelotTests.cs @@ -1,18 +1,14 @@ using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Hosting; using Ocelot.Configuration.File; using Shouldly; -using TestStack.BDDfy; using Xunit; namespace Ocelot.AcceptanceTests { public class CannotStartOcelotTests : IDisposable { - private IWebHost _builder; private readonly Steps _steps; - private string _downstreamPath; public CannotStartOcelotTests() { @@ -50,7 +46,6 @@ namespace Ocelot.AcceptanceTests public void Dispose() { - _builder?.Dispose(); _steps.Dispose(); } } diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs index 09f68998..61a01059 100644 --- a/test/Ocelot.AcceptanceTests/Steps.cs +++ b/test/Ocelot.AcceptanceTests/Steps.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Net; @@ -19,15 +17,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Ocelot.Configuration.File; -using Ocelot.Configuration.Repository; using Ocelot.DependencyInjection; using Ocelot.Middleware; -using Ocelot.ServiceDiscovery; using Shouldly; using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder; using Ocelot.AcceptanceTests.Caching; -using Butterfly.Client.AspNetCore; -using Butterfly.Client.Tracing; namespace Ocelot.AcceptanceTests { @@ -42,11 +36,9 @@ namespace Ocelot.AcceptanceTests public string RequestIdKey = "OcRequestId"; private readonly Random _random; private IWebHostBuilder _webHostBuilder; - private readonly string _baseUrl; public Steps() { - _baseUrl = "http://localhost:5000"; _random = new Random(); } diff --git a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs index 1ab81895..e5cb64ae 100644 --- a/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Authentication/AuthenticationMiddlewareTests.cs @@ -6,24 +6,17 @@ namespace Ocelot.UnitTests.Authentication using System.Collections.Generic; using System.IO; using System.Text; - using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; - using Microsoft.Extensions.DependencyInjection; using Moq; using Ocelot.Authentication.Middleware; using Ocelot.Configuration.Builder; - using Ocelot.DownstreamRouteFinder; - using Ocelot.DownstreamRouteFinder.Middleware; - using Ocelot.DownstreamRouteFinder.UrlMatcher; using Ocelot.Logging; - using Ocelot.Responses; using Shouldly; using TestStack.BDDfy; using Xunit; public class AuthenticationMiddlewareTests { - private OkResponse _downstreamRoute; private AuthenticationMiddleware _middleware; private Mock _factory; private Mock _logger; diff --git a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs index 4e9ef04d..c0a76b2a 100644 --- a/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs +++ b/test/Ocelot.UnitTests/Cache/OutputCacheMiddlewareRealCacheTests.cs @@ -1,5 +1,4 @@ using Ocelot.Errors; -using Ocelot.Infrastructure.RequestData; using Ocelot.Middleware; namespace Ocelot.UnitTests.Cache @@ -11,26 +10,19 @@ namespace Ocelot.UnitTests.Cache using Shouldly; using System.Collections.Generic; using System.Net.Http; - using Microsoft.AspNetCore.Builder; - using Microsoft.Extensions.DependencyInjection; using Moq; using Ocelot.Cache; using Ocelot.Cache.Middleware; using Ocelot.Configuration; using Ocelot.Configuration.Builder; - using Ocelot.DownstreamRouteFinder; - using Ocelot.DownstreamRouteFinder.UrlMatcher; using Ocelot.Logging; - using Ocelot.Responses; using TestStack.BDDfy; using Xunit; - using Ocelot.DownstreamRouteFinder.Middleware; using Microsoft.AspNetCore.Http; public class OutputCacheMiddlewareRealCacheTests { private IOcelotCache _cacheManager; - private CachedResponse _response; private OutputCacheMiddleware _middleware; private DownstreamContext _downstreamContext; private OcelotRequestDelegate _next; diff --git a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs index 5b5e386c..f6bf052c 100644 --- a/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Claims/ClaimsBuilderMiddlewareTests.cs @@ -15,12 +15,10 @@ namespace Ocelot.UnitTests.Claims using Ocelot.Responses; using TestStack.BDDfy; using Xunit; - using Ocelot.DownstreamRouteFinder.Middleware; public class ClaimsBuilderMiddlewareTests { private readonly Mock _addHeaders; - private Response _downstreamRoute; private Mock _loggerFactory; private Mock _logger; private readonly ClaimsBuilderMiddleware _middleware; diff --git a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs index b743b598..4a6faba2 100644 --- a/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs +++ b/test/Ocelot.UnitTests/Configuration/ConsulFileConfigurationPollerTests.cs @@ -83,7 +83,7 @@ namespace Ocelot.UnitTests.Configuration _setter.Verify(x => x.Set(fileConfig), Times.Once); return true; } - catch(Exception ex) + catch(Exception) { return false; } diff --git a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs index 8ed1a327..c2f35990 100644 --- a/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs +++ b/test/Ocelot.UnitTests/DependencyInjection/OcelotBuilderTests.cs @@ -15,7 +15,6 @@ using Ocelot.DependencyInjection; using Ocelot.Requester; using Ocelot.UnitTests.Requester; using Shouldly; -using System; using IdentityServer4.AccessTokenValidation; using TestStack.BDDfy; using Xunit; diff --git a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs index 2a4d3a24..e8808f17 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerHouseTests.cs @@ -17,9 +17,7 @@ namespace Ocelot.UnitTests.LoadBalancer private DownstreamReRoute _reRoute; private ILoadBalancer _loadBalancer; private readonly LoadBalancerHouse _loadBalancerHouse; - private Response _addResult; private Response _getResult; - private string _key; private readonly Mock _factory; private ServiceProviderConfiguration _serviceProviderConfig; diff --git a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs index 0af8b3af..242463a2 100644 --- a/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/LoadBalancer/LoadBalancerMiddlewareTests.cs @@ -4,15 +4,10 @@ namespace Ocelot.UnitTests.LoadBalancer { using System.Collections.Generic; using System.Net.Http; - using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; - using Microsoft.Extensions.DependencyInjection; using Moq; using Ocelot.Configuration; using Ocelot.Configuration.Builder; - using Ocelot.Configuration.Provider; - using Ocelot.DownstreamRouteFinder; - using Ocelot.DownstreamRouteFinder.Middleware; using Ocelot.Errors; using Ocelot.LoadBalancer.LoadBalancers; using Ocelot.LoadBalancer.Middleware; @@ -28,7 +23,6 @@ namespace Ocelot.UnitTests.LoadBalancer private readonly Mock _loadBalancerHouse; private readonly Mock _loadBalancer; private ServiceHostAndPort _hostAndPort; - private OkResponse _downstreamRoute; private ErrorResponse _getLoadBalancerHouseError; private ErrorResponse _getHostAndPortError; private HttpRequestMessage _downstreamRequest; diff --git a/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs b/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs index dbb0ae63..988d0b21 100644 --- a/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs +++ b/test/Ocelot.UnitTests/Middleware/OcelotPiplineBuilderTests.cs @@ -1,6 +1,5 @@ namespace Ocelot.UnitTests.Middleware { - using System; using System.Collections.Generic; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Internal; @@ -17,9 +16,7 @@ public class OcelotPiplineBuilderTests { private readonly IServiceCollection _services; - private IServiceProvider _serviceProvider; private readonly IConfiguration _configRoot; - private IOcelotBuilder _ocelotBuilder; private DownstreamContext _downstreamContext; private int _counter; diff --git a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs index c49f2c6a..f6bf4eb7 100644 --- a/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/RequestId/ReRouteRequestIdMiddlewareTests.cs @@ -4,7 +4,6 @@ namespace Ocelot.UnitTests.RequestId { using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; - using Ocelot.DownstreamRouteFinder.Middleware; using Ocelot.Infrastructure.RequestData; using System; using System.Collections.Generic; @@ -24,7 +23,6 @@ namespace Ocelot.UnitTests.RequestId public class ReRouteRequestIdMiddlewareTests { private readonly HttpRequestMessage _downstreamRequest; - private Response _downstreamRoute; private string _value; private string _key; private Mock _loggerFactory; diff --git a/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs b/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs index b5d7e1e6..b788c826 100644 --- a/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs +++ b/test/Ocelot.UnitTests/Requester/HttpClientBuilderTests.cs @@ -17,7 +17,6 @@ namespace Ocelot.UnitTests.Requester private readonly HttpClientBuilder _builder; private readonly Mock _house; private readonly Mock _provider; - private IHttpClientBuilder _builderResult; private IHttpClient _httpClient; private HttpResponseMessage _response; private DownstreamReRoute _request; diff --git a/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs b/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs index f6095034..ae027143 100644 --- a/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs +++ b/test/Ocelot.UnitTests/Requester/QosProviderHouseTests.cs @@ -13,7 +13,6 @@ namespace Ocelot.UnitTests.Requester { private IQoSProvider _qoSProvider; private readonly QosProviderHouse _qosProviderHouse; - private Response _addResult; private Response _getResult; private DownstreamReRoute _reRoute; private readonly Mock _factory; diff --git a/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs b/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs index 977a0b12..9800ffef 100644 --- a/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs +++ b/test/Ocelot.UnitTests/Responder/ErrorsToHttpStatusCodeMapperTests.cs @@ -42,7 +42,7 @@ namespace Ocelot.UnitTests.Responder [InlineData(OcelotErrorCode.RequestTimedOutError)] public void should_return_service_unavailable(OcelotErrorCode errorCode) { - ShouldMapErrorToStatusCode(OcelotErrorCode.RequestTimedOutError, HttpStatusCode.ServiceUnavailable); + ShouldMapErrorToStatusCode(errorCode, HttpStatusCode.ServiceUnavailable); } [Theory] diff --git a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs index 28a0707a..54b795a2 100644 --- a/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs +++ b/test/Ocelot.UnitTests/Responder/ResponderMiddlewareTests.cs @@ -4,7 +4,6 @@ using Ocelot.Middleware; namespace Ocelot.UnitTests.Responder { using Microsoft.AspNetCore.Http; - using Ocelot.DownstreamRouteFinder.Middleware; using System.Net.Http; using Moq; using Ocelot.DownstreamRouteFinder.Finder; @@ -12,7 +11,6 @@ namespace Ocelot.UnitTests.Responder using Ocelot.Logging; using Ocelot.Responder; using Ocelot.Responder.Middleware; - using Ocelot.Responses; using TestStack.BDDfy; using Xunit; @@ -20,7 +18,6 @@ namespace Ocelot.UnitTests.Responder { private readonly Mock _responder; private readonly Mock _codeMapper; - private OkResponse _response; private Mock _loggerFactory; private Mock _logger; private readonly ResponderMiddleware _middleware; From 01fe4ef9aaf454744d35931c109bef9f4f1fdce5 Mon Sep 17 00:00:00 2001 From: Philip Wood Date: Sat, 3 Mar 2018 14:15:39 +0000 Subject: [PATCH 11/11] Turn off a few more rules --- Ocelot.sln | 1 + codeanalysis.ruleset | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Ocelot.sln b/Ocelot.sln index 6aa429fe..c9ac2782 100644 --- a/Ocelot.sln +++ b/Ocelot.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build-and-run-tests.ps1 = build-and-run-tests.ps1 build.cake = build.cake build.ps1 = build.ps1 + codeanalysis.ruleset = codeanalysis.ruleset GitVersion.yml = GitVersion.yml global.json = global.json LICENSE.md = LICENSE.md diff --git a/codeanalysis.ruleset b/codeanalysis.ruleset index e867f4e5..ee66e99d 100644 --- a/codeanalysis.ruleset +++ b/codeanalysis.ruleset @@ -99,6 +99,7 @@ + @@ -113,12 +114,14 @@ + +