diff --git a/src/MMLib.SwaggerForOcelot/RouteOptionsExtensions.cs b/src/MMLib.SwaggerForOcelot/RouteOptionsExtensions.cs index 0603894..df06f65 100644 --- a/src/MMLib.SwaggerForOcelot/RouteOptionsExtensions.cs +++ b/src/MMLib.SwaggerForOcelot/RouteOptionsExtensions.cs @@ -69,6 +69,7 @@ public static IEnumerable ExpandConfig( DownstreamHttpVersion = routeOption.DownstreamHttpVersion, DownstreamScheme = routeOption.DownstreamScheme, AuthenticationOptions = routeOption.AuthenticationOptions, + DangerousAcceptAnyServerCertificateValidator = routeOption.DangerousAcceptAnyServerCertificateValidator }); routeOptions.AddRange(versionMappedRouteOptions); } diff --git a/tests/MMLib.SwaggerForOcelot.Tests/RouteOptionsExtensionsShould.cs b/tests/MMLib.SwaggerForOcelot.Tests/RouteOptionsExtensionsShould.cs index 54a9f81..b1cd34d 100644 --- a/tests/MMLib.SwaggerForOcelot.Tests/RouteOptionsExtensionsShould.cs +++ b/tests/MMLib.SwaggerForOcelot.Tests/RouteOptionsExtensionsShould.cs @@ -52,5 +52,71 @@ public void GroupRoutesByPaths() .Should() .BeEquivalentTo("Get", "Post"); } + + [Fact] + public void ExpandConfig() + { + IEnumerable routeOptions = new List() + { + new RouteOptions(){ + DownstreamPathTemplate= "/api/{version}/masterdatatype", + UpstreamPathTemplate = "/masterdatatype", + UpstreamHttpMethod = new HashSet(){ "Get"}, + DangerousAcceptAnyServerCertificateValidator = true + }, + new RouteOptions(){ + DownstreamPathTemplate= "/api/{version}/masterdatatype", + UpstreamPathTemplate = "/masterdatatype", + UpstreamHttpMethod = new HashSet(){ "Post"}, + DangerousAcceptAnyServerCertificateValidator = true + }, + new RouteOptions(){ + DownstreamPathTemplate= "/api/{version}/masterdatatype/{everything}", + UpstreamPathTemplate = "/masterdatatype/{everything}", + UpstreamHttpMethod = new HashSet(){ "Delete"}, + DangerousAcceptAnyServerCertificateValidator = true + }, + new RouteOptions(){ + DownstreamPathTemplate= "/api/{version}/masterdatatype/{everything}", + UpstreamPathTemplate = "/masterdatatype/{everything}", + UpstreamHttpMethod = new HashSet(){ "Delete"}, + VirtualDirectory = "something", + DangerousAcceptAnyServerCertificateValidator = true + }, + new RouteOptions(){ + DownstreamPathTemplate= "/api/{version}/masterdata", + UpstreamPathTemplate = "/masterdata", + UpstreamHttpMethod = new HashSet(){ "Delete"}, + DangerousAcceptAnyServerCertificateValidator = true + }, + }; + + SwaggerEndPointOptions swaggerEndPointOptions = new() + { + Config = new List() + { + new SwaggerEndPointConfig() + { + Version = "v1" + } + } + }; + + IEnumerable actual = routeOptions.ExpandConfig(swaggerEndPointOptions); + + actual + .Should() + .HaveCount(5); + actual + .First() + .DownstreamPathTemplate + .Should() + .Contain("v1"); + actual + .First() + .DangerousAcceptAnyServerCertificateValidator + .Should() + .BeTrue(); + } } }