mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 15:30:49 +08:00 
			
		
		
		
	update .net core 3.0 RTM (#1025)
* feat: update to asp.net core 3.0 preview 9 * fix : AspDotNetLogger unittest * feat: update generic host and useMvc 1、Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing https://github.com/aspnet/AspNetCore/issues/9542 2、 use IHost and IHostBuilder * feat : update .net core 3.0 rc1 * eureka extension * fixed logger formatter error * fixed synchronous operations are disallowed of ReadToEnd method * fix log tests * Flush method of FakeStream should do nothing * Update ContentTests.cs * Fixed ws tests * feat: delelte comment code * feat: update .net core 3.0 RTM * Update OcelotBuilderTests.cs * Update .travis.yml mono 6.0.0 and dotnet 3.0.100 * Update Ocelot.IntegrationTests.csproj update Microsoft.Data.SQLite 3.0.0 * Update .travis.yml * feat: remove FrameworkReference 1、 remove FrameworkReference 2、 update package * add appveyor configuration to use version of VS2019 with dotnet core 3 sdk support * update obsoleted SetCollectionValidator method * Swap out OpenCover for Coverlet * Bump Cake to 0.35.0 * Downgrade coveralls.net to 0.7.0 Fix disposing of PollConsul instance * Remove environment specific path separator * Do not return ReportGenerator on Mac/Linux * Remove direct dependency on IInternalConfiguration * Fix ordering of variable assignment * Fix broken tests * Fix acceptance tests for Consul
This commit is contained in:
		@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
using Microsoft.AspNetCore.Http;
 | 
			
		||||
using Microsoft.Extensions.Configuration;
 | 
			
		||||
using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
using Microsoft.Extensions.Hosting;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
using Ocelot.Administration;
 | 
			
		||||
using Ocelot.Cache;
 | 
			
		||||
@@ -29,15 +30,15 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
        private HttpClient _httpClient;
 | 
			
		||||
        private readonly HttpClient _httpClientTwo;
 | 
			
		||||
        private HttpResponseMessage _response;
 | 
			
		||||
        private IWebHost _builder;
 | 
			
		||||
        private IWebHostBuilder _webHostBuilder;
 | 
			
		||||
        private IHost _builder;
 | 
			
		||||
        private IHostBuilder _webHostBuilder;
 | 
			
		||||
        private string _ocelotBaseUrl;
 | 
			
		||||
        private BearerToken _token;
 | 
			
		||||
        private IWebHostBuilder _webHostBuilderTwo;
 | 
			
		||||
        private IWebHost _builderTwo;
 | 
			
		||||
        private IWebHost _identityServerBuilder;
 | 
			
		||||
        private IWebHost _fooServiceBuilder;
 | 
			
		||||
        private IWebHost _barServiceBuilder;
 | 
			
		||||
        private IHostBuilder _webHostBuilderTwo;
 | 
			
		||||
        private IHost _builderTwo;
 | 
			
		||||
        private IHost _identityServerBuilder;
 | 
			
		||||
        private IHost _fooServiceBuilder;
 | 
			
		||||
        private IHost _barServiceBuilder;
 | 
			
		||||
 | 
			
		||||
        public AdministrationTests()
 | 
			
		||||
        {
 | 
			
		||||
@@ -220,7 +221,7 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                        UpstreamHttpMethod = new List<string> { "get" },
 | 
			
		||||
                        UpstreamPathTemplate = "/test"
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                },
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            var updatedConfiguration = new FileConfiguration
 | 
			
		||||
@@ -476,56 +477,59 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
 | 
			
		||||
        private void GivenThereIsAnIdentityServerOn(string url, string apiName)
 | 
			
		||||
        {
 | 
			
		||||
            _identityServerBuilder = new WebHostBuilder()
 | 
			
		||||
                .UseUrls(url)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .ConfigureServices(services =>
 | 
			
		||||
            _identityServerBuilder = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
                {
 | 
			
		||||
                    services.AddLogging();
 | 
			
		||||
                    services.AddIdentityServer()
 | 
			
		||||
                    .AddDeveloperSigningCredential()
 | 
			
		||||
                    webBuilder.UseUrls(url)
 | 
			
		||||
                    .UseKestrel()
 | 
			
		||||
                    .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                    .ConfigureServices(services =>
 | 
			
		||||
                    {
 | 
			
		||||
                        services.AddLogging();
 | 
			
		||||
                        services.AddIdentityServer()
 | 
			
		||||
                        .AddDeveloperSigningCredential()
 | 
			
		||||
                        .AddInMemoryApiResources(new List<ApiResource>
 | 
			
		||||
                        {
 | 
			
		||||
                            new ApiResource
 | 
			
		||||
                        new ApiResource
 | 
			
		||||
                        {
 | 
			
		||||
                            Name = apiName,
 | 
			
		||||
                            Description = apiName,
 | 
			
		||||
                            Enabled = true,
 | 
			
		||||
                            DisplayName = apiName,
 | 
			
		||||
                            Scopes = new List<Scope>()
 | 
			
		||||
                            {
 | 
			
		||||
                                Name = apiName,
 | 
			
		||||
                                Description = apiName,
 | 
			
		||||
                                Enabled = true,
 | 
			
		||||
                                DisplayName = apiName,
 | 
			
		||||
                                Scopes = new List<Scope>()
 | 
			
		||||
                                {
 | 
			
		||||
                                    new Scope(apiName)
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                                new Scope(apiName),
 | 
			
		||||
                            },
 | 
			
		||||
                        },
 | 
			
		||||
                        })
 | 
			
		||||
                        .AddInMemoryClients(new List<Client>
 | 
			
		||||
                        {
 | 
			
		||||
                            new Client
 | 
			
		||||
                            {
 | 
			
		||||
                                ClientId = apiName,
 | 
			
		||||
                                AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
 | 
			
		||||
                                ClientSecrets = new List<Secret> {new Secret("secret".Sha256())},
 | 
			
		||||
                                AllowedScopes = new List<string> { apiName },
 | 
			
		||||
                                AccessTokenType = AccessTokenType.Jwt,
 | 
			
		||||
                                Enabled = true
 | 
			
		||||
                            }
 | 
			
		||||
                        new Client
 | 
			
		||||
                        {
 | 
			
		||||
                            ClientId = apiName,
 | 
			
		||||
                            AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
 | 
			
		||||
                            ClientSecrets = new List<Secret> { new Secret("secret".Sha256()) },
 | 
			
		||||
                            AllowedScopes = new List<string> { apiName },
 | 
			
		||||
                            AccessTokenType = AccessTokenType.Jwt,
 | 
			
		||||
                            Enabled = true
 | 
			
		||||
                        },
 | 
			
		||||
                        })
 | 
			
		||||
                        .AddTestUsers(new List<TestUser>
 | 
			
		||||
                        {
 | 
			
		||||
                            new TestUser
 | 
			
		||||
                            {
 | 
			
		||||
                                Username = "test",
 | 
			
		||||
                                Password = "test",
 | 
			
		||||
                                SubjectId = "1231231"
 | 
			
		||||
                            }
 | 
			
		||||
                        new TestUser
 | 
			
		||||
                        {
 | 
			
		||||
                            Username = "test",
 | 
			
		||||
                            Password = "test",
 | 
			
		||||
                            SubjectId = "1231231"
 | 
			
		||||
                        },
 | 
			
		||||
                        });
 | 
			
		||||
                })
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UseIdentityServer();
 | 
			
		||||
                })
 | 
			
		||||
                .Build();
 | 
			
		||||
                    })
 | 
			
		||||
                    .Configure(app =>
 | 
			
		||||
                    {
 | 
			
		||||
                        app.UseIdentityServer();
 | 
			
		||||
                    }
 | 
			
		||||
                    );
 | 
			
		||||
                }).Build();
 | 
			
		||||
 | 
			
		||||
            _identityServerBuilder.Start();
 | 
			
		||||
 | 
			
		||||
@@ -540,28 +544,32 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
        {
 | 
			
		||||
            _httpClientTwo.BaseAddress = new Uri(baseUrl);
 | 
			
		||||
 | 
			
		||||
            _webHostBuilderTwo = new WebHostBuilder()
 | 
			
		||||
               .UseUrls(baseUrl)
 | 
			
		||||
               .UseKestrel()
 | 
			
		||||
               .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
               .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
               {
 | 
			
		||||
                   config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                   var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                   config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                       .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
 | 
			
		||||
                   config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                   config.AddEnvironmentVariables();
 | 
			
		||||
               })
 | 
			
		||||
               .ConfigureServices(x =>
 | 
			
		||||
               {
 | 
			
		||||
                   x.AddOcelot()
 | 
			
		||||
            _webHostBuilderTwo = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
                {
 | 
			
		||||
                    webBuilder.UseUrls(baseUrl)
 | 
			
		||||
                    .UseKestrel()
 | 
			
		||||
                    .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                    .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                        var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                        config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
 | 
			
		||||
                        config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                        config.AddEnvironmentVariables();
 | 
			
		||||
                    })
 | 
			
		||||
                    .ConfigureServices(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        x.AddMvc(option => option.EnableEndpointRouting = false);
 | 
			
		||||
                        x.AddOcelot()
 | 
			
		||||
                       .AddAdministration("/administration", "secret");
 | 
			
		||||
               })
 | 
			
		||||
               .Configure(app =>
 | 
			
		||||
               {
 | 
			
		||||
                   app.UseOcelot().Wait();
 | 
			
		||||
               });
 | 
			
		||||
                    })
 | 
			
		||||
                    .Configure(app =>
 | 
			
		||||
                    {
 | 
			
		||||
                        app.UseOcelot().Wait();
 | 
			
		||||
                    });
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            _builderTwo = _webHostBuilderTwo.Build();
 | 
			
		||||
 | 
			
		||||
@@ -654,29 +662,33 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
 | 
			
		||||
        private void GivenOcelotIsRunningWithIdentityServerSettings(Action<IdentityServerAuthenticationOptions> configOptions)
 | 
			
		||||
        {
 | 
			
		||||
            _webHostBuilder = new WebHostBuilder()
 | 
			
		||||
                .UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
            _webHostBuilder = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
                {
 | 
			
		||||
                    config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                    var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                    config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                    webBuilder.UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                    .UseKestrel()
 | 
			
		||||
                    .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                    .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                        var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                        config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
 | 
			
		||||
                    config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                    config.AddEnvironmentVariables();
 | 
			
		||||
                })
 | 
			
		||||
                .ConfigureServices(x =>
 | 
			
		||||
                {
 | 
			
		||||
                    x.AddSingleton(_webHostBuilder);
 | 
			
		||||
                    x.AddOcelot()
 | 
			
		||||
                    .AddAdministration("/administration", configOptions);
 | 
			
		||||
                })
 | 
			
		||||
                        config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                        config.AddEnvironmentVariables();
 | 
			
		||||
                    })
 | 
			
		||||
                    .ConfigureServices(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        x.AddMvc(option => option.EnableEndpointRouting = false);
 | 
			
		||||
                        x.AddSingleton(_webHostBuilder);
 | 
			
		||||
                        x.AddOcelot()
 | 
			
		||||
                        .AddAdministration("/administration", configOptions);
 | 
			
		||||
                    })
 | 
			
		||||
                    .Configure(app =>
 | 
			
		||||
                    {
 | 
			
		||||
                        app.UseOcelot().Wait();
 | 
			
		||||
                    });
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            _builder = _webHostBuilder.Build();
 | 
			
		||||
 | 
			
		||||
@@ -685,27 +697,31 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
 | 
			
		||||
        private void GivenOcelotIsRunning()
 | 
			
		||||
        {
 | 
			
		||||
            _webHostBuilder = new WebHostBuilder()
 | 
			
		||||
                .UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
            _webHostBuilder = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
                {
 | 
			
		||||
                    config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                    var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                    config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                    webBuilder.UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                    .UseKestrel()
 | 
			
		||||
                    .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                    .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                        var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                        config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
 | 
			
		||||
                    config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                    config.AddEnvironmentVariables();
 | 
			
		||||
                })
 | 
			
		||||
                .ConfigureServices(x =>
 | 
			
		||||
                {
 | 
			
		||||
                    x.AddOcelot()
 | 
			
		||||
                        config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                        config.AddEnvironmentVariables();
 | 
			
		||||
                    })
 | 
			
		||||
                    .ConfigureServices(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        x.AddMvc(s => s.EnableEndpointRouting = false);
 | 
			
		||||
                        x.AddOcelot()
 | 
			
		||||
                        .AddAdministration("/administration", "secret");
 | 
			
		||||
                })
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UseOcelot().Wait();
 | 
			
		||||
                    })
 | 
			
		||||
                    .Configure(app =>
 | 
			
		||||
                    {
 | 
			
		||||
                        app.UseOcelot().Wait();
 | 
			
		||||
                    });
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
            _builder = _webHostBuilder.Build();
 | 
			
		||||
@@ -715,30 +731,34 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
 | 
			
		||||
        private void GivenOcelotIsRunningWithNoWebHostBuilder(string baseUrl)
 | 
			
		||||
        {
 | 
			
		||||
            _webHostBuilder = new WebHostBuilder()
 | 
			
		||||
                .UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
            _webHostBuilder = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
                {
 | 
			
		||||
                    config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                    var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                    config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                    webBuilder.UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                    .UseKestrel()
 | 
			
		||||
                    .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                    .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                        var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                        config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
 | 
			
		||||
                    config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                    config.AddEnvironmentVariables();
 | 
			
		||||
                })
 | 
			
		||||
                .ConfigureServices(x =>
 | 
			
		||||
                {
 | 
			
		||||
                    x.AddSingleton(_webHostBuilder);
 | 
			
		||||
                    x.AddOcelot()
 | 
			
		||||
                        config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                        config.AddEnvironmentVariables();
 | 
			
		||||
                    })
 | 
			
		||||
                    .ConfigureServices(x =>
 | 
			
		||||
                    {
 | 
			
		||||
                        x.AddMvc(option => option.EnableEndpointRouting = false);
 | 
			
		||||
                        x.AddSingleton(_webHostBuilder);
 | 
			
		||||
                        x.AddOcelot()
 | 
			
		||||
                        .AddAdministration("/administration", "secret");
 | 
			
		||||
                })
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UseOcelot().Wait();
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                    })
 | 
			
		||||
                    .Configure(app =>
 | 
			
		||||
                    {
 | 
			
		||||
                        app.UseOcelot().Wait();
 | 
			
		||||
                    });
 | 
			
		||||
                });        
 | 
			
		||||
            
 | 
			
		||||
            _builder = _webHostBuilder.Build();
 | 
			
		||||
 | 
			
		||||
            _builder.Start();
 | 
			
		||||
@@ -797,42 +817,46 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
 | 
			
		||||
        private void GivenThereIsAFooServiceRunningOn(string baseUrl)
 | 
			
		||||
        {
 | 
			
		||||
            _fooServiceBuilder = new WebHostBuilder()
 | 
			
		||||
                .UseUrls(baseUrl)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .UseIISIntegration()
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
            _fooServiceBuilder = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UsePathBase("/foo");
 | 
			
		||||
                    app.Run(async context =>
 | 
			
		||||
                    webBuilder.UseUrls(baseUrl)
 | 
			
		||||
                    .UseKestrel()
 | 
			
		||||
                    .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                    .UseIISIntegration()
 | 
			
		||||
                    .Configure(app =>
 | 
			
		||||
                    {
 | 
			
		||||
                        context.Response.StatusCode = 200;
 | 
			
		||||
                        await context.Response.WriteAsync("foo");
 | 
			
		||||
                        app.UsePathBase("/foo");
 | 
			
		||||
                        app.Run(async context =>
 | 
			
		||||
                        {
 | 
			
		||||
                            context.Response.StatusCode = 200;
 | 
			
		||||
                            await context.Response.WriteAsync("foo");
 | 
			
		||||
                        });
 | 
			
		||||
                    });
 | 
			
		||||
                })
 | 
			
		||||
                .Build();
 | 
			
		||||
 | 
			
		||||
                }).Build();
 | 
			
		||||
            
 | 
			
		||||
            _fooServiceBuilder.Start();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GivenThereIsABarServiceRunningOn(string baseUrl)
 | 
			
		||||
        {
 | 
			
		||||
            _barServiceBuilder = new WebHostBuilder()
 | 
			
		||||
                .UseUrls(baseUrl)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                .UseIISIntegration()
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
            _barServiceBuilder = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UsePathBase("/bar");
 | 
			
		||||
                    app.Run(async context =>
 | 
			
		||||
                    webBuilder.UseUrls(baseUrl)
 | 
			
		||||
                    .UseKestrel()
 | 
			
		||||
                    .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
                    .UseIISIntegration()
 | 
			
		||||
                    .Configure(app =>
 | 
			
		||||
                    {
 | 
			
		||||
                        context.Response.StatusCode = 200;
 | 
			
		||||
                        await context.Response.WriteAsync("bar");
 | 
			
		||||
                        app.UsePathBase("/bar");
 | 
			
		||||
                        app.Run(async context =>
 | 
			
		||||
                        {
 | 
			
		||||
                            context.Response.StatusCode = 200;
 | 
			
		||||
                            await context.Response.WriteAsync("bar");
 | 
			
		||||
                        });
 | 
			
		||||
                    });
 | 
			
		||||
                })
 | 
			
		||||
                .Build();
 | 
			
		||||
                }).Build();
 | 
			
		||||
 | 
			
		||||
            _barServiceBuilder.Start();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
    using global::CacheManager.Core;
 | 
			
		||||
    using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
    using Microsoft.Extensions.Configuration;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Microsoft.Extensions.Hosting;
 | 
			
		||||
    using Microsoft.Extensions.Logging;
 | 
			
		||||
    using Newtonsoft.Json;
 | 
			
		||||
    using Ocelot.Administration;
 | 
			
		||||
@@ -25,15 +27,10 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
        private HttpClient _httpClient;
 | 
			
		||||
        private readonly HttpClient _httpClientTwo;
 | 
			
		||||
        private HttpResponseMessage _response;
 | 
			
		||||
        private IWebHost _builder;
 | 
			
		||||
        private IWebHostBuilder _webHostBuilder;
 | 
			
		||||
        private IHost _builder;
 | 
			
		||||
        private IHostBuilder _webHostBuilder;
 | 
			
		||||
        private string _ocelotBaseUrl;
 | 
			
		||||
        private BearerToken _token;
 | 
			
		||||
        private IWebHostBuilder _webHostBuilderTwo;
 | 
			
		||||
        private IWebHost _builderTwo;
 | 
			
		||||
        private IWebHost _identityServerBuilder;
 | 
			
		||||
        private IWebHost _fooServiceBuilder;
 | 
			
		||||
        private IWebHost _barServiceBuilder;
 | 
			
		||||
 | 
			
		||||
        public CacheManagerTests()
 | 
			
		||||
        {
 | 
			
		||||
@@ -61,7 +58,7 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                            {
 | 
			
		||||
                                Host = "localhost",
 | 
			
		||||
                                Port = 80,
 | 
			
		||||
                            }
 | 
			
		||||
                            },
 | 
			
		||||
                        },
 | 
			
		||||
                        DownstreamScheme = "https",
 | 
			
		||||
                        DownstreamPathTemplate = "/",
 | 
			
		||||
@@ -69,8 +66,8 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                        UpstreamPathTemplate = "/",
 | 
			
		||||
                        FileCacheOptions = new FileCacheOptions
 | 
			
		||||
                        {
 | 
			
		||||
                            TtlSeconds = 10
 | 
			
		||||
                        }
 | 
			
		||||
                            TtlSeconds = 10,
 | 
			
		||||
                        },
 | 
			
		||||
                    },
 | 
			
		||||
                    new FileReRoute()
 | 
			
		||||
                    {
 | 
			
		||||
@@ -80,7 +77,7 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                            {
 | 
			
		||||
                                Host = "localhost",
 | 
			
		||||
                                Port = 80,
 | 
			
		||||
                            }
 | 
			
		||||
                            },
 | 
			
		||||
                        },
 | 
			
		||||
                        DownstreamScheme = "https",
 | 
			
		||||
                        DownstreamPathTemplate = "/",
 | 
			
		||||
@@ -88,10 +85,10 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                        UpstreamPathTemplate = "/test",
 | 
			
		||||
                        FileCacheOptions = new FileCacheOptions
 | 
			
		||||
                        {
 | 
			
		||||
                            TtlSeconds = 10
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                            TtlSeconds = 10,
 | 
			
		||||
                        },
 | 
			
		||||
                    },
 | 
			
		||||
                },
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            var regionToClear = "gettest";
 | 
			
		||||
@@ -118,7 +115,7 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                new KeyValuePair<string, string>("client_id", "admin"),
 | 
			
		||||
                new KeyValuePair<string, string>("client_secret", "secret"),
 | 
			
		||||
                new KeyValuePair<string, string>("scope", "admin"),
 | 
			
		||||
                new KeyValuePair<string, string>("grant_type", "client_credentials")
 | 
			
		||||
                new KeyValuePair<string, string>("grant_type", "client_credentials"),
 | 
			
		||||
            };
 | 
			
		||||
            var content = new FormUrlEncodedContent(formData);
 | 
			
		||||
 | 
			
		||||
@@ -133,16 +130,13 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
 | 
			
		||||
        private void GivenOcelotIsRunning()
 | 
			
		||||
        {
 | 
			
		||||
            _webHostBuilder = new WebHostBuilder()
 | 
			
		||||
                .UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())
 | 
			
		||||
            _webHostBuilder = Host.CreateDefaultBuilder()
 | 
			
		||||
                .ConfigureAppConfiguration((hostingContext, config) =>
 | 
			
		||||
                {
 | 
			
		||||
                    config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
 | 
			
		||||
                    var env = hostingContext.HostingEnvironment;
 | 
			
		||||
                    config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
 | 
			
		||||
                        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
 | 
			
		||||
                    .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
 | 
			
		||||
                    config.AddJsonFile("ocelot.json", false, false);
 | 
			
		||||
                    config.AddEnvironmentVariables();
 | 
			
		||||
                })
 | 
			
		||||
@@ -151,20 +145,26 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                    Action<ConfigurationBuilderCachePart> settings = (s) =>
 | 
			
		||||
                    {
 | 
			
		||||
                        s.WithMicrosoftLogging(log =>
 | 
			
		||||
                            {
 | 
			
		||||
                                log.AddConsole(LogLevel.Debug);
 | 
			
		||||
                            })
 | 
			
		||||
                            .WithDictionaryHandle();
 | 
			
		||||
                        {
 | 
			
		||||
                             //log.AddConsole(LogLevel.Debug);
 | 
			
		||||
                         })
 | 
			
		||||
                        .WithDictionaryHandle();
 | 
			
		||||
                    };
 | 
			
		||||
 | 
			
		||||
                    x.AddMvc(option => option.EnableEndpointRouting = false);
 | 
			
		||||
                    x.AddOcelot()
 | 
			
		||||
                        .AddCacheManager(settings)
 | 
			
		||||
                        .AddAdministration("/administration", "secret");
 | 
			
		||||
                })
 | 
			
		||||
                    .AddCacheManager(settings)
 | 
			
		||||
                    .AddAdministration("/administration", "secret");
 | 
			
		||||
                })  
 | 
			
		||||
                .ConfigureWebHost(webBuilder =>
 | 
			
		||||
            {
 | 
			
		||||
                webBuilder.UseUrls(_ocelotBaseUrl)
 | 
			
		||||
                .UseKestrel()
 | 
			
		||||
                .UseContentRoot(Directory.GetCurrentDirectory())                
 | 
			
		||||
                .Configure(app =>
 | 
			
		||||
                {
 | 
			
		||||
                    app.UseOcelot().Wait();
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            _builder = _webHostBuilder.Build();
 | 
			
		||||
 | 
			
		||||
@@ -214,7 +214,7 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
            Environment.SetEnvironmentVariable("OCELOT_CERTIFICATE_PASSWORD", "");
 | 
			
		||||
            _builder?.Dispose();
 | 
			
		||||
            _httpClient?.Dispose();
 | 
			
		||||
            _identityServerBuilder?.Dispose();
 | 
			
		||||
            //_identityServerBuilder?.Dispose();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <VersionPrefix>0.0.0-dev</VersionPrefix>
 | 
			
		||||
    <TargetFramework>netcoreapp2.2</TargetFramework>
 | 
			
		||||
    <TargetFramework>netcoreapp3.0</TargetFramework>
 | 
			
		||||
    <AssemblyName>Ocelot.IntegrationTests</AssemblyName>
 | 
			
		||||
    <OutputType>Exe</OutputType>
 | 
			
		||||
    <PackageId>Ocelot.IntegrationTests</PackageId>
 | 
			
		||||
@@ -29,30 +29,33 @@
 | 
			
		||||
    <ProjectReference Include="..\..\src\Ocelot.Provider.Polly\Ocelot.Provider.Polly.csproj" />
 | 
			
		||||
    <ProjectReference Include="..\..\src\Ocelot.Provider.Rafty\Ocelot.Provider.Rafty.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.App" />
 | 
			
		||||
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Data.SQLite" Version="2.2.4" />
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
 | 
			
		||||
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Data.SQLite" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
 | 
			
		||||
      <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
 | 
			
		||||
      <PrivateAssets>all</PrivateAssets>
 | 
			
		||||
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
 | 
			
		||||
    </PackageReference>
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
 | 
			
		||||
    <PackageReference Include="xunit" Version="2.4.1" />
 | 
			
		||||
    <PackageReference Include="Shouldly" Version="3.0.2" />
 | 
			
		||||
    <PackageReference Include="Shouldly" Version="4.0.0-beta0002" />
 | 
			
		||||
    <PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Data.SQLite" Version="2.2.4" />
 | 
			
		||||
    <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
 | 
			
		||||
    <PackageReference Include="IdentityServer4" Version="2.4.0" />
 | 
			
		||||
    <PackageReference Include="Microsoft.Data.SQLite" Version="3.0.0" />
 | 
			
		||||
    <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
 | 
			
		||||
    <PackageReference Include="IdentityServer4" Version="3.0.1" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
@@ -54,12 +54,12 @@ namespace Ocelot.IntegrationTests
 | 
			
		||||
                                {
 | 
			
		||||
                                    Host = "localhost",
 | 
			
		||||
                                    Port = 51879,
 | 
			
		||||
                                }
 | 
			
		||||
                                },
 | 
			
		||||
                            },
 | 
			
		||||
                            UpstreamPathTemplate = "/",
 | 
			
		||||
                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                        },
 | 
			
		||||
                    },
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            this.Given(x => GivenThereIsAConfiguration(configuration))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user