Merge branch 'develop' into feature/#238-statefull

This commit is contained in:
TomPallister
2018-03-03 17:12:41 +00:00
137 changed files with 493 additions and 440 deletions

View File

@ -15,7 +15,6 @@ namespace Ocelot.AcceptanceTests
public class AggregateTests : IDisposable
{
private IWebHost _serviceOneBuilder;
private IWebHost _serviceTwoBuilder;
private readonly Steps _steps;
private string _downstreamPathOne;
private string _downstreamPathTwo;
@ -229,7 +228,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_be_thread_safe()
{
@ -365,7 +363,6 @@ namespace Ocelot.AcceptanceTests
public void Dispose()
{
_serviceOneBuilder?.Dispose();
_serviceTwoBuilder?.Dispose();
_steps.Dispose();
}
}

View File

@ -177,7 +177,7 @@ namespace Ocelot.AcceptanceTests
AuthenticationOptions = new FileAuthenticationOptions
{
AuthenticationProviderKey = "Test",
AllowedScopes = new List<string>{ "api", "api.readOnly", "openid", "offline_access" },
AllowedScopes = new List<string>{ "api", "api.readOnly", "openid", "offline_access" },
},
}
}
@ -218,7 +218,7 @@ namespace Ocelot.AcceptanceTests
AuthenticationOptions = new FileAuthenticationOptions
{
AuthenticationProviderKey = "Test",
AllowedScopes = new List<string>{ "api", "openid", "offline_access" },
AllowedScopes = new List<string>{ "api", "openid", "offline_access" },
},
}
}
@ -356,7 +356,6 @@ namespace Ocelot.AcceptanceTests
"CustomerId", "LocationId", "UserType", "UserId"
}
},
})
.AddInMemoryClients(new List<Client>
{
@ -437,7 +436,6 @@ namespace Ocelot.AcceptanceTests
"CustomerId", "LocationId", "UserType", "UserId", "Role"
}
},
})
.AddInMemoryClients(new List<Client>
{
@ -450,7 +448,6 @@ namespace Ocelot.AcceptanceTests
AccessTokenType = tokenType,
Enabled = true,
RequireClientSecret = false,
}
})
.AddTestUsers(users);

View File

@ -52,7 +52,7 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = new List<string> { "Get" },
HttpHandlerOptions = new FileHttpHandlerOptions
{
UseTracing = true
UseTracing = true
},
QoSOptions = new FileQoSOptions
{
@ -77,7 +77,7 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = new List<string> { "Get" },
HttpHandlerOptions = new FileHttpHandlerOptions
{
UseTracing = true
UseTracing = true
},
QoSOptions = new FileQoSOptions
{
@ -104,7 +104,6 @@ namespace Ocelot.AcceptanceTests
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Tom"))
.BDDfy();
var commandOnAllStateMachines = WaitFor(5000).Until(() => _butterflyCalled == 4);
commandOnAllStateMachines.ShouldBeTrue();

View File

@ -1,19 +1,14 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Hosting;
using Ocelot.Configuration.File;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.AcceptanceTests
{
public class CannotStartOcelotTests : IDisposable
{
private IWebHost _builder;
private readonly Steps _steps;
private string _downstreamPath;
public CannotStartOcelotTests()
{
@ -51,8 +46,7 @@ namespace Ocelot.AcceptanceTests
public void Dispose()
{
_builder?.Dispose();
_steps.Dispose();
}
}
}
}

View File

@ -156,7 +156,7 @@ namespace Ocelot.AcceptanceTests
{
new ApiResource
{
Name = apiName,
Name = apiName,
Description = "My API",
Enabled = true,
DisplayName = "test",

View File

@ -20,13 +20,11 @@ namespace Ocelot.AcceptanceTests
private readonly Steps _steps;
private int _counterOne;
public ClientRateLimitTests()
{
_steps = new Steps();
}
public void Dispose()
{
_builder?.Dispose();
@ -56,7 +54,7 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = new List<string> { "Get" },
RequestIdKey = _steps.RequestIdKey,
RateLimitOptions = new FileRateLimitRule()
RateLimitOptions = new FileRateLimitRule()
{
EnableRateLimiting = true,
ClientWhitelist = new List<string>(),
@ -75,7 +73,6 @@ namespace Ocelot.AcceptanceTests
QuotaExceededMessage = "",
RateLimitCounterPrefix = "",
HttpStatusCode = 428
},
RequestIdKey ="oceclientrequest"
}
@ -93,7 +90,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_call_middleware_withWhitelistClient()
{
@ -117,7 +113,7 @@ namespace Ocelot.AcceptanceTests
UpstreamHttpMethod = new List<string> { "Get" },
RequestIdKey = _steps.RequestIdKey,
RateLimitOptions = new FileRateLimitRule()
RateLimitOptions = new FileRateLimitRule()
{
EnableRateLimiting = true,
ClientWhitelist = new List<string>() { "ocelotclient1"},
@ -148,7 +144,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath)
{
_builder = new WebHostBuilder()
@ -172,7 +167,5 @@ namespace Ocelot.AcceptanceTests
_builder.Start();
}
}
}

View File

@ -175,7 +175,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_load_configuration_out_of_consul_if_it_is_changed()
{
@ -307,8 +306,7 @@ namespace Ocelot.AcceptanceTests
var kvp = new FakeConsulGetResponse(base64);
await context.Response.WriteJsonAsync(new FakeConsulGetResponse[] { kvp });
}
}
else if (context.Request.Method.ToLower() == "put" && context.Request.Path.Value == "/v1/kv/OcelotConfiguration")
{
try

View File

@ -25,7 +25,7 @@ namespace Ocelot.AcceptanceTests
public CustomMiddlewareTests()
{
_counter = 0;
_steps = new Steps();;
_steps = new Steps();
_configurationPath = "configuration.json";
}
@ -286,7 +286,6 @@ namespace Ocelot.AcceptanceTests
.And(x => x.ThenTheCounterIs(1))
.BDDfy();
}
[Fact(Skip = "This is just an example to show how you could hook into Ocelot pipeline with your own middleware. At the moment you must use Response.OnCompleted callback and cannot change the response :( I will see if this can be changed one day!")]
public void should_fix_issue_237()
@ -352,14 +351,13 @@ namespace Ocelot.AcceptanceTests
app.UsePathBase(basePath);
app.Run(context =>
{
if(string.IsNullOrEmpty(basePath))
{
context.Response.StatusCode = statusCode;
}
else if(context.Request.Path.Value != basePath)
{
context.Response.StatusCode = 404;;
context.Response.StatusCode = 404;
}
return Task.CompletedTask;

View File

@ -186,7 +186,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath, int statusCode, string headerKey)
{
_builder = new WebHostBuilder()

View File

@ -70,8 +70,7 @@ namespace Ocelot.AcceptanceTests
}
class FakeHandler : DelegatingHandler
{
{
public DateTime TimeCalled { get; private set; }
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
@ -111,6 +110,5 @@ namespace Ocelot.AcceptanceTests
_builder.Start();
}
}
}

View File

@ -159,8 +159,7 @@ namespace Ocelot.AcceptanceTests
catch (System.Exception exception)
{
await context.Response.WriteAsync(exception.StackTrace);
}
}
});
})
.Build();

View File

@ -1,48 +1,53 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>0.0.0-dev</VersionPrefix>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<AssemblyName>Ocelot.AcceptanceTests</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Ocelot.AcceptanceTests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeIdentifiers>osx.10.11-x64;osx.10.12-x64;win7-x64;win10-x64</RuntimeIdentifiers>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<None Update="configuration.json;appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
<ProjectReference Include="..\Ocelot.ManualTest\Ocelot.ManualTest.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CacheManager.Serialization.Json" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171031-01" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="Shouldly" Version="3.0.0-beta0003" />
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
<PackageReference Include="Consul" Version="0.7.2.3" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Butterfly.Client.AspNetCore" Version="0.0.8" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>0.0.0-dev</VersionPrefix>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<AssemblyName>Ocelot.AcceptanceTests</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Ocelot.AcceptanceTests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeIdentifiers>osx.10.11-x64;osx.10.12-x64;win7-x64;win10-x64</RuntimeIdentifiers>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<CodeAnalysisRuleSet>..\..\codeanalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<None Update="configuration.json;appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
<ProjectReference Include="..\Ocelot.ManualTest\Ocelot.ManualTest.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CacheManager.Serialization.Json" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171031-01" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="Shouldly" Version="3.0.0-beta0003" />
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
<PackageReference Include="Consul" Version="0.7.2.3" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Butterfly.Client.AspNetCore" Version="0.0.8" />
</ItemGroup>
</Project>

View File

@ -51,8 +51,7 @@ namespace Ocelot.AcceptanceTests
ExceptionsAllowedBeforeBreaking = 1,
TimeoutValue = 500,
DurationOfBreak = 1000
},
},
}
}
};

View File

@ -543,7 +543,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_return_response_200_with_complex_url_that_starts_with_placeholder()
{
@ -578,7 +577,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_not_add_trailing_slash_to_downstream_url()
{
@ -834,7 +832,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_fix_145()
{

View File

@ -359,8 +359,7 @@ namespace Ocelot.AcceptanceTests
catch (System.Exception exception)
{
await context.Response.WriteAsync(exception.StackTrace);
}
}
});
})
.Build();
@ -406,4 +405,4 @@ namespace Ocelot.AcceptanceTests
_steps.Dispose();
}
}
}
}

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
@ -19,15 +17,11 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Ocelot.Configuration.File;
using Ocelot.Configuration.Repository;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.ServiceDiscovery;
using Shouldly;
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
using Ocelot.AcceptanceTests.Caching;
using Butterfly.Client.AspNetCore;
using Butterfly.Client.Tracing;
namespace Ocelot.AcceptanceTests
{
@ -42,11 +36,9 @@ namespace Ocelot.AcceptanceTests
public string RequestIdKey = "OcRequestId";
private readonly Random _random;
private IWebHostBuilder _webHostBuilder;
private readonly string _baseUrl;
public Steps()
{
_baseUrl = "http://localhost:5000";
_random = new Random();
}
@ -144,6 +136,7 @@ namespace Ocelot.AcceptanceTests
_ocelotClient = _ocelotServer.CreateClient();
}
/*
public void GivenIHaveAddedXForwardedForHeader(string value)
{

View File

@ -58,7 +58,6 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_return_response_200_with_simple_url_and_hosts_match_multiple_re_routes()
{

View File

@ -11,6 +11,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<CodeAnalysisRuleSet>..\..\codeanalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
@ -19,6 +20,9 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.12" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -8,7 +8,6 @@ namespace Ocelot.Benchmarks
{
var switcher = new BenchmarkSwitcher(new[] {
typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
});
switcher.Run(args);

View File

@ -124,7 +124,6 @@ namespace Ocelot.IntegrationTests
{
Host = "127.0.0.1",
}
},
ReRoutes = new List<FileReRoute>()
{
@ -485,7 +484,6 @@ namespace Ocelot.IntegrationTests
app.UseOcelot().Wait();
});
_builderTwo = _webHostBuilderTwo.Build();
_builderTwo.Start();

View File

@ -11,6 +11,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<CodeAnalysisRuleSet>..\..\codeanalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<None Update="peers.json;configuration.json;appsettings.json;idsrv3test.pfx">
@ -18,29 +19,32 @@
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}"/>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj"/>
<ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171031-01"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1"/>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0"/>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0"/>
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177"/>
<PackageReference Include="xunit" Version="2.3.1"/>
<PackageReference Include="IdentityServer4" Version="2.0.2"/>
<PackageReference Include="Shouldly" Version="3.0.0-beta0003"/>
<PackageReference Include="TestStack.BDDfy" Version="4.3.2"/>
<PackageReference Include="Consul" Version="0.7.2.3"/>
<PackageReference Include="Rafty" Version="0.4.2"/>
<PackageReference Include="Microsoft.Data.SQLite" Version="2.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171031-01" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="IdentityServer4" Version="2.0.2" />
<PackageReference Include="Shouldly" Version="3.0.0-beta0003" />
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
<PackageReference Include="Consul" Version="0.7.2.3" />
<PackageReference Include="Rafty" Version="0.4.2" />
<PackageReference Include="Microsoft.Data.SQLite" Version="2.0.0" />
</ItemGroup>
</Project>

View File

@ -45,6 +45,7 @@ namespace Ocelot.IntegrationTests
_builders = new List<IWebHost>();
_threads = new List<Thread>();
}
public void Dispose()
{
foreach (var builder in _builders)
@ -194,7 +195,6 @@ namespace Ocelot.IntegrationTests
var stopwatch = Stopwatch.StartNew();
while(stopwatch.ElapsedMilliseconds < 10000)
{
}
}
@ -204,10 +204,9 @@ namespace Ocelot.IntegrationTests
var stopwatch = Stopwatch.StartNew();
while(stopwatch.ElapsedMilliseconds < 2000)
{
}
bool CommandCalledOnAllStateMachines()
bool CommandCalledOnAllStateMachines()
{
try
{
@ -225,6 +224,7 @@ namespace Ocelot.IntegrationTests
index.ShouldBe(1);
}
}
_httpClientForAssertions.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken);
var result = _httpClientForAssertions.GetAsync($"{peer.HostAndPort}/administration/configuration").Result;
var json = result.Content.ReadAsStringAsync().Result;
@ -248,6 +248,7 @@ namespace Ocelot.IntegrationTests
response.ReRoutes[i].UpstreamPathTemplate.ShouldBe(expecteds.Configuration.ReRoutes[i].UpstreamPathTemplate);
response.ReRoutes[i].UpstreamHttpMethod.ShouldBe(expecteds.Configuration.ReRoutes[i].UpstreamHttpMethod);
}
passed++;
}
@ -384,7 +385,6 @@ namespace Ocelot.IntegrationTests
var stopwatch = Stopwatch.StartNew();
while(stopwatch.ElapsedMilliseconds < 20000)
{
}
}
}

View File

@ -195,6 +195,7 @@ namespace Ocelot.IntegrationTests
result.Result.ShouldBe(result.Random);
}
}
public void Dispose()
{
_builder?.Dispose();
@ -208,7 +209,6 @@ namespace Ocelot.IntegrationTests
{
Result = result;
Random = random;
}
public int Result { get; private set; }

View File

@ -9,6 +9,7 @@
<OutputType>Exe</OutputType>
<PackageId>Ocelot.ManualTest</PackageId>
<RuntimeIdentifiers>osx.10.11-x64;osx.10.12-x64;win7-x64;win10-x64</RuntimeIdentifiers>
<CodeAnalysisRuleSet>..\..\codeanalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
@ -38,6 +39,9 @@
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="Consul" Version="0.7.2.3" />
<PackageReference Include="Polly" Version="5.3.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -6,24 +6,17 @@ namespace Ocelot.UnitTests.Authentication
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Authentication.Middleware;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Responses;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
public class AuthenticationMiddlewareTests
{
private OkResponse<DownstreamRoute> _downstreamRoute;
private AuthenticationMiddleware _middleware;
private Mock<IOcelotLoggerFactory> _factory;
private Mock<IOcelotLogger> _logger;
@ -49,7 +42,7 @@ namespace Ocelot.UnitTests.Authentication
.BDDfy();
}
private void WhenICallTheMiddleware()
private void WhenICallTheMiddleware()
{
_next = async (context) => {
byte[] byteArray = Encoding.ASCII.GetBytes("The user is authenticated");
@ -89,7 +82,7 @@ namespace Ocelot.UnitTests.Authentication
{
string text = reader.ReadToEnd();
return text;
};
}
}
}
}

View File

@ -28,7 +28,6 @@ namespace Ocelot.UnitTests.Authorization
this.Given(x => x.GivenAClaimsPrincipal(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
{
new Claim("UserType", "registered"),
}))))
.And(x => x.GivenARouteClaimsRequirement(new Dictionary<string, string>
{

View File

@ -1,5 +1,4 @@
using Ocelot.Errors;
using Ocelot.Infrastructure.RequestData;
using Ocelot.Middleware;
namespace Ocelot.UnitTests.Cache
@ -11,26 +10,19 @@ namespace Ocelot.UnitTests.Cache
using Shouldly;
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Cache;
using Ocelot.Cache.Middleware;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Logging;
using Ocelot.Responses;
using TestStack.BDDfy;
using Xunit;
using Ocelot.DownstreamRouteFinder.Middleware;
using Microsoft.AspNetCore.Http;
public class OutputCacheMiddlewareRealCacheTests
{
private IOcelotCache<CachedResponse> _cacheManager;
private CachedResponse _response;
private OutputCacheMiddleware _middleware;
private DownstreamContext _downstreamContext;
private OcelotRequestDelegate _next;

View File

@ -110,7 +110,6 @@ namespace Ocelot.UnitTests.Cache
private void GivenThereAreNoErrors()
{
_downstreamContext.Errors = new List<Error>();
}
private void ThenTheCacheGetIsCalledCorrectly()

View File

@ -93,7 +93,6 @@ namespace Ocelot.UnitTests.Claims
.BDDfy();
}
private void GivenClaimsToThings(List<ClaimToThing> configuration)
{
_claimsToThings = configuration;
@ -129,7 +128,6 @@ namespace Ocelot.UnitTests.Claims
private void ThenTheResultIsError()
{
_result.IsError.ShouldBe(true);
}

View File

@ -15,12 +15,10 @@ namespace Ocelot.UnitTests.Claims
using Ocelot.Responses;
using TestStack.BDDfy;
using Xunit;
using Ocelot.DownstreamRouteFinder.Middleware;
public class ClaimsBuilderMiddlewareTests
{
private readonly Mock<IAddClaimsToRequest> _addHeaders;
private Response<DownstreamRoute> _downstreamRoute;
private Mock<IOcelotLoggerFactory> _loggerFactory;
private Mock<IOcelotLogger> _logger;
private readonly ClaimsBuilderMiddleware _middleware;
@ -68,7 +66,6 @@ namespace Ocelot.UnitTests.Claims
_middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
}
private void GivenTheDownStreamRouteIs(DownstreamRoute downstreamRoute)
{
_downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues;

View File

@ -79,6 +79,7 @@ namespace Ocelot.UnitTests.Configuration
{
_result.Count.ShouldBeGreaterThan(0);
}
private void GivenTheFollowingDictionary(Dictionary<string,string> claimsToThings)
{
_claimsToThings = claimsToThings;
@ -107,4 +108,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.Extract(_claimsToThings.First().Key, _claimsToThings.First().Value), Times.Once);
}
}
}
}

View File

@ -588,7 +588,8 @@ namespace Ocelot.UnitTests.Configuration
AuthenticationOptions = new FileAuthenticationOptions()
{
AuthenticationProviderKey = "Test"
} }
}
}
}
}))
.When(x => x.WhenIValidateTheConfiguration())
@ -869,7 +870,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Theory]
[InlineData(null)]
[InlineData("")]
@ -981,7 +981,8 @@ namespace Ocelot.UnitTests.Configuration
.And(x => x.ThenTheErrorMessageAtPositionIs(0, "When not using service discovery DownstreamHostAndPorts must be set and not empty or Ocelot cannot find your service!"))
.BDDfy();
}
[Fact]
[Fact]
public void configuration_is_not_valid_when_host_and_port_is_empty()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration
@ -1007,7 +1008,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
private void GivenAConfiguration(FileConfiguration fileConfiguration)
{
_fileConfiguration = fileConfiguration;

View File

@ -12,7 +12,6 @@ using Xunit;
using Shouldly;
using static Ocelot.UnitTests.Wait;
namespace Ocelot.UnitTests.Configuration
{
public class ConsulFileConfigurationPollerTests : IDisposable
@ -34,6 +33,7 @@ namespace Ocelot.UnitTests.Configuration
_repo.Setup(x => x.Get()).ReturnsAsync(new OkResponse<FileConfiguration>(_fileConfig));
_poller = new ConsulFileConfigurationPoller(_factory.Object, _repo.Object, _setter.Object);
}
public void Dispose()
{
_poller.Dispose();
@ -49,7 +49,6 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_call_setter_when_gets_new_config()
{
var newConfig = new FileConfiguration {
ReRoutes = new List<FileReRoute>
{
@ -84,7 +83,7 @@ namespace Ocelot.UnitTests.Configuration
_setter.Verify(x => x.Set(fileConfig), Times.Once);
return true;
}
catch(Exception ex)
catch(Exception)
{
return false;
}

View File

@ -502,7 +502,6 @@ namespace Ocelot.UnitTests.Configuration
.WithUseServiceDiscovery(false)
.Build();
this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -545,7 +544,6 @@ namespace Ocelot.UnitTests.Configuration
.WithUpstreamTemplatePattern(new UpstreamPathTemplate("(?i)/api/products/.*/$", 1))
.Build();
this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -823,8 +821,7 @@ namespace Ocelot.UnitTests.Configuration
result.DownstreamReRoute[0].ClaimsToClaims.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToClaims.Count);
result.DownstreamReRoute[0].ClaimsToHeaders.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToHeaders.Count);
result.DownstreamReRoute[0].ClaimsToQueries.Count.ShouldBe(expected.DownstreamReRoute[0].ClaimsToQueries.Count);
result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);
result.DownstreamReRoute[0].RequestIdKey.ShouldBe(expected.DownstreamReRoute[0].RequestIdKey);
}
}
@ -916,7 +913,6 @@ namespace Ocelot.UnitTests.Configuration
.Setup(x => x.Create(It.IsAny<FileGlobalConfiguration>())).Returns(serviceProviderConfiguration);
}
private void GivenTheFollowingRegionIsReturned(string region)
{
_regionCreator

View File

@ -38,8 +38,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
private void GivenTheConfigurationIs(FileConfiguration fileConfiguration)
{
_fileConfiguration = fileConfiguration;
@ -59,4 +57,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.Get(), Times.Once);
}
}
}
}

View File

@ -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";

View File

@ -48,7 +48,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_return_error_if_unable_to_set_file_configuration()
{
@ -110,4 +109,4 @@ namespace Ocelot.UnitTests.Configuration
.Verify(x => x.AddOrReplace(_configuration.Data), Times.Once);
}
}
}
}

View File

@ -33,13 +33,11 @@ namespace Ocelot.UnitTests.Configuration
UpstreamHeaderTransform = new Dictionary<string, string>
{
{"Test", "Test, Chicken"},
{"Moop", "o, a"}
},
DownstreamHeaderTransform = new Dictionary<string, string>
{
{"Pop", "West, East"},
{"Bop", "e, r"}
}
};
@ -86,7 +84,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_use_base_url_partial_placeholder()
{
@ -155,4 +152,4 @@ namespace Ocelot.UnitTests.Configuration
}
}
}
}
}

View File

@ -7,7 +7,6 @@ using Xunit;
namespace Ocelot.UnitTests.Configuration
{
public class HttpHandlerOptionsCreatorTests
{
private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;

View File

@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_match_forward_slash_or_no_forward_slash_if_template_end_with_forward_slash()
{
@ -70,7 +69,7 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void should_create_template_pattern_that_matches_anything_to_end_of_string()
{
var fileReRoute = new FileReRoute
var fileReRoute = new FileReRoute
{
UpstreamPathTemplate = "/api/products/{productId}",
ReRouteIsCaseSensitive = true
@ -181,4 +180,4 @@ namespace Ocelot.UnitTests.Configuration
_result.Priority.ShouldBe(v);
}
}
}
}

View File

@ -111,7 +111,6 @@ namespace Ocelot.UnitTests.Controllers
.BDDfy();
}
private void ThenTheNodeIsCalledCorrectly()
{
_node.Verify(x => x.Accept(It.IsAny<UpdateFileConfiguration>()), Times.Once);

View File

@ -15,7 +15,6 @@ using Ocelot.DependencyInjection;
using Ocelot.Requester;
using Ocelot.UnitTests.Requester;
using Shouldly;
using System;
using IdentityServer4.AccessTokenValidation;
using TestStack.BDDfy;
using Xunit;
@ -38,6 +37,7 @@ namespace Ocelot.UnitTests.DependencyInjection
_services.AddSingleton<IConfiguration>(_configRoot);
_maxRetries = 100;
}
private Exception _ex;
[Fact]
@ -69,7 +69,6 @@ namespace Ocelot.UnitTests.DependencyInjection
.BDDfy();
}
[Fact]
public void should_set_up_cache_manager()
{
@ -102,9 +101,7 @@ namespace Ocelot.UnitTests.DependencyInjection
[Fact]
public void should_set_up_administration_with_identity_server_options()
{
Action<IdentityServerAuthenticationOptions> options = o => {
};
Action<IdentityServerAuthenticationOptions> options = o => {};
this.Given(x => WhenISetUpOcelotServices())
.When(x => WhenISetUpAdministration(options))
@ -152,7 +149,6 @@ namespace Ocelot.UnitTests.DependencyInjection
.BDDfy();
}
[Fact]
public void should_set_up_without_passing_in_config()
{

View File

@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
_downstreamRouteFinder = new Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder(_mockMatcher.Object, _finder.Object);
}
[Fact]
public void should_return_highest_priority_when_first()
{
@ -182,7 +181,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
.BDDfy();
}
[Fact]
public void should_not_append_slash_to_upstream_url_path()
{
@ -598,7 +596,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
.BDDfy();
}
[Fact]
public void should_return_route_when_host_matches_but_null_host_on_same_path_first()
{

View File

@ -30,7 +30,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
.BDDfy();
}
[Fact]
public void can_match_down_stream_url_with_nothing_then_placeholder_no_value_is_blank()
{
@ -264,4 +263,4 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder.UrlMatcher
_result = _finder.Find(_downstreamUrlPath, _downstreamPathTemplate);
}
}
}
}

View File

@ -29,7 +29,6 @@ namespace Ocelot.UnitTests.Errors
private DownstreamContext _downstreamContext;
private OcelotRequestDelegate _next;
public ExceptionHandlerMiddlewareTests()
{
_provider = new Mock<IOcelotConfigurationProvider>();
@ -135,7 +134,7 @@ namespace Ocelot.UnitTests.Errors
private void GivenTheConfigThrows()
{
var ex = new Exception("outer", new Exception("inner"));
var ex = new Exception("outer", new Exception("inner"));
_provider
.Setup(x => x.Get()).ThrowsAsync(ex);
}
@ -174,7 +173,6 @@ namespace Ocelot.UnitTests.Errors
.Setup(x => x.Get()).ReturnsAsync(response);
}
private void GivenAnExceptionWillNotBeThrownDownstream()
{
_shouldThrowAnException = false;
@ -192,7 +190,6 @@ namespace Ocelot.UnitTests.Errors
private void ThenTheResponseIsError()
{
_downstreamContext.HttpContext.Response.StatusCode.ShouldBe(500);
}

View File

@ -130,7 +130,6 @@ namespace Ocelot.UnitTests.Headers
private void ThenTheResultIsError()
{
_result.IsError.ShouldBe(true);
}

View File

@ -80,7 +80,6 @@ namespace Ocelot.UnitTests.Headers
_downstreamContext.TemplatePlaceholderNameAndValues = dR.TemplatePlaceholderNameAndValues;
_downstreamContext.DownstreamReRoute = dR.ReRoute.DownstreamReRoute[0];
}
private void ThenTheIHttpContextRequestHeaderReplacerIsCalledCorrectly()

View File

@ -22,6 +22,7 @@ namespace Ocelot.UnitTests.Headers
{
_replacer = new HttpResponseHeaderReplacer();
}
[Fact]
public void should_replace_headers()
{
@ -97,7 +98,6 @@ namespace Ocelot.UnitTests.Headers
.BDDfy();
}
[Fact]
public void should_replace_downstream_base_url_with_ocelot_base_url_and_path()
{
@ -232,4 +232,4 @@ namespace Ocelot.UnitTests.Headers
}
}
}
}
}

View File

@ -21,13 +21,14 @@ namespace Ocelot.UnitTests.Infrastructure
_httpDataRepository = new HttpDataRepository(_httpContextAccessor);
}
//TODO - Additional tests -> Type mistmatch aka Add string, request int
//TODO - Additional tests -> HttpContent null. This should never happen
/*
TODO - Additional tests -> Type mistmatch aka Add string, request int
TODO - Additional tests -> HttpContent null. This should never happen
*/
[Fact]
public void get_returns_correct_key_from_http_context()
{
this.Given(x => x.GivenAHttpContextContaining("key", "string"))
.When(x => x.GetIsCalledWithKey<string>("key"))
.Then(x => x.ThenTheResultIsAnOkResponse<string>("string"))
@ -83,6 +84,5 @@ namespace Ocelot.UnitTests.Infrastructure
_result.ShouldBeOfType<OkResponse<T>>();
((OkResponse<T>)_result).Data.ShouldBe(resultValue);
}
}
}

View File

@ -35,7 +35,6 @@ namespace Ocelot.UnitTests.Infrastructure
.BDDfy();
}
[Fact]
public void should_return_ok_if_null_allowed_scopes()
{
@ -121,4 +120,4 @@ namespace Ocelot.UnitTests.Infrastructure
{
}
}
}
}

View File

@ -91,7 +91,6 @@ namespace Ocelot.UnitTests.LoadBalancer
hostAndPortTwo.Data.DownstreamHost.ShouldBe("127.0.0.2");
_leastConnection.Release(hostAndPortOne.Data);
_leastConnection.Release(hostAndPortTwo.Data);
}
private async Task LeaseDelayAndRelease()

View File

@ -17,9 +17,7 @@ namespace Ocelot.UnitTests.LoadBalancer
private DownstreamReRoute _reRoute;
private ILoadBalancer _loadBalancer;
private readonly LoadBalancerHouse _loadBalancerHouse;
private Response _addResult;
private Response<ILoadBalancer> _getResult;
private string _key;
private readonly Mock<ILoadBalancerFactory> _factory;
private ServiceProviderConfiguration _serviceProviderConfig;
@ -116,7 +114,6 @@ namespace Ocelot.UnitTests.LoadBalancer
_factory.Verify(x => x.Get(_reRoute, _serviceProviderConfig), Times.Once);
}
private void GivenThereIsALoadBalancer(DownstreamReRoute reRoute, ILoadBalancer loadBalancer)
{
_reRoute = reRoute;

View File

@ -4,15 +4,10 @@ namespace Ocelot.UnitTests.LoadBalancer
{
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Provider;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.Errors;
using Ocelot.LoadBalancer.LoadBalancers;
using Ocelot.LoadBalancer.Middleware;
@ -28,7 +23,6 @@ namespace Ocelot.UnitTests.LoadBalancer
private readonly Mock<ILoadBalancerHouse> _loadBalancerHouse;
private readonly Mock<ILoadBalancer> _loadBalancer;
private ServiceHostAndPort _hostAndPort;
private OkResponse<DownstreamRoute> _downstreamRoute;
private ErrorResponse<ILoadBalancer> _getLoadBalancerHouseError;
private ErrorResponse<ServiceHostAndPort> _getHostAndPortError;
private HttpRequestMessage _downstreamRequest;
@ -188,7 +182,6 @@ namespace Ocelot.UnitTests.LoadBalancer
{
_downstreamContext.IsError.ShouldBeTrue();
_downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors);
}
private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri)

View File

@ -58,7 +58,6 @@ namespace Ocelot.UnitTests.Middleware
private void WhenIMultiplex()
{
_multiplexer.Multiplex(_context, _reRoute, _pipeline).GetAwaiter().GetResult();
}
private void ThePipelineIsCalled(int expected)

View File

@ -1,6 +1,5 @@
namespace Ocelot.UnitTests.Middleware
{
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
@ -17,9 +16,7 @@
public class OcelotPiplineBuilderTests
{
private readonly IServiceCollection _services;
private IServiceProvider _serviceProvider;
private readonly IConfiguration _configRoot;
private IOcelotBuilder _ocelotBuilder;
private DownstreamContext _downstreamContext;
private int _counter;

View File

@ -42,7 +42,6 @@ namespace Ocelot.UnitTests.Middleware
.WithDownstreamReRoutes(downstreamReRoutes)
.Build();
var billDownstreamContext = new DownstreamContext(new DefaultHttpContext())
{
DownstreamResponse =

View File

@ -12,6 +12,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<CodeAnalysisRuleSet>..\..\codeanalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -37,6 +38,9 @@
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171031-01" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />

View File

@ -19,7 +19,6 @@ namespace Ocelot.UnitTests.RateLimit
using Microsoft.Extensions.Caching.Memory;
using System.IO;
public class ClientRateLimitMiddlewareTests
{
private int _responseStatusCode;

View File

@ -36,7 +36,6 @@ namespace Ocelot.UnitTests.Request
public DownstreamRequestInitialiserMiddlewareTests()
{
_httpContext = new Mock<HttpContext>();
_httpRequest = new Mock<HttpRequest>();
_requestMapper = new Mock<IRequestMapper>();

View File

@ -4,7 +4,6 @@ namespace Ocelot.UnitTests.RequestId
{
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.Infrastructure.RequestData;
using System;
using System.Collections.Generic;
@ -24,7 +23,6 @@ namespace Ocelot.UnitTests.RequestId
public class ReRouteRequestIdMiddlewareTests
{
private readonly HttpRequestMessage _downstreamRequest;
private Response<DownstreamRoute> _downstreamRoute;
private string _value;
private string _key;
private Mock<IOcelotLoggerFactory> _loggerFactory;
@ -165,7 +163,6 @@ namespace Ocelot.UnitTests.RequestId
_repo.Verify(x => x.Update<string>("RequestId", _value), Times.Once);
}
private void GivenTheDownStreamRouteIs(DownstreamRoute downstreamRoute)
{
_downstreamContext.TemplatePlaceholderNameAndValues = downstreamRoute.TemplatePlaceholderNameAndValues;

View File

@ -41,7 +41,6 @@ namespace Ocelot.UnitTests.Requester
.Returns(qosProvider);
}
[Fact]
public void should_all_from_all_routes_provider_and_qos()
{

View File

@ -9,13 +9,13 @@ namespace Ocelot.UnitTests.Requester
{
public FakeDelegatingHandler()
{
}
public FakeDelegatingHandler(int order)
{
Order = order;
}
public int Order {get;private set;}
public DateTime TimeCalled {get;private set;}
@ -25,4 +25,4 @@ namespace Ocelot.UnitTests.Requester
return new HttpResponseMessage();
}
}
}
}

View File

@ -17,7 +17,6 @@ namespace Ocelot.UnitTests.Requester
private readonly HttpClientBuilder _builder;
private readonly Mock<IDelegatingHandlerHandlerHouse> _house;
private readonly Mock<IDelegatingHandlerHandlerProvider> _provider;
private IHttpClientBuilder _builderResult;
private IHttpClient _httpClient;
private HttpResponseMessage _response;
private DownstreamReRoute _request;

View File

@ -13,7 +13,6 @@ namespace Ocelot.UnitTests.Requester
{
private IQoSProvider _qoSProvider;
private readonly QosProviderHouse _qosProviderHouse;
private Response _addResult;
private Response<IQoSProvider> _getResult;
private DownstreamReRoute _reRoute;
private readonly Mock<IQoSProviderFactory> _factory;
@ -111,7 +110,6 @@ namespace Ocelot.UnitTests.Requester
_getResult.Data.ShouldBe(_qoSProvider);
}
private void GivenThereIsAQoSProvider(DownstreamReRoute reRoute, IQoSProvider qoSProvider)
{
_reRoute = reRoute;

View File

@ -42,10 +42,9 @@ namespace Ocelot.UnitTests.Responder
[InlineData(OcelotErrorCode.RequestTimedOutError)]
public void should_return_service_unavailable(OcelotErrorCode errorCode)
{
ShouldMapErrorToStatusCode(OcelotErrorCode.RequestTimedOutError, HttpStatusCode.ServiceUnavailable);
ShouldMapErrorToStatusCode(errorCode, HttpStatusCode.ServiceUnavailable);
}
[Theory]
[InlineData(OcelotErrorCode.CannotAddDataError)]
[InlineData(OcelotErrorCode.CannotFindDataError)]

View File

@ -4,7 +4,6 @@ using Ocelot.Middleware;
namespace Ocelot.UnitTests.Responder
{
using Microsoft.AspNetCore.Http;
using Ocelot.DownstreamRouteFinder.Middleware;
using System.Net.Http;
using Moq;
using Ocelot.DownstreamRouteFinder.Finder;
@ -12,7 +11,6 @@ namespace Ocelot.UnitTests.Responder
using Ocelot.Logging;
using Ocelot.Responder;
using Ocelot.Responder.Middleware;
using Ocelot.Responses;
using TestStack.BDDfy;
using Xunit;
@ -20,14 +18,12 @@ namespace Ocelot.UnitTests.Responder
{
private readonly Mock<IHttpResponder> _responder;
private readonly Mock<IErrorsToHttpStatusCodeMapper> _codeMapper;
private OkResponse<HttpResponseMessage> _response;
private Mock<IOcelotLoggerFactory> _loggerFactory;
private Mock<IOcelotLogger> _logger;
private readonly ResponderMiddleware _middleware;
private readonly DownstreamContext _downstreamContext;
private OcelotRequestDelegate _next;
public ResponderMiddlewareTests()
{
_responder = new Mock<IHttpResponder>();

View File

@ -131,8 +131,7 @@ namespace Ocelot.UnitTests.ServiceDiscovery
else
{
_registeredServices[serviceNameAndAddress.Name] = new List<Service>(){ serviceNameAndAddress };
}
}
}
}
}

View File

@ -0,0 +1,10 @@
namespace Ocelot.UnitTests
{
public class Wait
{
public static Waiter WaitFor(int milliSeconds)
{
return new Waiter(milliSeconds);
}
}
}

View File

@ -3,14 +3,6 @@ using System.Diagnostics;
namespace Ocelot.UnitTests
{
public class Wait
{
public static Waiter WaitFor(int milliSeconds)
{
return new Waiter(milliSeconds);
}
}
public class Waiter
{
private readonly int _milliSeconds;
@ -52,4 +44,4 @@ namespace Ocelot.UnitTests
return passed;
}
}
}
}