mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 16:18:14 +08:00
Merge branch 'develop' into feature/#238-statefull
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
new ApiResource
|
||||
{
|
||||
Name = apiName,
|
||||
Name = apiName,
|
||||
Description = "My API",
|
||||
Enabled = true,
|
||||
DisplayName = "test",
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -186,7 +186,6 @@ namespace Ocelot.AcceptanceTests
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
|
||||
private void GivenThereIsAServiceRunningOn(string baseUrl, string basePath, int statusCode, string headerKey)
|
||||
{
|
||||
_builder = new WebHostBuilder()
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +159,7 @@ namespace Ocelot.AcceptanceTests
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
await context.Response.WriteAsync(exception.StackTrace);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
.Build();
|
||||
|
@ -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>
|
||||
|
@ -51,8 +51,7 @@ namespace Ocelot.AcceptanceTests
|
||||
ExceptionsAllowedBeforeBreaking = 1,
|
||||
TimeoutValue = 500,
|
||||
DurationOfBreak = 1000
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -58,7 +58,6 @@ namespace Ocelot.AcceptanceTests
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void should_return_response_200_with_simple_url_and_hosts_match_multiple_re_routes()
|
||||
{
|
||||
|
Reference in New Issue
Block a user