Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5 from ThreeMammals/feature/update-ocelot
Browse files Browse the repository at this point in the history
Feature/update ocelot
  • Loading branch information
TomPallister authored Sep 3, 2018
2 parents c0c3bd7 + 523cb3e commit 921de50
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 44 deletions.
3 changes: 2 additions & 1 deletion Ocelot.Provider.Consul.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Ocelot.Provider.Consul/Ocelot.Provider.Consul.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Consul" Version="0.7.2.6" />
<PackageReference Include="Ocelot" Version="9.0.0" />
<PackageReference Include="Ocelot" Version="11.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,20 @@ public void should_handle_request_to_consul_for_downstream_service_and_make_requ
var consulConfig = new FileConfiguration
{
DynamicReRoutes = new List<FileDynamicReRoute>
{
new FileDynamicReRoute
{
new FileDynamicReRoute
ServiceName = serviceName,
RateLimitRule = new FileRateLimitRule()
{
ServiceName = serviceName,
RateLimitRule = new FileRateLimitRule()
{
EnableRateLimiting = true,
ClientWhitelist = new List<string>(),
Limit = 3,
Period = "1s",
PeriodTimespan = 1000
}
EnableRateLimiting = true,
ClientWhitelist = new List<string>(),
Limit = 3,
Period = "1s",
PeriodTimespan = 1000
}
},
}
},
GlobalConfiguration = new FileGlobalConfiguration
{
ServiceDiscoveryProvider = new FileServiceDiscoveryProvider
Expand Down Expand Up @@ -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")
{
Expand All @@ -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);
}
});
})
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Ocelot" Version="9.0.0" />
<PackageReference Include="Ocelot" Version="11.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Configuration.File;
using global::Consul;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
Expand Down Expand Up @@ -72,7 +73,6 @@ public void should_use_consul_service_discovery_and_load_balance_request()
UpstreamHttpMethod = new List<string> { "Get" },
ServiceName = serviceName,
LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" },
UseServiceDiscovery = true,
}
},
GlobalConfiguration = new FileGlobalConfiguration()
Expand Down Expand Up @@ -128,7 +128,6 @@ public void should_handle_request_to_consul_for_downstream_service_and_make_requ
UpstreamHttpMethod = new List<string> { "Get", "Options" },
ServiceName = serviceName,
LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" },
UseServiceDiscovery = true,
}
},
GlobalConfiguration = new FileGlobalConfiguration()
Expand Down Expand Up @@ -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
}
}
};
Expand Down Expand Up @@ -299,7 +292,6 @@ public void should_use_token_to_make_request_to_consul()
UpstreamHttpMethod = new List<string> { "Get", "Options" },
ServiceName = serviceName,
LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" },
UseServiceDiscovery = true,
}
},
GlobalConfiguration = new FileGlobalConfiguration()
Expand Down Expand Up @@ -368,7 +360,6 @@ public void should_send_request_to_service_after_it_becomes_available_in_consul(
UpstreamHttpMethod = new List<string> { "Get" },
ServiceName = serviceName,
LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" },
UseServiceDiscovery = true,
}
},
GlobalConfiguration = new FileGlobalConfiguration()
Expand Down Expand Up @@ -434,7 +425,6 @@ public void should_handle_request_to_poll_consul_for_downstream_service_and_make
UpstreamHttpMethod = new List<string> { "Get", "Options" },
ServiceName = serviceName,
LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" },
UseServiceDiscovery = true,
}
},
GlobalConfiguration = new FileGlobalConfiguration()
Expand Down Expand Up @@ -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);
}
});
}
Expand Down
1 change: 0 additions & 1 deletion test/Ocelot.Provider.Consul.AcceptanceTests/Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Configuration.File;
using global::Consul;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using TestStack.BDDfy;
using Xunit;

Expand Down Expand Up @@ -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);
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions test/Ocelot.Provider.Consul.AcceptanceTests/WebSocketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Configuration.File;
using global::Consul;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.14" />
<PackageReference Include="Consul" Version="0.7.2.6" />
<PackageReference Include="Ocelot" Version="9.0.0" />
<PackageReference Include="Ocelot" Version="11.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
<ItemGroup>
<PackageReference Include="CacheManager.Core" Version="1.1.2" />
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Ocelot" Version="9.0.0" />
<PackageReference Include="Ocelot" Version="11.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -35,7 +34,6 @@
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="IdentityServer4" Version="2.2.0" />
<PackageReference Include="Shouldly" Version="3.0.0" />
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
<PackageReference Include="Consul" Version="0.7.2.6" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="Consul" Version="0.7.2.6" />
<PackageReference Include="Ocelot" Version="9.0.0" />
<PackageReference Include="Ocelot" Version="11.0.2" />
<PackageReference Include="Polly" Version="6.0.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Moq;
using Newtonsoft.Json;
using Shouldly;
using TestStack.BDDfy;
using Values;
Expand Down Expand Up @@ -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);
}
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Ocelot" Version="9.0.0" />
<PackageReference Include="Ocelot" Version="11.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 921de50

Please sign in to comment.