mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 12:10:50 +08:00 
			
		
		
		
	Fix brace line spacing and remove multiple concurrent whitespace characters
SA1025, SA1505, SA1508, SA-1509, SA1513
This commit is contained in:
		@@ -47,7 +47,8 @@ namespace Ocelot.Authorisation
 | 
				
			|||||||
                        });
 | 
					                        });
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return new OkResponse<bool>(true);
 | 
					            return new OkResponse<bool>(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@ using Ocelot.Configuration.File;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.Cache
 | 
					namespace Ocelot.Cache
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public class RegionCreator : IRegionCreator
 | 
					    public class RegionCreator : IRegionCreator
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public string Create(FileReRoute reRoute)
 | 
					        public string Create(FileReRoute reRoute)
 | 
				
			||||||
@@ -21,4 +20,4 @@ namespace Ocelot.Cache
 | 
				
			|||||||
            return region;
 | 
					            return region;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@ namespace Ocelot.Cache
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            Value = value;
 | 
					            Value = value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<string> Value {get;private set;}
 | 
					        public List<string> Value {get;private set;}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,6 +39,7 @@ namespace Ocelot.Claims.Middleware
 | 
				
			|||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await _next.Invoke(context);
 | 
					            await _next.Invoke(context);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,7 @@
 | 
				
			|||||||
            Host = host;
 | 
					            Host = host;
 | 
				
			||||||
            Port = port;
 | 
					            Port = port;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string Host { get; private set; }
 | 
					        public string Host { get; private set; }
 | 
				
			||||||
        public int Port { get; private set; }
 | 
					        public int Port { get; private set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,4 @@ namespace Ocelot.Configuration.File
 | 
				
			|||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public int HttpStatusCode { get;  set; } = 429;
 | 
					        public int HttpStatusCode { get;  set; } = 429;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.Configuration.File
 | 
					namespace Ocelot.Configuration.File
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public class FileRateLimitRule
 | 
					    public class FileRateLimitRule
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public FileRateLimitRule()
 | 
					        public FileRateLimitRule()
 | 
				
			||||||
@@ -38,6 +37,7 @@ namespace Ocelot.Configuration.File
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                return string.Empty;
 | 
					                return string.Empty;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var sb = new StringBuilder();
 | 
					            var sb = new StringBuilder();
 | 
				
			||||||
            sb.Append(
 | 
					            sb.Append(
 | 
				
			||||||
                $"{nameof(Period)}:{Period},{nameof(PeriodTimespan)}:{PeriodTimespan:F},{nameof(Limit)}:{Limit},{nameof(ClientWhitelist)}:[");
 | 
					                $"{nameof(Period)}:{Period},{nameof(PeriodTimespan)}:{PeriodTimespan:F},{nameof(Limit)}:{Limit},{nameof(ClientWhitelist)}:[");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,5 @@ namespace Ocelot.Configuration
 | 
				
			|||||||
        public int TimeoutValue { get; private set; }
 | 
					        public int TimeoutValue { get; private set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public TimeoutStrategy TimeoutStrategy { get; private set; }
 | 
					        public TimeoutStrategy TimeoutStrategy { get; private set; }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,12 +9,12 @@ namespace Ocelot.Configuration
 | 
				
			|||||||
            IsCached = isCached;
 | 
					            IsCached = isCached;
 | 
				
			||||||
            IsQos = isQos;
 | 
					            IsQos = isQos;
 | 
				
			||||||
            EnableRateLimiting = isEnableRateLimiting;
 | 
					            EnableRateLimiting = isEnableRateLimiting;
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool IsAuthenticated { get; private set; }
 | 
					        public bool IsAuthenticated { get; private set; }
 | 
				
			||||||
        public bool IsAuthorised { get; private set; }
 | 
					        public bool IsAuthorised { get; private set; }
 | 
				
			||||||
        public bool IsCached { get; private set; }
 | 
					        public bool IsCached { get; private set; }
 | 
				
			||||||
        public bool IsQos { get; private set; }
 | 
					        public bool IsQos { get; private set; }
 | 
				
			||||||
        public bool EnableRateLimiting { get; private set; }
 | 
					        public bool EnableRateLimiting { get; private set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,6 @@ namespace Ocelot.Configuration.Repository
 | 
				
			|||||||
                _polling = true;
 | 
					                _polling = true;
 | 
				
			||||||
                await Poll();
 | 
					                await Poll();
 | 
				
			||||||
                _polling = false;
 | 
					                _polling = false;
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }, null, 0, 1000);
 | 
					            }, null, 0, 1000);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,6 @@ using Ocelot.ServiceDiscovery;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.Configuration.Repository
 | 
					namespace Ocelot.Configuration.Repository
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public class ConsulFileConfigurationRepository : IFileConfigurationRepository
 | 
					    public class ConsulFileConfigurationRepository : IFileConfigurationRepository
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        private readonly ConsulClient _consul;
 | 
					        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}"));
 | 
					            return new ErrorResponse(new UnableToSetConfigInConsulError($"Unable to set FileConfiguration in consul, response status code from consul was {result.StatusCode}"));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ namespace Ocelot.Configuration.Setter
 | 
				
			|||||||
        private readonly IOcelotConfigurationCreator _configCreator;
 | 
					        private readonly IOcelotConfigurationCreator _configCreator;
 | 
				
			||||||
        private readonly IFileConfigurationRepository _repo;
 | 
					        private readonly IFileConfigurationRepository _repo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public  FileConfigurationSetter(IOcelotConfigurationRepository configRepo, 
 | 
					        public FileConfigurationSetter(IOcelotConfigurationRepository configRepo, 
 | 
				
			||||||
            IOcelotConfigurationCreator configCreator, IFileConfigurationRepository repo)
 | 
					            IOcelotConfigurationCreator configCreator, IFileConfigurationRepository repo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _configRepo = configRepo;
 | 
					            _configRepo = configRepo;
 | 
				
			||||||
@@ -39,4 +39,4 @@ namespace Ocelot.Configuration.Setter
 | 
				
			|||||||
            return new ErrorResponse(config.Errors);
 | 
					            return new ErrorResponse(config.Errors);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,6 @@ namespace Ocelot.Configuration.Validator
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        public FileValidationFailedError(string message) : base(message, OcelotErrorCode.FileValidationFailedError)
 | 
					        public FileValidationFailedError(string message) : base(message, OcelotErrorCode.FileValidationFailedError)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,6 +67,7 @@ namespace Ocelot.Configuration.Validator
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var schemes = await _authenticationSchemeProvider.GetAllSchemesAsync();
 | 
					            var schemes = await _authenticationSchemeProvider.GetAllSchemesAsync();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var supportedSchemes = schemes.Select(scheme => scheme.Name).ToList();
 | 
					            var supportedSchemes = schemes.Select(scheme => scheme.Name).ToList();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
					            // 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
 | 
					            // could maybe use a scoped data repository
 | 
				
			||||||
            _services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();		
 | 
					            _services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
 | 
				
			||||||
            _services.TryAddSingleton<IRequestScopedDataRepository, HttpDataRepository>();
 | 
					            _services.TryAddSingleton<IRequestScopedDataRepository, HttpDataRepository>();
 | 
				
			||||||
            _services.AddMemoryCache();
 | 
					            _services.AddMemoryCache();
 | 
				
			||||||
            _services.TryAddSingleton<OcelotDiagnosticListener>();
 | 
					            _services.TryAddSingleton<OcelotDiagnosticListener>();
 | 
				
			||||||
@@ -154,7 +154,6 @@ namespace Ocelot.DependencyInjection
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            // We add this here so that we can always inject something into the factory for IoC..
 | 
					            // We add this here so that we can always inject something into the factory for IoC..
 | 
				
			||||||
            _services.AddSingleton<IServiceTracer, FakeServiceTracer>();
 | 
					            _services.AddSingleton<IServiceTracer, FakeServiceTracer>();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public IOcelotAdministrationBuilder AddAdministration(string path, string secret)
 | 
					        public IOcelotAdministrationBuilder AddAdministration(string path, string secret)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,8 @@ namespace Ocelot.DownstreamRouteFinder
 | 
				
			|||||||
            TemplatePlaceholderNameAndValues = templatePlaceholderNameAndValues;
 | 
					            TemplatePlaceholderNameAndValues = templatePlaceholderNameAndValues;
 | 
				
			||||||
            ReRoute = reRoute;
 | 
					            ReRoute = reRoute;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<PlaceholderNameAndValue> TemplatePlaceholderNameAndValues { get; private set; }
 | 
					        public List<PlaceholderNameAndValue> TemplatePlaceholderNameAndValues { get; private set; }
 | 
				
			||||||
        public ReRoute ReRoute { get; private set; }
 | 
					        public ReRoute ReRoute { get; private set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            Match = match; 
 | 
					            Match = match; 
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool Match {get;private set;}
 | 
					        public bool Match {get;private set;}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,8 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
 | 
				
			|||||||
            Name = name;
 | 
					            Name = name;
 | 
				
			||||||
            Value = value;
 | 
					            Value = value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string Name {get;private set;}
 | 
					        public string Name {get;private set;}
 | 
				
			||||||
        public string Value {get;private set;}
 | 
					        public string Value {get;private set;}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    counterForTemplate = endOfPlaceholder;
 | 
					                    counterForTemplate = endOfPlaceholder;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                counterForPath++;
 | 
					                counterForPath++;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -90,6 +91,7 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            return variableName;
 | 
					            return variableName;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private int GetNextCounterPosition(string urlTemplate, int counterForTemplate, char delimiter)
 | 
					        private int GetNextCounterPosition(string urlTemplate, int counterForTemplate, char delimiter)
 | 
				
			||||||
        {                        
 | 
					        {                        
 | 
				
			||||||
            var closingPlaceHolderPositionOnTemplate = urlTemplate.IndexOf(delimiter, counterForTemplate);
 | 
					            var closingPlaceHolderPositionOnTemplate = urlTemplate.IndexOf(delimiter, counterForTemplate);
 | 
				
			||||||
@@ -111,4 +113,4 @@ namespace Ocelot.DownstreamRouteFinder.UrlMatcher
 | 
				
			|||||||
            return character == '{';
 | 
					            return character == '{';
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -100,6 +100,7 @@ namespace Ocelot.Errors.Middleware
 | 
				
			|||||||
                message =
 | 
					                message =
 | 
				
			||||||
                    $"{message}, inner exception message {e.InnerException.Message}, inner exception stack {e.InnerException.StackTrace}";
 | 
					                    $"{message}, inner exception message {e.InnerException.Message}, inner exception stack {e.InnerException.StackTrace}";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return $"{message} RequestId: {context.HttpContext.TraceIdentifier}";
 | 
					            return $"{message} RequestId: {context.HttpContext.TraceIdentifier}";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,6 +26,7 @@ namespace Ocelot.Headers
 | 
				
			|||||||
                return $"{downstreamUrl}/";
 | 
					                return $"{downstreamUrl}/";
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Response Replace(HttpResponseMessage response, List<HeaderFindAndReplace> fAndRs, HttpRequestMessage httpRequestMessage)
 | 
					        public Response Replace(HttpResponseMessage response, List<HeaderFindAndReplace> fAndRs, HttpRequestMessage httpRequestMessage)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            foreach (var f in fAndRs)
 | 
					            foreach (var f in fAndRs)
 | 
				
			||||||
@@ -54,4 +55,4 @@ namespace Ocelot.Headers
 | 
				
			|||||||
            return new OkResponse();
 | 
					            return new OkResponse();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
 | 
				
			|||||||
            HostAndPort = hostAndPort;
 | 
					            HostAndPort = hostAndPort;
 | 
				
			||||||
            Connections = connections;
 | 
					            Connections = connections;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public ServiceHostAndPort HostAndPort { get; private set; }
 | 
					        public ServiceHostAndPort HostAndPort { get; private set; }
 | 
				
			||||||
        public int Connections { get; private set; }
 | 
					        public int Connections { get; private set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ namespace Ocelot.Logging
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        IOcelotLogger CreateLogger<T>();
 | 
					        IOcelotLogger CreateLogger<T>();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
    /// Thin wrapper around the DotNet core logging framework, used to allow the scopedDataRepository to be injected giving access to the Ocelot RequestId
 | 
					    /// Thin wrapper around the DotNet core logging framework, used to allow the scopedDataRepository to be injected giving access to the Ocelot RequestId
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,6 @@
 | 
				
			|||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// This allows the user to implement there own query string manipulation logic
 | 
					        /// This allows the user to implement there own query string manipulation logic
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public Func<DownstreamContext, Func<Task>, Task> PreQueryStringBuilderMiddleware { get; set; }
 | 
					        public Func<DownstreamContext, Func<Task>, Task> PreQueryStringBuilderMiddleware { get; set; }        
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,8 @@ namespace Ocelot.Raft
 | 
				
			|||||||
        public FakeCommand(string value)
 | 
					        public FakeCommand(string value)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.Value = value;
 | 
					            this.Value = value;
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string Value { get; private set; }
 | 
					        public string Value { get; private set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,6 +37,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                _peers.Add(httpPeer);
 | 
					                _peers.Add(httpPeer);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<IPeer> Get()
 | 
					        public List<IPeer> Get()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return _peers;
 | 
					            return _peers;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            _identityServerConfiguration = identityServerConfiguration;
 | 
					            _identityServerConfiguration = identityServerConfiguration;
 | 
				
			||||||
            _config = config;
 | 
					            _config = config;
 | 
				
			||||||
            Id  = hostAndPort;
 | 
					            Id = hostAndPort;
 | 
				
			||||||
            _hostAndPort = hostAndPort;
 | 
					            _hostAndPort = hostAndPort;
 | 
				
			||||||
            _httpClient = httpClient;
 | 
					            _httpClient = httpClient;
 | 
				
			||||||
            _jsonSerializerSettings = new JsonSerializerSettings() { 
 | 
					            _jsonSerializerSettings = new JsonSerializerSettings() { 
 | 
				
			||||||
@@ -68,6 +68,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    SetToken();
 | 
					                    SetToken();
 | 
				
			||||||
                }                
 | 
					                }                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var json = JsonConvert.SerializeObject(appendEntries, _jsonSerializerSettings);
 | 
					                var json = JsonConvert.SerializeObject(appendEntries, _jsonSerializerSettings);
 | 
				
			||||||
                var content = new StringContent(json);
 | 
					                var content = new StringContent(json);
 | 
				
			||||||
                content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
 | 
					                content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
 | 
				
			||||||
@@ -94,6 +95,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                SetToken();
 | 
					                SetToken();
 | 
				
			||||||
            }   
 | 
					            }   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var json = JsonConvert.SerializeObject(command, _jsonSerializerSettings);
 | 
					            var json = JsonConvert.SerializeObject(command, _jsonSerializerSettings);
 | 
				
			||||||
            var content = new StringContent(json);
 | 
					            var content = new StringContent(json);
 | 
				
			||||||
            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
 | 
					            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                    FileStream fs = File.Create(_path);
 | 
					                    FileStream fs = File.Create(_path);
 | 
				
			||||||
                    fs.Dispose();
 | 
					                    fs.Dispose();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                using(var connection = new SqliteConnection($"Data Source={_path};"))
 | 
					                using(var connection = new SqliteConnection($"Data Source={_path};"))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    connection.Open();
 | 
					                    connection.Open();
 | 
				
			||||||
@@ -59,6 +60,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return result;
 | 
					                    return result;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -88,6 +90,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return result;
 | 
					                    return result;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -113,6 +116,7 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return result;
 | 
					                    return result;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -222,15 +226,13 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                                };
 | 
					                                };
 | 
				
			||||||
                                var log = JsonConvert.DeserializeObject<LogEntry>(data, jsonSerializerSettings);
 | 
					                                var log = JsonConvert.DeserializeObject<LogEntry>(data, jsonSerializerSettings);
 | 
				
			||||||
                                logsToReturn.Add((id, log));
 | 
					                                logsToReturn.Add((id, log));
 | 
				
			||||||
 | 
					 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return logsToReturn;
 | 
					                return logsToReturn;
 | 
				
			||||||
            }
 | 
					            }        
 | 
				
			||||||
          
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public long GetTermAtIndex(int index)
 | 
					        public long GetTermAtIndex(int index)
 | 
				
			||||||
@@ -256,9 +258,11 @@ namespace Ocelot.Raft
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return result;
 | 
					                return result;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void Remove(int indexOfCommand)
 | 
					        public void Remove(int indexOfCommand)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            lock(_lock)
 | 
					            lock(_lock)
 | 
				
			||||||
@@ -276,4 +280,4 @@ namespace Ocelot.Raft
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,6 @@ using System.Threading.Tasks;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.RateLimit
 | 
					namespace Ocelot.RateLimit
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public class ClientRateLimitProcessor
 | 
					    public class ClientRateLimitProcessor
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        private readonly IRateLimitCounterHandler _counterHandler;
 | 
					        private readonly IRateLimitCounterHandler _counterHandler;
 | 
				
			||||||
@@ -39,7 +38,5 @@ namespace Ocelot.RateLimit
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            return _core.ConvertToTimeSpan(timeSpan);
 | 
					            return _core.ConvertToTimeSpan(timeSpan);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,7 @@ namespace Ocelot.RateLimit
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                return JsonConvert.DeserializeObject<RateLimitCounter>(stored);
 | 
					                return JsonConvert.DeserializeObject<RateLimitCounter>(stored);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,7 @@ namespace Ocelot.RateLimit.Middleware
 | 
				
			|||||||
                await _next.Invoke(context);
 | 
					                await _next.Invoke(context);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // compute identity from request
 | 
					            // compute identity from request
 | 
				
			||||||
            var identity = SetIdentity(context.HttpContext, options);
 | 
					            var identity = SetIdentity(context.HttpContext, options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,8 +71,8 @@ namespace Ocelot.RateLimit.Middleware
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //set X-Rate-Limit headers for the longest period
 | 
					            //set X-Rate-Limit headers for the longest period
 | 
				
			||||||
            if (!options.DisableRateLimitHeaders)
 | 
					            if (!options.DisableRateLimitHeaders)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -103,6 +104,7 @@ namespace Ocelot.RateLimit.Middleware
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -134,8 +136,5 @@ namespace Ocelot.RateLimit.Middleware
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            return Task.CompletedTask;
 | 
					            return Task.CompletedTask;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,6 +62,7 @@ namespace Ocelot.RateLimit
 | 
				
			|||||||
                var expirationTime = ConvertToTimeSpan(rule.Period);
 | 
					                var expirationTime = ConvertToTimeSpan(rule.Period);
 | 
				
			||||||
                _counterHandler.Set(counterId, counter, expirationTime);
 | 
					                _counterHandler.Set(counterId, counter, expirationTime);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return counter;
 | 
					            return counter;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -92,7 +93,6 @@ namespace Ocelot.RateLimit
 | 
				
			|||||||
                    rule.Period,
 | 
					                    rule.Period,
 | 
				
			||||||
                    rule.Limit.ToString(),
 | 
					                    rule.Limit.ToString(),
 | 
				
			||||||
                    (DateTime.UtcNow + ConvertToTimeSpan(rule.Period)).ToUniversalTime().ToString("o", DateTimeFormatInfo.InvariantInfo));
 | 
					                    (DateTime.UtcNow + ConvertToTimeSpan(rule.Period)).ToUniversalTime().ToString("o", DateTimeFormatInfo.InvariantInfo));
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return headers;
 | 
					            return headers;
 | 
				
			||||||
@@ -141,7 +141,6 @@ namespace Ocelot.RateLimit
 | 
				
			|||||||
                default:
 | 
					                default:
 | 
				
			||||||
                    throw new FormatException($"{timeSpan} can't be converted to TimeSpan, unknown type {type}");
 | 
					                    throw new FormatException($"{timeSpan} can't be converted to TimeSpan, unknown type {type}");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }  
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,7 +55,6 @@ namespace Ocelot.Requester
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                _cacheHandlers.Set(cacheKey, httpClient, TimeSpan.FromHours(24));
 | 
					                _cacheHandlers.Set(cacheKey, httpClient, TimeSpan.FromHours(24));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private IHttpClient GetHttpClient(string cacheKey, IHttpClientBuilder builder, DownstreamContext request)
 | 
					        private IHttpClient GetHttpClient(string cacheKey, IHttpClientBuilder builder, DownstreamContext request)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,7 @@ namespace Ocelot.Requester
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                connectionQueue.TryDequeue(out client);
 | 
					                connectionQueue.TryDequeue(out client);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return client;
 | 
					            return client;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ namespace Ocelot.Requester
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                request.Headers.Remove(prefix_spanId);
 | 
					                request.Headers.Remove(prefix_spanId);
 | 
				
			||||||
                request.Headers.TryAddWithoutValidation(prefix_spanId, span.SpanContext.SpanId);
 | 
					                request.Headers.TryAddWithoutValidation(prefix_spanId, span.SpanContext.SpanId);
 | 
				
			||||||
            };
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            span.Tags.Client().Component("HttpClient")
 | 
					            span.Tags.Client().Component("HttpClient")
 | 
				
			||||||
                .HttpMethod(request.Method.Method)
 | 
					                .HttpMethod(request.Method.Method)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,7 +50,6 @@ namespace Ocelot.Responder
 | 
				
			|||||||
                httpContext.Response.StatusCode = (int)response.StatusCode;
 | 
					                httpContext.Response.StatusCode = (int)response.StatusCode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return Task.CompletedTask;
 | 
					                return Task.CompletedTask;
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }, context);
 | 
					            }, context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            using (Stream stream = new MemoryStream(content))
 | 
					            using (Stream stream = new MemoryStream(content))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,6 @@ namespace Ocelot.Responder.Middleware
 | 
				
			|||||||
            _responder = responder;
 | 
					            _responder = responder;
 | 
				
			||||||
            _codeMapper = codeMapper;
 | 
					            _codeMapper = codeMapper;
 | 
				
			||||||
            _logger = loggerFactory.CreateLogger<ResponderMiddleware>();
 | 
					            _logger = loggerFactory.CreateLogger<ResponderMiddleware>();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async Task Invoke(DownstreamContext context)
 | 
					        public async Task Invoke(DownstreamContext context)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,8 +8,9 @@ namespace Ocelot.Responses
 | 
				
			|||||||
        public ErrorResponse(Error error) : base(new List<Error>{error})
 | 
					        public ErrorResponse(Error error) : base(new List<Error>{error})
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public ErrorResponse(List<Error> errors) : base(errors)
 | 
					        public ErrorResponse(List<Error> errors) : base(errors)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,12 +7,12 @@ namespace Ocelot.Responses
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        public ErrorResponse(Error error) 
 | 
					        public ErrorResponse(Error error) 
 | 
				
			||||||
            : base(new List<Error> {error})
 | 
					            : base(new List<Error> {error})
 | 
				
			||||||
        {
 | 
					        {            
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public ErrorResponse(List<Error> errors) 
 | 
					        public ErrorResponse(List<Error> errors) 
 | 
				
			||||||
            : base(errors)
 | 
					            : base(errors)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,6 @@ namespace Ocelot.Responses
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public T Data { get; private set; }
 | 
					        public T Data { get; private set; }        
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
} 
 | 
					} 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ namespace Ocelot.ServiceDiscovery
 | 
				
			|||||||
            _factory = factory;
 | 
					            _factory = factory;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public  IServiceDiscoveryProvider Get(ServiceProviderConfiguration serviceConfig, DownstreamReRoute reRoute)
 | 
					        public IServiceDiscoveryProvider Get(ServiceProviderConfiguration serviceConfig, DownstreamReRoute reRoute)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (reRoute.UseServiceDiscovery)
 | 
					            if (reRoute.UseServiceDiscovery)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@ namespace Ocelot.Values
 | 
				
			|||||||
            Version = version;
 | 
					            Version = version;
 | 
				
			||||||
            Tags = tags;
 | 
					            Tags = tags;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string Id { get; private set; }
 | 
					        public string Id { get; private set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string Name { get; private set; }
 | 
					        public string Name { get; private set; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -177,7 +177,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                           AuthenticationOptions = new FileAuthenticationOptions
 | 
					                           AuthenticationOptions = new FileAuthenticationOptions
 | 
				
			||||||
                           {
 | 
					                           {
 | 
				
			||||||
                               AuthenticationProviderKey = "Test",
 | 
					                               AuthenticationProviderKey = "Test",
 | 
				
			||||||
                               AllowedScopes =  new List<string>{ "api", "api.readOnly", "openid", "offline_access" },
 | 
					                               AllowedScopes = new List<string>{ "api", "api.readOnly", "openid", "offline_access" },
 | 
				
			||||||
                           },
 | 
					                           },
 | 
				
			||||||
                       }
 | 
					                       }
 | 
				
			||||||
                   }
 | 
					                   }
 | 
				
			||||||
@@ -218,7 +218,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                           AuthenticationOptions = new FileAuthenticationOptions
 | 
					                           AuthenticationOptions = new FileAuthenticationOptions
 | 
				
			||||||
                           {
 | 
					                           {
 | 
				
			||||||
                               AuthenticationProviderKey = "Test",
 | 
					                               AuthenticationProviderKey = "Test",
 | 
				
			||||||
                               AllowedScopes =  new List<string>{ "api", "openid", "offline_access" },
 | 
					                               AllowedScopes = new List<string>{ "api", "openid", "offline_access" },
 | 
				
			||||||
                           },
 | 
					                           },
 | 
				
			||||||
                       }
 | 
					                       }
 | 
				
			||||||
                   }
 | 
					                   }
 | 
				
			||||||
@@ -356,7 +356,6 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                                    "CustomerId", "LocationId", "UserType", "UserId"
 | 
					                                    "CustomerId", "LocationId", "UserType", "UserId"
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            },
 | 
					                            },
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
                        .AddInMemoryClients(new List<Client>
 | 
					                        .AddInMemoryClients(new List<Client>
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
@@ -437,7 +436,6 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                                    "CustomerId", "LocationId", "UserType", "UserId", "Role"
 | 
					                                    "CustomerId", "LocationId", "UserType", "UserId", "Role"
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            },
 | 
					                            },
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
                        .AddInMemoryClients(new List<Client>
 | 
					                        .AddInMemoryClients(new List<Client>
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
@@ -450,7 +448,6 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                                AccessTokenType = tokenType,
 | 
					                                AccessTokenType = tokenType,
 | 
				
			||||||
                                Enabled = true,
 | 
					                                Enabled = true,
 | 
				
			||||||
                                RequireClientSecret = false,
 | 
					                                RequireClientSecret = false,
 | 
				
			||||||
 | 
					 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        })
 | 
					                        })
 | 
				
			||||||
                        .AddTestUsers(users);
 | 
					                        .AddTestUsers(users);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,7 +52,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
					                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
				
			||||||
                            HttpHandlerOptions = new FileHttpHandlerOptions
 | 
					                            HttpHandlerOptions = new FileHttpHandlerOptions
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                UseTracing  = true
 | 
					                                UseTracing = true
 | 
				
			||||||
                            },
 | 
					                            },
 | 
				
			||||||
                            QoSOptions = new FileQoSOptions
 | 
					                            QoSOptions = new FileQoSOptions
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
@@ -77,7 +77,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
					                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
				
			||||||
                            HttpHandlerOptions = new FileHttpHandlerOptions
 | 
					                            HttpHandlerOptions = new FileHttpHandlerOptions
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                UseTracing  = true
 | 
					                                UseTracing = true
 | 
				
			||||||
                            },
 | 
					                            },
 | 
				
			||||||
                            QoSOptions = new FileQoSOptions
 | 
					                            QoSOptions = new FileQoSOptions
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,7 +156,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            new ApiResource
 | 
					                            new ApiResource
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
								Name = apiName,
 | 
					                                Name = apiName,
 | 
				
			||||||
                                Description = "My API",
 | 
					                                Description = "My API",
 | 
				
			||||||
                                Enabled = true,
 | 
					                                Enabled = true,
 | 
				
			||||||
                                DisplayName = "test",
 | 
					                                DisplayName = "test",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,7 +56,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
					                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
				
			||||||
                            RequestIdKey = _steps.RequestIdKey,
 | 
					                            RequestIdKey = _steps.RequestIdKey,
 | 
				
			||||||
                             
 | 
					                             
 | 
				
			||||||
                            RateLimitOptions =    new FileRateLimitRule()
 | 
					                            RateLimitOptions = new FileRateLimitRule()
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                EnableRateLimiting = true,
 | 
					                                EnableRateLimiting = true,
 | 
				
			||||||
                                ClientWhitelist = new List<string>(),
 | 
					                                ClientWhitelist = new List<string>(),
 | 
				
			||||||
@@ -75,7 +75,6 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                        QuotaExceededMessage = "",
 | 
					                        QuotaExceededMessage = "",
 | 
				
			||||||
                        RateLimitCounterPrefix = "",
 | 
					                        RateLimitCounterPrefix = "",
 | 
				
			||||||
                         HttpStatusCode = 428
 | 
					                         HttpStatusCode = 428
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                     RequestIdKey ="oceclientrequest"
 | 
					                     RequestIdKey ="oceclientrequest"
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -117,7 +116,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
					                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
				
			||||||
                            RequestIdKey = _steps.RequestIdKey,
 | 
					                            RequestIdKey = _steps.RequestIdKey,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            RateLimitOptions =    new FileRateLimitRule()
 | 
					                            RateLimitOptions = new FileRateLimitRule()
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                EnableRateLimiting = true,
 | 
					                                EnableRateLimiting = true,
 | 
				
			||||||
                                ClientWhitelist = new List<string>() { "ocelotclient1"},
 | 
					                                ClientWhitelist = new List<string>() { "ocelotclient1"},
 | 
				
			||||||
@@ -172,7 +171,5 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            _builder.Start();
 | 
					            _builder.Start();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -352,7 +352,6 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                    app.UsePathBase(basePath);
 | 
					                    app.UsePathBase(basePath);
 | 
				
			||||||
                    app.Run(context =>
 | 
					                    app.Run(context =>
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if(string.IsNullOrEmpty(basePath))
 | 
					                        if(string.IsNullOrEmpty(basePath))
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            context.Response.StatusCode = statusCode;
 | 
					                            context.Response.StatusCode = statusCode;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,8 +70,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        class FakeHandler : DelegatingHandler
 | 
					        class FakeHandler : DelegatingHandler
 | 
				
			||||||
        {
 | 
					        {  
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
            public DateTime TimeCalled { get; private set; }
 | 
					            public DateTime TimeCalled { get; private set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 | 
					            protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 | 
				
			||||||
@@ -111,6 +110,5 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            _builder.Start();
 | 
					            _builder.Start();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -159,8 +159,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                        catch (System.Exception exception)
 | 
					                        catch (System.Exception exception)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            await context.Response.WriteAsync(exception.StackTrace);
 | 
					                            await context.Response.WriteAsync(exception.StackTrace);
 | 
				
			||||||
                        }
 | 
					                        }                   
 | 
				
			||||||
                   
 | 
					 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .Build();
 | 
					                .Build();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,8 +51,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                            ExceptionsAllowedBeforeBreaking = 1,
 | 
					                            ExceptionsAllowedBeforeBreaking = 1,
 | 
				
			||||||
                            TimeoutValue = 500,
 | 
					                            TimeoutValue = 500,
 | 
				
			||||||
                            DurationOfBreak = 1000
 | 
					                            DurationOfBreak = 1000
 | 
				
			||||||
                        },
 | 
					                        },                        
 | 
				
			||||||
                        
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -359,8 +359,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
                        catch (System.Exception exception)
 | 
					                        catch (System.Exception exception)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            await context.Response.WriteAsync(exception.StackTrace);
 | 
					                            await context.Response.WriteAsync(exception.StackTrace);
 | 
				
			||||||
                        }
 | 
					                        }                  
 | 
				
			||||||
                   
 | 
					 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .Build();
 | 
					                .Build();
 | 
				
			||||||
@@ -406,4 +405,4 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
            _steps.Dispose();
 | 
					            _steps.Dispose();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -144,6 +144,7 @@ namespace Ocelot.AcceptanceTests
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            _ocelotClient = _ocelotServer.CreateClient();
 | 
					            _ocelotClient = _ocelotServer.CreateClient();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
        public void GivenIHaveAddedXForwardedForHeader(string value)
 | 
					        public void GivenIHaveAddedXForwardedForHeader(string value)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,6 @@ namespace Ocelot.Benchmarks
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var switcher = new BenchmarkSwitcher(new[] {
 | 
					            var switcher = new BenchmarkSwitcher(new[] {
 | 
				
			||||||
                   typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
 | 
					                   typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
 | 
				
			||||||
 | 
					 | 
				
			||||||
               });
 | 
					               });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switcher.Run(args);
 | 
					            switcher.Run(args);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -124,7 +124,6 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        Host = "127.0.0.1",
 | 
					                        Host = "127.0.0.1",
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                ReRoutes = new List<FileReRoute>()
 | 
					                ReRoutes = new List<FileReRoute>()
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,6 +45,7 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
            _builders = new List<IWebHost>();
 | 
					            _builders = new List<IWebHost>();
 | 
				
			||||||
            _threads = new List<Thread>();
 | 
					            _threads = new List<Thread>();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void Dispose()
 | 
					        public void Dispose()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            foreach (var builder in _builders)
 | 
					            foreach (var builder in _builders)
 | 
				
			||||||
@@ -194,7 +195,6 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
            var stopwatch = Stopwatch.StartNew();
 | 
					            var stopwatch = Stopwatch.StartNew();
 | 
				
			||||||
            while(stopwatch.ElapsedMilliseconds < 10000)
 | 
					            while(stopwatch.ElapsedMilliseconds < 10000)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -204,10 +204,9 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
            var stopwatch = Stopwatch.StartNew();
 | 
					            var stopwatch = Stopwatch.StartNew();
 | 
				
			||||||
            while(stopwatch.ElapsedMilliseconds < 2000)
 | 
					            while(stopwatch.ElapsedMilliseconds < 2000)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
             bool CommandCalledOnAllStateMachines()
 | 
					            bool CommandCalledOnAllStateMachines()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@@ -225,6 +224,7 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
                                index.ShouldBe(1);
 | 
					                                index.ShouldBe(1);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        _httpClientForAssertions.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken);
 | 
					                        _httpClientForAssertions.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken);
 | 
				
			||||||
                        var result = _httpClientForAssertions.GetAsync($"{peer.HostAndPort}/administration/configuration").Result;
 | 
					                        var result = _httpClientForAssertions.GetAsync($"{peer.HostAndPort}/administration/configuration").Result;
 | 
				
			||||||
                        var json = result.Content.ReadAsStringAsync().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].UpstreamPathTemplate.ShouldBe(expecteds.Configuration.ReRoutes[i].UpstreamPathTemplate);
 | 
				
			||||||
                            response.ReRoutes[i].UpstreamHttpMethod.ShouldBe(expecteds.Configuration.ReRoutes[i].UpstreamHttpMethod);
 | 
					                            response.ReRoutes[i].UpstreamHttpMethod.ShouldBe(expecteds.Configuration.ReRoutes[i].UpstreamHttpMethod);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        passed++;
 | 
					                        passed++;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -384,7 +385,6 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
            var stopwatch = Stopwatch.StartNew();
 | 
					            var stopwatch = Stopwatch.StartNew();
 | 
				
			||||||
            while(stopwatch.ElapsedMilliseconds < 20000)
 | 
					            while(stopwatch.ElapsedMilliseconds < 20000)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -195,6 +195,7 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
                result.Result.ShouldBe(result.Random);
 | 
					                result.Result.ShouldBe(result.Random);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void Dispose()
 | 
					        public void Dispose()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _builder?.Dispose();
 | 
					            _builder?.Dispose();
 | 
				
			||||||
@@ -208,7 +209,6 @@ namespace Ocelot.IntegrationTests
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                Result = result;
 | 
					                Result = result;
 | 
				
			||||||
                Random = random;
 | 
					                Random = random;
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            public int Result { get; private set; }
 | 
					            public int Result { get; private set; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ namespace Ocelot.UnitTests.Authentication
 | 
				
			|||||||
                .BDDfy();
 | 
					                .BDDfy();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private  void WhenICallTheMiddleware()
 | 
					        private void WhenICallTheMiddleware()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _next = async (context) => {
 | 
					            _next = async (context) => {
 | 
				
			||||||
                byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
 | 
					                byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
 | 
				
			||||||
@@ -89,7 +89,7 @@ namespace Ocelot.UnitTests.Authentication
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                string text = reader.ReadToEnd();
 | 
					                string text = reader.ReadToEnd();
 | 
				
			||||||
                return text;
 | 
					                return text;
 | 
				
			||||||
            };
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,6 @@ namespace Ocelot.UnitTests.Authorization
 | 
				
			|||||||
            this.Given(x => x.GivenAClaimsPrincipal(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
 | 
					            this.Given(x => x.GivenAClaimsPrincipal(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    new Claim("UserType", "registered"),
 | 
					                    new Claim("UserType", "registered"),
 | 
				
			||||||
 | 
					 | 
				
			||||||
                }))))
 | 
					                }))))
 | 
				
			||||||
                .And(x => x.GivenARouteClaimsRequirement(new Dictionary<string, string>
 | 
					                .And(x => x.GivenARouteClaimsRequirement(new Dictionary<string, string>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -110,7 +110,6 @@ namespace Ocelot.UnitTests.Cache
 | 
				
			|||||||
        private void GivenThereAreNoErrors()
 | 
					        private void GivenThereAreNoErrors()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _downstreamContext.Errors = new List<Error>();
 | 
					            _downstreamContext.Errors = new List<Error>();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void ThenTheCacheGetIsCalledCorrectly()
 | 
					        private void ThenTheCacheGetIsCalledCorrectly()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,7 +129,6 @@ namespace Ocelot.UnitTests.Claims
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void ThenTheResultIsError()
 | 
					        private void ThenTheResultIsError()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            _result.IsError.ShouldBe(true);
 | 
					            _result.IsError.ShouldBe(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,6 +79,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            _result.Count.ShouldBeGreaterThan(0);
 | 
					            _result.Count.ShouldBeGreaterThan(0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void GivenTheFollowingDictionary(Dictionary<string,string> claimsToThings)
 | 
					        private void GivenTheFollowingDictionary(Dictionary<string,string> claimsToThings)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _claimsToThings = claimsToThings;
 | 
					            _claimsToThings = claimsToThings;
 | 
				
			||||||
@@ -107,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
                .Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once);
 | 
					                .Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -981,7 +981,8 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
                 .And(x => x.ThenTheErrorMessageAtPositionIs(0, "When not using service discovery DownstreamHostAndPorts must be set and not empty or Ocelot cannot find your service!"))
 | 
					                 .And(x => x.ThenTheErrorMessageAtPositionIs(0, "When not using service discovery DownstreamHostAndPorts must be set and not empty or Ocelot cannot find your service!"))
 | 
				
			||||||
                .BDDfy();
 | 
					                .BDDfy();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
         [Fact]
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
        public void configuration_is_not_valid_when_host_and_port_is_empty()
 | 
					        public void configuration_is_not_valid_when_host_and_port_is_empty()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.Given(x => x.GivenAConfiguration(new FileConfiguration
 | 
					            this.Given(x => x.GivenAConfiguration(new FileConfiguration
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
            _repo.Setup(x => x.Get()).ReturnsAsync(new OkResponse<FileConfiguration>(_fileConfig));
 | 
					            _repo.Setup(x => x.Get()).ReturnsAsync(new OkResponse<FileConfiguration>(_fileConfig));
 | 
				
			||||||
            _poller = new ConsulFileConfigurationPoller(_factory.Object, _repo.Object, _setter.Object);
 | 
					            _poller = new ConsulFileConfigurationPoller(_factory.Object, _repo.Object, _setter.Object);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void Dispose()
 | 
					        public void Dispose()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _poller.Dispose();
 | 
					            _poller.Dispose();
 | 
				
			||||||
@@ -49,7 +50,6 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void should_call_setter_when_gets_new_config()
 | 
					        public void should_call_setter_when_gets_new_config()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            var newConfig = new FileConfiguration {
 | 
					            var newConfig = new FileConfiguration {
 | 
				
			||||||
                ReRoutes = new List<FileReRoute>
 | 
					                ReRoutes = new List<FileReRoute>
 | 
				
			||||||
                {   
 | 
					                {   
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -823,8 +823,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
                result.DownstreamReRoute[0].ClaimsToClaims.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToClaims.Count);
 | 
					                result.DownstreamReRoute[0].ClaimsToClaims.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToClaims.Count);
 | 
				
			||||||
                result.DownstreamReRoute[0].ClaimsToHeaders.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToHeaders.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].ClaimsToQueries.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToQueries.Count);
 | 
				
			||||||
                result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);
 | 
					                result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);           
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -111,7 +111,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void  GivenTheConfigurationIs(FileConfiguration fileConfiguration)
 | 
					        private void GivenTheConfigurationIs(FileConfiguration fileConfiguration)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var configurationPath = $"{AppContext.BaseDirectory}/configuration{(string.IsNullOrEmpty(_environmentName) ? string.Empty : ".")}{_environmentName}.json";
 | 
					            var configurationPath = $"{AppContext.BaseDirectory}/configuration{(string.IsNullOrEmpty(_environmentName) ? string.Empty : ".")}{_environmentName}.json";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,13 +33,11 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
                UpstreamHeaderTransform = new Dictionary<string, string>
 | 
					                UpstreamHeaderTransform = new Dictionary<string, string>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    {"Test", "Test, Chicken"},
 | 
					                    {"Test", "Test, Chicken"},
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    {"Moop", "o, a"}
 | 
					                    {"Moop", "o, a"}
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                 DownstreamHeaderTransform = new Dictionary<string, string>
 | 
					                 DownstreamHeaderTransform = new Dictionary<string, string>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    {"Pop", "West, East"},
 | 
					                    {"Pop", "West, East"},
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    {"Bop", "e, r"}
 | 
					                    {"Bop", "e, r"}
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
@@ -155,4 +153,4 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,6 @@ using Xunit;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Ocelot.UnitTests.Configuration
 | 
					namespace Ocelot.UnitTests.Configuration
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public class HttpHandlerOptionsCreatorTests
 | 
					    public class HttpHandlerOptionsCreatorTests
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;
 | 
					        private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,7 +70,7 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void should_create_template_pattern_that_matches_anything_to_end_of_string()
 | 
					        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}",
 | 
					                UpstreamPathTemplate = "/api/products/{productId}",
 | 
				
			||||||
                ReRouteIsCaseSensitive = true
 | 
					                ReRouteIsCaseSensitive = true
 | 
				
			||||||
@@ -181,4 +181,4 @@ namespace Ocelot.UnitTests.Configuration
 | 
				
			|||||||
            _result.Priority.ShouldBe(v);
 | 
					            _result.Priority.ShouldBe(v);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,7 @@ namespace Ocelot.UnitTests.DependencyInjection
 | 
				
			|||||||
            _services.AddSingleton<IConfiguration>(_configRoot);
 | 
					            _services.AddSingleton<IConfiguration>(_configRoot);
 | 
				
			||||||
            _maxRetries = 100;
 | 
					            _maxRetries = 100;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private Exception _ex;
 | 
					        private Exception _ex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
@@ -102,9 +103,7 @@ namespace Ocelot.UnitTests.DependencyInjection
 | 
				
			|||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void should_set_up_administration_with_identity_server_options()
 | 
					        public void should_set_up_administration_with_identity_server_options()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Action<IdentityServerAuthenticationOptions> options = o => {
 | 
					            Action<IdentityServerAuthenticationOptions> options = o => {};
 | 
				
			||||||
               
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.Given(x => WhenISetUpOcelotServices())
 | 
					            this.Given(x => WhenISetUpOcelotServices())
 | 
				
			||||||
                .When(x => WhenISetUpAdministration(options))
 | 
					                .When(x => WhenISetUpAdministration(options))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -135,7 +135,7 @@ namespace Ocelot.UnitTests.Errors
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void GivenTheConfigThrows()
 | 
					        private void GivenTheConfigThrows()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var ex = new Exception("outer", new  Exception("inner"));
 | 
					            var ex = new Exception("outer", new Exception("inner"));
 | 
				
			||||||
             _provider
 | 
					             _provider
 | 
				
			||||||
                .Setup(x => x.Get()).ThrowsAsync(ex);
 | 
					                .Setup(x => x.Get()).ThrowsAsync(ex);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -192,7 +192,6 @@ namespace Ocelot.UnitTests.Errors
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void ThenTheResponseIsError()
 | 
					        private void ThenTheResponseIsError()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            _downstreamContext.HttpContext.Response.StatusCode.ShouldBe(500);
 | 
					            _downstreamContext.HttpContext.Response.StatusCode.ShouldBe(500);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -130,7 +130,6 @@ namespace Ocelot.UnitTests.Headers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void ThenTheResultIsError()
 | 
					        private void ThenTheResultIsError()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            _result.IsError.ShouldBe(true);
 | 
					            _result.IsError.ShouldBe(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,7 +80,6 @@ namespace Ocelot.UnitTests.Headers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            _downstreamContext.TemplatePlaceholderNameAndValues = dR.TemplatePlaceholderNameAndValues;
 | 
					            _downstreamContext.TemplatePlaceholderNameAndValues = dR.TemplatePlaceholderNameAndValues;
 | 
				
			||||||
            _downstreamContext.DownstreamReRoute = dR.ReRoute.DownstreamReRoute[0];
 | 
					            _downstreamContext.DownstreamReRoute = dR.ReRoute.DownstreamReRoute[0];
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void ThenTheIHttpContextRequestHeaderReplacerIsCalledCorrectly()
 | 
					        private void ThenTheIHttpContextRequestHeaderReplacerIsCalledCorrectly()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,7 @@ namespace Ocelot.UnitTests.Headers
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            _replacer = new HttpResponseHeaderReplacer();
 | 
					            _replacer = new HttpResponseHeaderReplacer();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void should_replace_headers()
 | 
					        public void should_replace_headers()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -232,4 +233,4 @@ namespace Ocelot.UnitTests.Headers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,6 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
				
			|||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void get_returns_correct_key_from_http_context()
 | 
					        public void get_returns_correct_key_from_http_context()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.Given(x => x.GivenAHttpContextContaining("key", "string"))
 | 
					            this.Given(x => x.GivenAHttpContextContaining("key", "string"))
 | 
				
			||||||
                .When(x => x.GetIsCalledWithKey<string>("key"))
 | 
					                .When(x => x.GetIsCalledWithKey<string>("key"))
 | 
				
			||||||
                .Then(x => x.ThenTheResultIsAnOkResponse<string>("string"))
 | 
					                .Then(x => x.ThenTheResultIsAnOkResponse<string>("string"))
 | 
				
			||||||
@@ -83,6 +82,5 @@ namespace Ocelot.UnitTests.Infrastructure
 | 
				
			|||||||
            _result.ShouldBeOfType<OkResponse<T>>();
 | 
					            _result.ShouldBeOfType<OkResponse<T>>();
 | 
				
			||||||
            ((OkResponse<T>)_result).Data.ShouldBe(resultValue);
 | 
					            ((OkResponse<T>)_result).Data.ShouldBe(resultValue);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,7 +91,6 @@ namespace Ocelot.UnitTests.LoadBalancer
 | 
				
			|||||||
            hostAndPortTwo.Data.DownstreamHost.ShouldBe("127.0.0.2");
 | 
					            hostAndPortTwo.Data.DownstreamHost.ShouldBe("127.0.0.2");
 | 
				
			||||||
            _leastConnection.Release(hostAndPortOne.Data);
 | 
					            _leastConnection.Release(hostAndPortOne.Data);
 | 
				
			||||||
            _leastConnection.Release(hostAndPortTwo.Data);
 | 
					            _leastConnection.Release(hostAndPortTwo.Data);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private async Task LeaseDelayAndRelease()
 | 
					        private async Task LeaseDelayAndRelease()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -188,7 +188,6 @@ namespace Ocelot.UnitTests.LoadBalancer
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            _downstreamContext.IsError.ShouldBeTrue();
 | 
					            _downstreamContext.IsError.ShouldBeTrue();
 | 
				
			||||||
            _downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors);
 | 
					            _downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri)
 | 
					        private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,7 +58,6 @@ namespace Ocelot.UnitTests.Middleware
 | 
				
			|||||||
        private void WhenIMultiplex()
 | 
					        private void WhenIMultiplex()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _multiplexer.Multiplex(_context, _reRoute, _pipeline).GetAwaiter().GetResult();
 | 
					            _multiplexer.Multiplex(_context, _reRoute, _pipeline).GetAwaiter().GetResult();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void ThePipelineIsCalled(int expected)
 | 
					        private void ThePipelineIsCalled(int expected)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,6 @@ namespace Ocelot.UnitTests.Request
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public DownstreamRequestInitialiserMiddlewareTests()
 | 
					        public DownstreamRequestInitialiserMiddlewareTests()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            _httpContext = new Mock<HttpContext>();
 | 
					            _httpContext = new Mock<HttpContext>();
 | 
				
			||||||
            _httpRequest = new Mock<HttpRequest>();
 | 
					            _httpRequest = new Mock<HttpRequest>();
 | 
				
			||||||
            _requestMapper = new Mock<IRequestMapper>();
 | 
					            _requestMapper = new Mock<IRequestMapper>();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,13 +9,13 @@ namespace Ocelot.UnitTests.Requester
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        public FakeDelegatingHandler()
 | 
					        public FakeDelegatingHandler()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public FakeDelegatingHandler(int order)
 | 
					        public FakeDelegatingHandler(int order)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Order = order;
 | 
					            Order = order;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public int Order {get;private set;}
 | 
					        public int Order {get;private set;}
 | 
				
			||||||
        public DateTime TimeCalled {get;private set;}
 | 
					        public DateTime TimeCalled {get;private set;}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,4 +25,4 @@ namespace Ocelot.UnitTests.Requester
 | 
				
			|||||||
            return new HttpResponseMessage();
 | 
					            return new HttpResponseMessage();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,8 +131,7 @@ namespace Ocelot.UnitTests.ServiceDiscovery
 | 
				
			|||||||
            else
 | 
					            else
 | 
				
			||||||
            {     
 | 
					            {     
 | 
				
			||||||
                _registeredServices[serviceNameAndAddress.Name] = new List<Service>(){ serviceNameAndAddress };
 | 
					                _registeredServices[serviceNameAndAddress.Name] = new List<Service>(){ serviceNameAndAddress };
 | 
				
			||||||
            }
 | 
					            }          
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user