-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#340 working towards supporting dynamic routing
- Loading branch information
Tom Gardham-Pallister
committed
May 10, 2018
1 parent
ed695e3
commit f564917
Showing
6 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/Ocelot.UnitTests/DownstreamRouteFinder/DownstreamRouteCreatorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Ocelot.DownstreamRouteFinder.Finder; | ||
using Xunit; | ||
using Shouldly; | ||
using Ocelot.Configuration; | ||
using System.Net.Http; | ||
|
||
namespace Ocelot.UnitTests.DownstreamRouteFinder | ||
{ | ||
public class DownstreamRouteCreatorTests | ||
{ | ||
private DownstreamRouteCreator _creator; | ||
|
||
public DownstreamRouteCreatorTests() | ||
{ | ||
_creator = new DownstreamRouteCreator(); | ||
} | ||
|
||
[Fact] | ||
public void should_create_downstream_route() | ||
{ | ||
var upstreamUrlPath = "/auth/test"; | ||
var upstreamHttpMethod = "GET"; | ||
IInternalConfiguration configuration = new InternalConfiguration(null, "doesnt matter", null, "doesnt matter"); | ||
var upstreamHost = "doesnt matter"; | ||
var result = _creator.Get(upstreamUrlPath, upstreamHttpMethod, configuration, upstreamHost); | ||
result.Data.ReRoute.DownstreamReRoute[0].DownstreamPathTemplate.Value.ShouldBe("/test"); | ||
result.Data.ReRoute.UpstreamHttpMethod[0].ShouldBe(HttpMethod.Get); | ||
result.Data.ReRoute.DownstreamReRoute[0].ServiceName.ShouldBe("auth"); | ||
result.Data.ReRoute.DownstreamReRoute[0].LoadBalancerKey.ShouldBe("/auth/test|GET"); | ||
} | ||
|
||
[Fact] | ||
public void should_create_downstream_route_and_remove_query_string() | ||
{ | ||
var upstreamUrlPath = "/auth/test?test=1&best=2"; | ||
var upstreamHttpMethod = "GET"; | ||
IInternalConfiguration configuration = new InternalConfiguration(null, "doesnt matter", null, "doesnt matter"); | ||
var upstreamHost = "doesnt matter"; | ||
var result = _creator.Get(upstreamUrlPath, upstreamHttpMethod, configuration, upstreamHost); | ||
result.Data.ReRoute.DownstreamReRoute[0].DownstreamPathTemplate.Value.ShouldBe("/test"); | ||
result.Data.ReRoute.UpstreamHttpMethod[0].ShouldBe(HttpMethod.Get); | ||
result.Data.ReRoute.DownstreamReRoute[0].ServiceName.ShouldBe("auth"); | ||
result.Data.ReRoute.DownstreamReRoute[0].LoadBalancerKey.ShouldBe("/auth/test?test=1&best=2|GET"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters