mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-05-02 21:22:51 +08:00

* #340 started looking at supporting automatic routing when using service discovery * #340 getting old routing tests to pass * #340 renamed stuff to provider rather than finder, as its not longer finding anything * #340 working towards supporting dynamic routing * #340 loads of refactoring to make configuration work with dynamic routing * #340 refactor consul config code so the registry class owns it * #340 default to consul to maintain backwards compat * #340 added docs, finished this branches todos
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System.Collections.Generic;
|
|
using Ocelot.Configuration;
|
|
using Ocelot.Configuration.Builder;
|
|
using Ocelot.Configuration.Creator;
|
|
using Ocelot.Configuration.File;
|
|
using Shouldly;
|
|
using TestStack.BDDfy;
|
|
using Xunit;
|
|
|
|
namespace Ocelot.UnitTests.Configuration
|
|
{
|
|
public class ReRouteOptionsCreatorTests
|
|
{
|
|
private ReRouteOptionsCreator _creator;
|
|
private FileReRoute _reRoute;
|
|
private ReRouteOptions _result;
|
|
|
|
public ReRouteOptionsCreatorTests()
|
|
{
|
|
_creator = new ReRouteOptionsCreator();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_create_re_route_options()
|
|
{
|
|
var reRoute = new FileReRoute
|
|
{
|
|
RateLimitOptions = new FileRateLimitRule
|
|
{
|
|
EnableRateLimiting = true
|
|
},
|
|
AuthenticationOptions = new FileAuthenticationOptions()
|
|
{
|
|
AuthenticationProviderKey = "Test"
|
|
},
|
|
RouteClaimsRequirement = new Dictionary<string, string>()
|
|
{
|
|
{"",""}
|
|
},
|
|
FileCacheOptions = new FileCacheOptions
|
|
{
|
|
TtlSeconds = 1
|
|
}
|
|
};
|
|
|
|
var expected = new ReRouteOptionsBuilder()
|
|
.WithIsAuthenticated(true)
|
|
.WithIsAuthorised(true)
|
|
.WithIsCached(true)
|
|
.WithRateLimiting(true)
|
|
.Build();
|
|
|
|
this.Given(x => x.GivenTheFollowing(reRoute))
|
|
.When(x => x.WhenICreate())
|
|
.Then(x => x.ThenTheFollowingIsReturned(expected))
|
|
.BDDfy();
|
|
}
|
|
|
|
private void GivenTheFollowing(FileReRoute reRoute)
|
|
{
|
|
_reRoute = reRoute;
|
|
}
|
|
|
|
private void WhenICreate()
|
|
{
|
|
_result = _creator.Create(_reRoute);
|
|
}
|
|
|
|
private void ThenTheFollowingIsReturned(ReRouteOptions expected)
|
|
{
|
|
_result.IsAuthenticated.ShouldBe(expected.IsAuthenticated);
|
|
_result.IsAuthorised.ShouldBe(expected.IsAuthorised);
|
|
_result.IsCached.ShouldBe(expected.IsCached);
|
|
_result.EnableRateLimiting.ShouldBe(expected.EnableRateLimiting);
|
|
}
|
|
}
|
|
}
|