mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-08-04 12:58:00 +08:00
add file configuration fluent validation and change default configura… (#168)
* add file configuration fluent validation and change default configuration validator to fluent validator * add file validation failed error code * change authentication schemes check to async * beautify the code ^_^ * clean file validation and fix test failure.
This commit is contained in:
@ -15,17 +15,17 @@ using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
public class ConfigurationValidationTests
|
||||
public class ConfigurationFluentValidationTests
|
||||
{
|
||||
private readonly IConfigurationValidator _configurationValidator;
|
||||
private FileConfiguration _fileConfiguration;
|
||||
private Response<ConfigurationValidationResult> _result;
|
||||
private Mock<IAuthenticationSchemeProvider> _provider;
|
||||
|
||||
public ConfigurationValidationTests()
|
||||
public ConfigurationFluentValidationTests()
|
||||
{
|
||||
_provider = new Mock<IAuthenticationSchemeProvider>();
|
||||
_configurationValidator = new FileConfigurationValidator(_provider.Object);
|
||||
_provider = new Mock<IAuthenticationSchemeProvider>();
|
||||
_configurationValidator = new FileConfigurationFluentValidator(_provider.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -44,6 +44,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}))
|
||||
.When(x => x.WhenIValidateTheConfiguration())
|
||||
.Then(x => x.ThenTheResultIsNotValid())
|
||||
.Then(x => x.ThenTheErrorIs<FileValidationFailedError>())
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
@ -147,7 +148,6 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}))
|
||||
.When(x => x.WhenIValidateTheConfiguration())
|
||||
.Then(x => x.ThenTheResultIsNotValid())
|
||||
.And(x => x.ThenTheErrorIs<UnsupportedAuthenticationProviderError>())
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
@ -172,10 +172,10 @@ namespace Ocelot.UnitTests.Configuration
|
||||
}))
|
||||
.When(x => x.WhenIValidateTheConfiguration())
|
||||
.Then(x => x.ThenTheResultIsNotValid())
|
||||
.And(x => x.ThenTheErrorIs<DownstreamPathTemplateAlreadyUsedError>())
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
|
||||
private void GivenAConfiguration(FileConfiguration fileConfiguration)
|
||||
{
|
||||
_fileConfiguration = fileConfiguration;
|
||||
@ -225,6 +225,5 @@ namespace Ocelot.UnitTests.Configuration
|
||||
return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -503,7 +503,7 @@ namespace Ocelot.UnitTests.Configuration
|
||||
[Fact]
|
||||
public void should_return_validation_errors()
|
||||
{
|
||||
var errors = new List<Error> {new PathTemplateDoesntStartWithForwardSlash("some message")};
|
||||
var errors = new List<Error> {new FileValidationFailedError("some message")};
|
||||
|
||||
this.Given(x => x.GivenTheConfigIs(new FileConfiguration()))
|
||||
.And(x => x.GivenTheConfigIsInvalid(errors))
|
||||
|
Reference in New Issue
Block a user