-
Notifications
You must be signed in to change notification settings - Fork 894
Open
Labels
Type: BugSomething isn't workingSomething isn't workingneeds-author-actionAn issue or pull request that requires more info or actions from the author.An issue or pull request that requires more info or actions from the author.
Description
Describe the bug
@miaxzhitong found an issue when Ingress rule with Exact Path "/foo" matches a request "/foo/" (and the other way around too). Per https://kubernetes.io/docs/concepts/services-networking/ingress/#examples it should not match:
Kind | Path(s) | Request path(s) | Matches? |
---|---|---|---|
Exact | /foo | /foo/ | No |
Exact | /foo/ | /foo | No |
To Reproduce
Define ingress rule
spec:
rules:
- http:
paths:
- backend:
service:
name: bar
port:
number: 443
path: /foo/
pathType: Exact
Send a request "/foo".
or with unit test:
[Fact]
public async Task ExactPathRouting_Works()
{
var routes = new[]
{
new RouteConfig()
{
RouteId = "route1",
ClusterId = "cluster1",
Match = new RouteMatch { Path = "/api" }
}
};
using var host = await CreateHostAsync(routes);
var client = host.GetTestClient();
// Positive
var response = await client.GetAsync("/api");
response.EnsureSuccessStatusCode();
Assert.Equal("route1", response.Headers.GetValues("route").SingleOrDefault());
// Negative
response = await client.GetAsync("/api/");
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
Further technical details
Related to dotnet/aspnetcore#4220
Metadata
Metadata
Assignees
Labels
Type: BugSomething isn't workingSomething isn't workingneeds-author-actionAn issue or pull request that requires more info or actions from the author.An issue or pull request that requires more info or actions from the author.