Skip to content

Commit e16335d

Browse files
committed
Wrote unit test to verify when bug is fixed
1 parent 1288df8 commit e16335d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@ public async Task MapOpenApi_Returns404ForUnresolvedDocument()
132132
Assert.Equal("No OpenAPI document with the name 'v2' was found.", Encoding.UTF8.GetString(responseBodyStream.ToArray()));
133133
}
134134

135+
[Theory]
136+
[InlineData("CaseSensitive", "casesensitive")]
137+
[InlineData("casesensitive", "CaseSensitive")]
138+
public async Task MapOpenApi_ReturnsDocumentWhenPathIsCaseSensitive(string registeredDocumentName, string requestedDocumentName)
139+
{
140+
// Arrange
141+
var serviceProvider = CreateServiceProvider(registeredDocumentName);
142+
var builder = new DefaultEndpointRouteBuilder(new ApplicationBuilder(serviceProvider));
143+
builder.MapOpenApi("/openapi/{documentName}.json");
144+
var context = new DefaultHttpContext();
145+
var responseBodyStream = new MemoryStream();
146+
context.Response.Body = responseBodyStream;
147+
context.RequestServices = serviceProvider;
148+
context.Request.RouteValues.Add("documentName", requestedDocumentName);
149+
var endpoint = builder.DataSources.First().Endpoints[0];
150+
151+
// Act
152+
var requestDelegate = endpoint.RequestDelegate;
153+
await requestDelegate(context);
154+
155+
// Assert
156+
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
157+
}
158+
135159
[Theory]
136160
[InlineData("/openapi.json", "application/json;charset=utf-8", false)]
137161
[InlineData("/openapi.yaml", "text/plain+yaml;charset=utf-8", true)]

0 commit comments

Comments
 (0)