diff --git a/Ocelot.Provider.Consul.sln b/Ocelot.Provider.Consul.sln index 6b50ad2..e73a6a4 100644 --- a/Ocelot.Provider.Consul.sln +++ b/Ocelot.Provider.Consul.sln @@ -1,4 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2036 MinimumVisualStudioVersion = 10.0.40219.1 diff --git a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj index 24db863..d6402e5 100644 --- a/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj +++ b/src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj @@ -27,7 +27,7 @@ - + all diff --git a/test/Ocelot.Provider.Consul.AcceptanceTests/ConfigurationInConsulTests.cs b/test/Ocelot.Provider.Consul.AcceptanceTests/ConfigurationInConsulTests.cs index 112ce12..49ab386 100644 --- a/test/Ocelot.Provider.Consul.AcceptanceTests/ConfigurationInConsulTests.cs +++ b/test/Ocelot.Provider.Consul.AcceptanceTests/ConfigurationInConsulTests.cs @@ -254,20 +254,20 @@ public void should_handle_request_to_consul_for_downstream_service_and_make_requ var consulConfig = new FileConfiguration { DynamicReRoutes = new List + { + new FileDynamicReRoute { - new FileDynamicReRoute + ServiceName = serviceName, + RateLimitRule = new FileRateLimitRule() { - ServiceName = serviceName, - RateLimitRule = new FileRateLimitRule() - { - EnableRateLimiting = true, - ClientWhitelist = new List(), - Limit = 3, - Period = "1s", - PeriodTimespan = 1000 - } + EnableRateLimiting = true, + ClientWhitelist = new List(), + Limit = 3, + Period = "1s", + PeriodTimespan = 1000 } - }, + } + }, GlobalConfiguration = new FileGlobalConfiguration { ServiceDiscoveryProvider = new FileServiceDiscoveryProvider @@ -366,8 +366,9 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string var base64 = Convert.ToBase64String(bytes); var kvp = new FakeConsulGetResponse(base64); - - await context.Response.WriteJsonAsync(new FakeConsulGetResponse[] { kvp }); + json = JsonConvert.SerializeObject(new FakeConsulGetResponse[] { kvp }); + context.Response.Headers.Add("Content-Type", "application/json"); + await context.Response.WriteAsync(json); } else if (context.Request.Method.ToLower() == "put" && context.Request.Path.Value == "/v1/kv/InternalConfiguration") { @@ -391,7 +392,9 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string } else if (context.Request.Path.Value == $"/v1/health/service/{serviceName}") { - await context.Response.WriteJsonAsync(_consulServices); + var json = JsonConvert.SerializeObject(_consulServices); + context.Response.Headers.Add("Content-Type", "application/json"); + await context.Response.WriteAsync(json); } }); }) @@ -452,17 +455,17 @@ public void Add(string key, FileConfiguration value, TimeSpan ttl, string region throw new NotImplementedException(); } - public void AddAndDelete(string key, FileConfiguration value, TimeSpan ttl, string region) + public FileConfiguration Get(string key, string region) { throw new NotImplementedException(); } - public FileConfiguration Get(string key, string region) + public void ClearRegion(string region) { throw new NotImplementedException(); } - public void ClearRegion(string region) + public void AddAndDelete(string key, FileConfiguration value, TimeSpan ttl, string region) { throw new NotImplementedException(); } diff --git a/test/Ocelot.Provider.Consul.AcceptanceTests/Ocelot.Provider.Consul.AcceptanceTests.csproj b/test/Ocelot.Provider.Consul.AcceptanceTests/Ocelot.Provider.Consul.AcceptanceTests.csproj index c9b1ba8..2ff0800 100644 --- a/test/Ocelot.Provider.Consul.AcceptanceTests/Ocelot.Provider.Consul.AcceptanceTests.csproj +++ b/test/Ocelot.Provider.Consul.AcceptanceTests/Ocelot.Provider.Consul.AcceptanceTests.csproj @@ -33,7 +33,7 @@ - + all diff --git a/test/Ocelot.Provider.Consul.AcceptanceTests/ServiceDiscoveryTests.cs b/test/Ocelot.Provider.Consul.AcceptanceTests/ServiceDiscoveryTests.cs index 1f1aa77..ac655cd 100644 --- a/test/Ocelot.Provider.Consul.AcceptanceTests/ServiceDiscoveryTests.cs +++ b/test/Ocelot.Provider.Consul.AcceptanceTests/ServiceDiscoveryTests.cs @@ -7,6 +7,7 @@ using Configuration.File; using global::Consul; using Microsoft.AspNetCore.Http; + using Newtonsoft.Json; using Shouldly; using TestStack.BDDfy; using Xunit; @@ -72,7 +73,6 @@ public void should_use_consul_service_discovery_and_load_balance_request() UpstreamHttpMethod = new List { "Get" }, ServiceName = serviceName, LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" }, - UseServiceDiscovery = true, } }, GlobalConfiguration = new FileGlobalConfiguration() @@ -128,7 +128,6 @@ public void should_handle_request_to_consul_for_downstream_service_and_make_requ UpstreamHttpMethod = new List { "Get", "Options" }, ServiceName = serviceName, LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" }, - UseServiceDiscovery = true, } }, GlobalConfiguration = new FileGlobalConfiguration() @@ -187,12 +186,6 @@ public void should_handle_request_to_consul_for_downstream_service_and_make_requ AllowAutoRedirect = true, UseCookieContainer = true, UseTracing = false - }, - QoSOptions = new FileQoSOptions - { - TimeoutValue = 100, - DurationOfBreak = 1000, - ExceptionsAllowedBeforeBreaking = 1 } } }; @@ -299,7 +292,6 @@ public void should_use_token_to_make_request_to_consul() UpstreamHttpMethod = new List { "Get", "Options" }, ServiceName = serviceName, LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" }, - UseServiceDiscovery = true, } }, GlobalConfiguration = new FileGlobalConfiguration() @@ -368,7 +360,6 @@ public void should_send_request_to_service_after_it_becomes_available_in_consul( UpstreamHttpMethod = new List { "Get" }, ServiceName = serviceName, LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" }, - UseServiceDiscovery = true, } }, GlobalConfiguration = new FileGlobalConfiguration() @@ -434,7 +425,6 @@ public void should_handle_request_to_poll_consul_for_downstream_service_and_make UpstreamHttpMethod = new List { "Get", "Options" }, ServiceName = serviceName, LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" }, - UseServiceDiscovery = true, } }, GlobalConfiguration = new FileGlobalConfiguration() @@ -512,8 +502,9 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string { _receivedToken = values.First(); } - - await context.Response.WriteJsonAsync(_consulServices); + var json = JsonConvert.SerializeObject(_consulServices); + context.Response.Headers.Add("Content-Type", "application/json"); + await context.Response.WriteAsync(json); } }); } diff --git a/test/Ocelot.Provider.Consul.AcceptanceTests/Steps.cs b/test/Ocelot.Provider.Consul.AcceptanceTests/Steps.cs index b53b1b4..e8bd3b1 100644 --- a/test/Ocelot.Provider.Consul.AcceptanceTests/Steps.cs +++ b/test/Ocelot.Provider.Consul.AcceptanceTests/Steps.cs @@ -15,7 +15,6 @@ using Configuration.File; using Configuration.Repository; using DependencyInjection; - using IdentityServer4.AccessTokenValidation; using Infrastructure; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; diff --git a/test/Ocelot.Provider.Consul.AcceptanceTests/TwoDownstreamServicesTests.cs b/test/Ocelot.Provider.Consul.AcceptanceTests/TwoDownstreamServicesTests.cs index e883137..a8934d5 100644 --- a/test/Ocelot.Provider.Consul.AcceptanceTests/TwoDownstreamServicesTests.cs +++ b/test/Ocelot.Provider.Consul.AcceptanceTests/TwoDownstreamServicesTests.cs @@ -6,6 +6,7 @@ using Configuration.File; using global::Consul; using Microsoft.AspNetCore.Http; + using Newtonsoft.Json; using TestStack.BDDfy; using Xunit; @@ -97,7 +98,9 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url) { if (context.Request.Path.Value == "/v1/health/service/product") { - await context.Response.WriteJsonAsync(_serviceEntries); + var json = JsonConvert.SerializeObject(_serviceEntries); + context.Response.Headers.Add("Content-Type", "application/json"); + await context.Response.WriteAsync(json); } }); } diff --git a/test/Ocelot.Provider.Consul.AcceptanceTests/WebSocketTests.cs b/test/Ocelot.Provider.Consul.AcceptanceTests/WebSocketTests.cs index 2c5a220..ac8688c 100644 --- a/test/Ocelot.Provider.Consul.AcceptanceTests/WebSocketTests.cs +++ b/test/Ocelot.Provider.Consul.AcceptanceTests/WebSocketTests.cs @@ -9,6 +9,7 @@ using Configuration.File; using global::Consul; using Microsoft.AspNetCore.Http; + using Newtonsoft.Json; using Shouldly; using TestStack.BDDfy; using Xunit; @@ -76,7 +77,6 @@ public void should_proxy_websocket_input_to_downstream_service_and_use_service_d DownstreamScheme = "ws", LoadBalancerOptions = new FileLoadBalancerOptions { Type = "RoundRobin" }, ServiceName = serviceName, - UseServiceDiscovery = true } }, GlobalConfiguration = new FileGlobalConfiguration @@ -130,7 +130,9 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string { if (context.Request.Path.Value == $"/v1/health/service/{serviceName}") { - await context.Response.WriteJsonAsync(_serviceEntries); + var json = JsonConvert.SerializeObject(_serviceEntries); + context.Response.Headers.Add("Content-Type", "application/json"); + await context.Response.WriteAsync(json); } }); } diff --git a/test/Ocelot.Provider.Consul.Benchmarks/Ocelot.Provider.Consul.Benchmarks.csproj b/test/Ocelot.Provider.Consul.Benchmarks/Ocelot.Provider.Consul.Benchmarks.csproj index 845327b..9cfda1f 100644 --- a/test/Ocelot.Provider.Consul.Benchmarks/Ocelot.Provider.Consul.Benchmarks.csproj +++ b/test/Ocelot.Provider.Consul.Benchmarks/Ocelot.Provider.Consul.Benchmarks.csproj @@ -16,7 +16,7 @@ - + all diff --git a/test/Ocelot.Provider.Consul.IntegrationTests/Ocelot.Provider.Consul.IntegrationTests.csproj b/test/Ocelot.Provider.Consul.IntegrationTests/Ocelot.Provider.Consul.IntegrationTests.csproj index c4fd163..b62cd45 100644 --- a/test/Ocelot.Provider.Consul.IntegrationTests/Ocelot.Provider.Consul.IntegrationTests.csproj +++ b/test/Ocelot.Provider.Consul.IntegrationTests/Ocelot.Provider.Consul.IntegrationTests.csproj @@ -18,10 +18,9 @@ - - + all @@ -35,7 +34,6 @@ - diff --git a/test/Ocelot.Provider.Consul.ManualTest/Ocelot.Provider.Consul.ManualTest.csproj b/test/Ocelot.Provider.Consul.ManualTest/Ocelot.Provider.Consul.ManualTest.csproj index fdc82b1..b35a580 100644 --- a/test/Ocelot.Provider.Consul.ManualTest/Ocelot.Provider.Consul.ManualTest.csproj +++ b/test/Ocelot.Provider.Consul.ManualTest/Ocelot.Provider.Consul.ManualTest.csproj @@ -34,7 +34,7 @@ - + all diff --git a/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs b/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs index 03e0837..05ece95 100644 --- a/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs +++ b/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Moq; + using Newtonsoft.Json; using Shouldly; using TestStack.BDDfy; using Values; @@ -276,7 +277,9 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string _receivedToken = values.First(); } - await context.Response.WriteJsonAsync(_serviceEntries); + var json = JsonConvert.SerializeObject(_serviceEntries); + context.Response.Headers.Add("Content-Type", "application/json"); + await context.Response.WriteAsync(json); } }); }) diff --git a/test/Ocelot.Provider.Consul.UnitTests/Ocelot.Provider.Consul.UnitTests.csproj b/test/Ocelot.Provider.Consul.UnitTests/Ocelot.Provider.Consul.UnitTests.csproj index df76812..e153185 100644 --- a/test/Ocelot.Provider.Consul.UnitTests/Ocelot.Provider.Consul.UnitTests.csproj +++ b/test/Ocelot.Provider.Consul.UnitTests/Ocelot.Provider.Consul.UnitTests.csproj @@ -42,7 +42,7 @@ - + all