split DownstreamTemplate into DownstreamPathTemplate, DownstreamScheme, DownstreamHost and DownstreamPort in order to prepare for service discovery

This commit is contained in:
TomPallister
2017-01-21 09:59:47 +00:00
parent 044b609ea9
commit 0f71c040d9
53 changed files with 767 additions and 258 deletions

View File

@ -40,7 +40,10 @@ namespace Ocelot.AcceptanceTests
{
new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/",
DownstreamPathTemplate = "/",
DownstreamScheme = "http",
DownstreamHost = "localhost",
DownstreamPort = 51879,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
}
@ -56,6 +59,62 @@ namespace Ocelot.AcceptanceTests
.BDDfy();
}
[Fact]
public void should_return_response_200_when_path_missing_forward_slash_as_first_char()
{
var configuration = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamPathTemplate = "api/products",
DownstreamScheme = "http",
DownstreamHost = "localhost",
DownstreamPort = 51879,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
}
}
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879/api/products", 200, "Hello from Laura"))
.And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
.BDDfy();
}
[Fact]
public void should_return_response_200_when_host_has_trailing_slash()
{
var configuration = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamPathTemplate = "/api/products",
DownstreamScheme = "http",
DownstreamHost = "localhost/",
DownstreamPort = 51879,
UpstreamTemplate = "/",
UpstreamHttpMethod = "Get",
}
}
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879/api/products", 200, "Hello from Laura"))
.And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
.BDDfy();
}
[Fact]
public void should_not_care_about_no_trailing()
{
@ -65,7 +124,10 @@ namespace Ocelot.AcceptanceTests
{
new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/products",
DownstreamPathTemplate = "/products",
DownstreamScheme = "http",
DownstreamHost = "localhost",
DownstreamPort = 51879,
UpstreamTemplate = "/products/",
UpstreamHttpMethod = "Get",
}
@ -90,7 +152,10 @@ namespace Ocelot.AcceptanceTests
{
new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/products",
DownstreamPathTemplate = "/products",
DownstreamScheme = "http",
DownstreamHost = "localhost",
DownstreamPort = 51879,
UpstreamTemplate = "/products",
UpstreamHttpMethod = "Get",
}
@ -115,7 +180,10 @@ namespace Ocelot.AcceptanceTests
{
new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/products",
DownstreamPathTemplate = "/products",
DownstreamScheme = "http",
DownstreamHost = "localhost",
DownstreamPort = 51879,
UpstreamTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get",
}
@ -139,7 +207,10 @@ namespace Ocelot.AcceptanceTests
{
new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/api/products/{productId}",
DownstreamPathTemplate = "/api/products/{productId}",
DownstreamScheme = "http",
DownstreamHost = "localhost",
DownstreamPort = 51879,
UpstreamTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get"
}
@ -164,7 +235,10 @@ namespace Ocelot.AcceptanceTests
{
new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/",
DownstreamPathTemplate = "/",
DownstreamHost = "localhost",
DownstreamPort = 51879,
DownstreamScheme = "http",
UpstreamTemplate = "/",
UpstreamHttpMethod = "Post"
}
@ -189,8 +263,11 @@ namespace Ocelot.AcceptanceTests
{
new FileReRoute
{
DownstreamTemplate = "http://localhost:51879/newThing",
DownstreamPathTemplate = "/newThing",
UpstreamTemplate = "/newThing",
DownstreamScheme = "http",
DownstreamHost = "localhost",
DownstreamPort = 51879,
UpstreamHttpMethod = "Get",
}
}