Skip to content

Commit

Permalink
Updated RouteOptionsExtensions.ExpandConfig to respect DangerousAccep…
Browse files Browse the repository at this point in the history
…tAnyServerCertificateValidator
  • Loading branch information
jhines-sf committed Aug 30, 2023
1 parent 32c549f commit b38e201
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/MMLib.SwaggerForOcelot/RouteOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public static IEnumerable<RouteOptions> ExpandConfig(
DownstreamHttpVersion = routeOption.DownstreamHttpVersion,
DownstreamScheme = routeOption.DownstreamScheme,
AuthenticationOptions = routeOption.AuthenticationOptions,
DangerousAcceptAnyServerCertificateValidator = routeOption.DangerousAcceptAnyServerCertificateValidator
});
routeOptions.AddRange(versionMappedRouteOptions);
}
Expand Down
66 changes: 66 additions & 0 deletions tests/MMLib.SwaggerForOcelot.Tests/RouteOptionsExtensionsShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,71 @@ public void GroupRoutesByPaths()
.Should()
.BeEquivalentTo("Get", "Post");
}

[Fact]
public void ExpandConfig()
{
IEnumerable<RouteOptions> routeOptions = new List<RouteOptions>()
{
new RouteOptions(){
DownstreamPathTemplate= "/api/{version}/masterdatatype",
UpstreamPathTemplate = "/masterdatatype",
UpstreamHttpMethod = new HashSet<string>(){ "Get"},
DangerousAcceptAnyServerCertificateValidator = true
},
new RouteOptions(){
DownstreamPathTemplate= "/api/{version}/masterdatatype",
UpstreamPathTemplate = "/masterdatatype",
UpstreamHttpMethod = new HashSet<string>(){ "Post"},
DangerousAcceptAnyServerCertificateValidator = true
},
new RouteOptions(){
DownstreamPathTemplate= "/api/{version}/masterdatatype/{everything}",
UpstreamPathTemplate = "/masterdatatype/{everything}",
UpstreamHttpMethod = new HashSet<string>(){ "Delete"},
DangerousAcceptAnyServerCertificateValidator = true
},
new RouteOptions(){
DownstreamPathTemplate= "/api/{version}/masterdatatype/{everything}",
UpstreamPathTemplate = "/masterdatatype/{everything}",
UpstreamHttpMethod = new HashSet<string>(){ "Delete"},
VirtualDirectory = "something",
DangerousAcceptAnyServerCertificateValidator = true
},
new RouteOptions(){
DownstreamPathTemplate= "/api/{version}/masterdata",
UpstreamPathTemplate = "/masterdata",
UpstreamHttpMethod = new HashSet<string>(){ "Delete"},
DangerousAcceptAnyServerCertificateValidator = true
},
};

SwaggerEndPointOptions swaggerEndPointOptions = new()
{
Config = new List<SwaggerEndPointConfig>()
{
new SwaggerEndPointConfig()
{
Version = "v1"
}
}
};

IEnumerable<RouteOptions> actual = routeOptions.ExpandConfig(swaggerEndPointOptions);

actual
.Should()
.HaveCount(5);
actual
.First()
.DownstreamPathTemplate
.Should()
.Contain("v1");
actual
.First()
.DangerousAcceptAnyServerCertificateValidator
.Should()
.BeTrue();
}
}
}

0 comments on commit b38e201

Please sign in to comment.