mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 12:58:16 +08:00
more work towards getting identity server and admin area set up
This commit is contained in:
@ -11,6 +11,7 @@ using CacheManager.Core;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Ocelot.Configuration.File;
|
||||
@ -32,6 +33,7 @@ namespace Ocelot.AcceptanceTests
|
||||
public HttpClient OcelotClient => _ocelotClient;
|
||||
public string RequestIdKey = "OcRequestId";
|
||||
private readonly Random _random;
|
||||
private IWebHostBuilder _webHostBuilder;
|
||||
|
||||
public Steps()
|
||||
{
|
||||
@ -69,7 +71,14 @@ namespace Ocelot.AcceptanceTests
|
||||
/// </summary>
|
||||
public void GivenOcelotIsRunning()
|
||||
{
|
||||
_ocelotServer = new TestServer(new WebHostBuilder()
|
||||
_webHostBuilder = new WebHostBuilder();
|
||||
|
||||
_webHostBuilder.ConfigureServices(s =>
|
||||
{
|
||||
s.AddSingleton(_webHostBuilder);
|
||||
});
|
||||
|
||||
_ocelotServer = new TestServer(_webHostBuilder
|
||||
.UseStartup<Startup>());
|
||||
|
||||
_ocelotClient = _ocelotServer.CreateClient();
|
||||
@ -109,7 +118,14 @@ namespace Ocelot.AcceptanceTests
|
||||
|
||||
var configuration = builder.Build();
|
||||
|
||||
_ocelotServer = new TestServer(new WebHostBuilder()
|
||||
_webHostBuilder = new WebHostBuilder();
|
||||
|
||||
_webHostBuilder.ConfigureServices(s =>
|
||||
{
|
||||
s.AddSingleton(_webHostBuilder);
|
||||
});
|
||||
|
||||
_ocelotServer = new TestServer(_webHostBuilder
|
||||
.UseConfiguration(configuration)
|
||||
.ConfigureServices(s =>
|
||||
{
|
||||
@ -121,7 +137,7 @@ namespace Ocelot.AcceptanceTests
|
||||
})
|
||||
.WithDictionaryHandle();
|
||||
};
|
||||
|
||||
|
||||
s.AddOcelotOutputCaching(settings);
|
||||
s.AddOcelotFileConfiguration(configuration);
|
||||
s.AddOcelot();
|
||||
|
@ -5,6 +5,7 @@ using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using Ocelot.Configuration.File;
|
||||
using Ocelot.ManualTest;
|
||||
@ -19,6 +20,7 @@ namespace Ocelot.IntegrationTests
|
||||
private readonly HttpClient _httpClient;
|
||||
private HttpResponseMessage _response;
|
||||
private IWebHost _builder;
|
||||
private IWebHostBuilder _webHostBuilder;
|
||||
private readonly string _ocelotBaseUrl;
|
||||
private BearerToken _token;
|
||||
|
||||
@ -246,12 +248,16 @@ namespace Ocelot.IntegrationTests
|
||||
|
||||
private void GivenOcelotIsRunning()
|
||||
{
|
||||
_builder = new WebHostBuilder()
|
||||
_webHostBuilder = new WebHostBuilder()
|
||||
.UseUrls(_ocelotBaseUrl)
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
.ConfigureServices(x => {
|
||||
x.AddSingleton(_webHostBuilder);
|
||||
})
|
||||
.UseStartup<Startup>();
|
||||
|
||||
_builder = _webHostBuilder.Build();
|
||||
|
||||
_builder.Start();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Ocelot.ManualTest
|
||||
{
|
||||
@ -7,11 +8,17 @@ namespace Ocelot.ManualTest
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
IWebHostBuilder builder = new WebHostBuilder();
|
||||
|
||||
builder.ConfigureServices(s => {
|
||||
s.AddSingleton(builder);
|
||||
});
|
||||
|
||||
builder.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
.UseStartup<Startup>();
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
host.Run();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ocelot.Configuration.Provider;
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
|
||||
@ -14,6 +15,8 @@ namespace Ocelot.ManualTest
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
private IdentityServerConfiguration _identityServerConfig;
|
||||
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
@ -24,6 +27,9 @@ namespace Ocelot.ManualTest
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
Configuration = builder.Build();
|
||||
|
||||
var identityServerConfigProvider = new HardCodedIdentityServerConfigurationProvider();
|
||||
_identityServerConfig = identityServerConfigProvider.Get();
|
||||
}
|
||||
|
||||
public IConfigurationRoot Configuration { get; }
|
||||
@ -41,14 +47,14 @@ namespace Ocelot.ManualTest
|
||||
|
||||
services.AddOcelotOutputCaching(settings);
|
||||
services.AddOcelotFileConfiguration(Configuration);
|
||||
services.AddOcelot();
|
||||
services.AddOcelot(_identityServerConfig);
|
||||
}
|
||||
|
||||
public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
|
||||
await app.UseOcelot();
|
||||
await app.UseOcelot(_identityServerConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user