mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 23:28:15 +08:00
changed file config stuff to just use app base directory
This commit is contained in:
@ -36,7 +36,6 @@ namespace Ocelot.AcceptanceTests
|
||||
.And(x => _steps.GivenOcelotIsRunning())
|
||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/administration/configuration"))
|
||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||
.And(x => _steps.ThenTheResponseBodyShouldBe("hi from re routes controller"))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
@ -56,7 +55,18 @@ namespace Ocelot.AcceptanceTests
|
||||
DownstreamHost = "localhost",
|
||||
DownstreamPort = 80,
|
||||
DownstreamScheme = "https",
|
||||
DownstreamPathTemplate = "/"
|
||||
DownstreamPathTemplate = "/",
|
||||
UpstreamHttpMethod = "get",
|
||||
UpstreamPathTemplate = "/"
|
||||
},
|
||||
new FileReRoute()
|
||||
{
|
||||
DownstreamHost = "localhost",
|
||||
DownstreamPort = 80,
|
||||
DownstreamScheme = "https",
|
||||
DownstreamPathTemplate = "/",
|
||||
UpstreamHttpMethod = "get",
|
||||
UpstreamPathTemplate = "/test"
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -69,27 +79,6 @@ namespace Ocelot.AcceptanceTests
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenThereIsAServiceRunningOn(string url, int statusCode, string responseBody)
|
||||
{
|
||||
_builder = new WebHostBuilder()
|
||||
.UseUrls(url)
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseIISIntegration()
|
||||
.UseUrls(url)
|
||||
.Configure(app =>
|
||||
{
|
||||
app.Run(async context =>
|
||||
{
|
||||
context.Response.StatusCode = statusCode;
|
||||
await context.Response.WriteAsync(responseBody);
|
||||
});
|
||||
})
|
||||
.Build();
|
||||
|
||||
_builder.Start();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_builder?.Dispose();
|
||||
|
@ -31,7 +31,7 @@ namespace Ocelot.AcceptanceTests
|
||||
private BearerToken _token;
|
||||
public HttpClient OcelotClient => _ocelotClient;
|
||||
public string RequestIdKey = "OcRequestId";
|
||||
private Random _random;
|
||||
private readonly Random _random;
|
||||
|
||||
public Steps()
|
||||
{
|
||||
@ -91,6 +91,8 @@ namespace Ocelot.AcceptanceTests
|
||||
response.ReRoutes[i].DownstreamPathTemplate.ShouldBe(expected.ReRoutes[i].DownstreamPathTemplate);
|
||||
response.ReRoutes[i].DownstreamPort.ShouldBe(expected.ReRoutes[i].DownstreamPort);
|
||||
response.ReRoutes[i].DownstreamScheme.ShouldBe(expected.ReRoutes[i].DownstreamScheme);
|
||||
response.ReRoutes[i].UpstreamPathTemplate.ShouldBe(expected.ReRoutes[i].UpstreamPathTemplate);
|
||||
response.ReRoutes[i].UpstreamHttpMethod.ShouldBe(expected.ReRoutes[i].UpstreamHttpMethod);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,36 +1,9 @@
|
||||
namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
|
||||
namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
public static class TestConfiguration
|
||||
{
|
||||
public static double Version => 1.1;
|
||||
public static string ConfigurationPath => GetConfigurationPath();
|
||||
|
||||
public static string GetConfigurationPath()
|
||||
{
|
||||
var osArchitecture = RuntimeInformation.OSArchitecture.ToString();
|
||||
|
||||
if(RuntimeInformation.OSDescription.ToLower().Contains("darwin"))
|
||||
{
|
||||
return FormatConfigurationPath("osx.10.11", osArchitecture);
|
||||
}
|
||||
|
||||
if(RuntimeInformation.OSDescription.ToLower().Contains("microsoft windows 10"))
|
||||
{
|
||||
return FormatConfigurationPath("win10", osArchitecture);
|
||||
}
|
||||
|
||||
return FormatConfigurationPath("win7", osArchitecture);
|
||||
}
|
||||
|
||||
private static string FormatConfigurationPath(string oSDescription, string osArchitecture)
|
||||
{
|
||||
var runTime = $"{oSDescription}-{osArchitecture}".ToLower();
|
||||
|
||||
var configPath = $"./test/Ocelot.AcceptanceTests/bin/Debug/netcoreapp{Version}/{runTime}/configuration.json";
|
||||
|
||||
return configPath;
|
||||
}
|
||||
public static string ConfigurationPath => $"{AppContext.BaseDirectory}/configuration.json";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user