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

@ -10,8 +10,8 @@ namespace Ocelot.UnitTests.Configuration
{
public class ConfigurationValidationTests
{
private FileConfiguration _fileConfiguration;
private readonly IConfigurationValidator _configurationValidator;
private FileConfiguration _fileConfiguration;
private Response<ConfigurationValidationResult> _result;
public ConfigurationValidationTests()
@ -22,32 +22,13 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_invalid_if_scheme_in_downstream_template()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration()
this.Given(x => x.GivenAConfiguration(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamTemplate = "http://www.bbc.co.uk/api/products/{productId}",
UpstreamTemplate = "http://asdf.com"
}
}
}))
.When(x => x.WhenIValidateTheConfiguration())
.Then(x => x.ThenTheResultIsNotValid())
.BDDfy();
}
[Fact]
public void configuration_is_invalid_if_host_in_downstream_template()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration()
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamTemplate = "www.bbc.co.uk/api/products/{productId}",
DownstreamPathTemplate = "http://www.bbc.co.uk/api/products/{productId}",
UpstreamTemplate = "http://asdf.com"
}
}
@ -60,13 +41,13 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_valid_with_one_reroute()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration()
this.Given(x => x.GivenAConfiguration(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamTemplate = "/api/products/",
DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com"
}
}
@ -79,13 +60,13 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_valid_with_valid_authentication_provider()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration()
this.Given(x => x.GivenAConfiguration(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamTemplate = "/api/products/",
DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com",
AuthenticationOptions = new FileAuthenticationOptions
{
@ -102,13 +83,13 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_invalid_with_invalid_authentication_provider()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration()
this.Given(x => x.GivenAConfiguration(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamTemplate = "/api/products/",
DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com",
AuthenticationOptions = new FileAuthenticationOptions
{
@ -126,25 +107,25 @@ namespace Ocelot.UnitTests.Configuration
[Fact]
public void configuration_is_not_valid_with_duplicate_reroutes()
{
this.Given(x => x.GivenAConfiguration(new FileConfiguration()
this.Given(x => x.GivenAConfiguration(new FileConfiguration
{
ReRoutes = new List<FileReRoute>
{
new FileReRoute
{
DownstreamTemplate = "/api/products/",
DownstreamPathTemplate = "/api/products/",
UpstreamTemplate = "http://asdf.com"
},
new FileReRoute
{
DownstreamTemplate = "http://www.bbc.co.uk",
DownstreamPathTemplate = "http://www.bbc.co.uk",
UpstreamTemplate = "http://asdf.com"
}
}
}))
.When(x => x.WhenIValidateTheConfiguration())
.Then(x => x.ThenTheResultIsNotValid())
.And(x => x.ThenTheErrorIs<DownstreamTemplateAlreadyUsedError>())
.And(x => x.ThenTheErrorIs<DownstreamPathTemplateAlreadyUsedError>())
.BDDfy();
}
@ -173,4 +154,4 @@ namespace Ocelot.UnitTests.Configuration
_result.Data.Errors[0].ShouldBeOfType<T>();
}
}
}
}