Can authorise routes based on claims, there is also a claims transformation middleware

This commit is contained in:
tom.pallister
2016-10-19 11:56:05 +01:00
parent 3285be3c73
commit b8951c4698
39 changed files with 700 additions and 294 deletions

View File

@ -21,14 +21,14 @@ namespace Ocelot.UnitTests.Configuration
private readonly Mock<IConfigurationValidator> _validator;
private Response<IOcelotConfiguration> _config;
private YamlConfiguration _yamlConfiguration;
private readonly Mock<IClaimToHeaderConfigurationParser> _configParser;
private readonly Mock<IClaimToThingConfigurationParser> _configParser;
private readonly Mock<ILogger<YamlOcelotConfigurationCreator>> _logger;
private readonly YamlOcelotConfigurationCreator _ocelotConfigurationCreator;
public YamlConfigurationCreatorTests()
{
_logger = new Mock<ILogger<YamlOcelotConfigurationCreator>>();
_configParser = new Mock<IClaimToHeaderConfigurationParser>();
_configParser = new Mock<IClaimToThingConfigurationParser>();
_validator = new Mock<IConfigurationValidator>();
_yamlConfig = new Mock<IOptions<YamlConfiguration>>();
_ocelotConfigurationCreator = new YamlOcelotConfigurationCreator(
@ -79,9 +79,9 @@ namespace Ocelot.UnitTests.Configuration
.WithRequireHttps(false)
.WithScopeSecret("secret")
.WithAuthenticationProviderScopeName("api")
.WithConfigurationHeaderExtractorProperties(new List<ClaimToHeader>
.WithClaimsToHeaders(new List<ClaimToThing>
{
new ClaimToHeader("CustomerId", "CustomerId", "", 0),
new ClaimToThing("CustomerId", "CustomerId", "", 0),
})
.Build()
};
@ -112,18 +112,18 @@ namespace Ocelot.UnitTests.Configuration
}
}))
.And(x => x.GivenTheYamlConfigIsValid())
.And(x => x.GivenTheConfigHeaderExtractorReturns(new ClaimToHeader("CustomerId", "CustomerId", "", 0)))
.And(x => x.GivenTheConfigHeaderExtractorReturns(new ClaimToThing("CustomerId", "CustomerId", "", 0)))
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheReRoutesAre(expected))
.And(x => x.ThenTheAuthenticationOptionsAre(expected))
.BDDfy();
}
private void GivenTheConfigHeaderExtractorReturns(ClaimToHeader expected)
private void GivenTheConfigHeaderExtractorReturns(ClaimToThing expected)
{
_configParser
.Setup(x => x.Extract(It.IsAny<string>(), It.IsAny<string>()))
.Returns(new OkResponse<ClaimToHeader>(expected));
.Returns(new OkResponse<ClaimToThing>(expected));
}
[Fact]