mirror of
https://github.com/alibaba/higress.git
synced 2026-06-02 00:57:28 +08:00
Fix the problem that ignoreUriCase does not work when the path type is prefix (#260)
Signed-off-by: charlie <qianglin98@qq.com>
This commit is contained in:
@@ -17,6 +17,8 @@ package ingressv1
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
networking "istio.io/api/networking/v1alpha3"
|
||||
v1 "k8s.io/api/networking/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -76,3 +78,38 @@ func TestShouldProcessIngressUpdate(t *testing.T) {
|
||||
t.Fatal("should be true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateHttpMatches(t *testing.T) {
|
||||
c := controller{}
|
||||
|
||||
tt := []struct {
|
||||
pathType common.PathType
|
||||
path string
|
||||
expect []*networking.HTTPMatchRequest
|
||||
}{
|
||||
{
|
||||
pathType: common.Prefix,
|
||||
path: "/foo",
|
||||
expect: []*networking.HTTPMatchRequest{
|
||||
{
|
||||
Uri: &networking.StringMatch{
|
||||
MatchType: &networking.StringMatch_Exact{Exact: "/foo"},
|
||||
},
|
||||
}, {
|
||||
Uri: &networking.StringMatch{
|
||||
MatchType: &networking.StringMatch_Prefix{Prefix: "/foo/"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testcase := range tt {
|
||||
httpMatches := c.generateHttpMatches(testcase.pathType, testcase.path, nil)
|
||||
for idx, httpMatch := range httpMatches {
|
||||
if diff := cmp.Diff(httpMatch, testcase.expect[idx]); diff != "" {
|
||||
t.Errorf("generateHttpMatches() mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user