mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 01:58:15 +08:00
split DownstreamTemplate into DownstreamPathTemplate, DownstreamScheme, DownstreamHost and DownstreamPort in order to prepare for service discovery
This commit is contained in:
@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user