mirror of
https://github.com/alibaba/higress.git
synced 2026-04-21 20:17:29 +08:00
Sync inner fix (#634)
This commit is contained in:
@@ -77,16 +77,13 @@ func TestRewriteParse(t *testing.T) {
|
||||
},
|
||||
expect: &RewriteConfig{
|
||||
RewriteTarget: "/test",
|
||||
UseRegex: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
input: Annotations{
|
||||
buildNginxAnnotationKey(rewriteTarget): "",
|
||||
},
|
||||
expect: &RewriteConfig{
|
||||
UseRegex: false,
|
||||
},
|
||||
expect: &RewriteConfig{},
|
||||
},
|
||||
{
|
||||
input: Annotations{
|
||||
@@ -94,7 +91,6 @@ func TestRewriteParse(t *testing.T) {
|
||||
},
|
||||
expect: &RewriteConfig{
|
||||
RewriteTarget: "/\\2/\\1",
|
||||
UseRegex: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -113,6 +109,16 @@ func TestRewriteParse(t *testing.T) {
|
||||
RewriteHost: "test.com",
|
||||
},
|
||||
},
|
||||
{
|
||||
input: Annotations{
|
||||
buildNginxAnnotationKey(useRegex): "true",
|
||||
buildNginxAnnotationKey(rewriteTarget): "/$1",
|
||||
},
|
||||
expect: &RewriteConfig{
|
||||
UseRegex: true,
|
||||
RewriteTarget: "/\\1",
|
||||
},
|
||||
},
|
||||
{
|
||||
input: Annotations{
|
||||
buildNginxAnnotationKey(rewriteTarget): "/$2/$1",
|
||||
@@ -120,7 +126,6 @@ func TestRewriteParse(t *testing.T) {
|
||||
},
|
||||
expect: &RewriteConfig{
|
||||
RewriteTarget: "/\\2/\\1",
|
||||
UseRegex: true,
|
||||
RewriteHost: "test.com",
|
||||
},
|
||||
},
|
||||
@@ -330,6 +335,76 @@ func TestRewriteApplyRoute(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
config: &Ingress{
|
||||
Rewrite: &RewriteConfig{
|
||||
RewriteTarget: "/test",
|
||||
},
|
||||
},
|
||||
input: &networking.HTTPRoute{
|
||||
Match: []*networking.HTTPMatchRequest{
|
||||
{
|
||||
Uri: &networking.StringMatch{
|
||||
MatchType: &networking.StringMatch_Exact{
|
||||
Exact: "/exact",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expect: &networking.HTTPRoute{
|
||||
Match: []*networking.HTTPMatchRequest{
|
||||
{
|
||||
Uri: &networking.StringMatch{
|
||||
MatchType: &networking.StringMatch_Exact{
|
||||
Exact: "/exact",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Rewrite: &networking.HTTPRewrite{
|
||||
UriRegex: &networking.RegexMatchAndSubstitute{
|
||||
Pattern: "/exact",
|
||||
Substitution: "/test",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
config: &Ingress{
|
||||
Rewrite: &RewriteConfig{
|
||||
RewriteTarget: "/test",
|
||||
},
|
||||
},
|
||||
input: &networking.HTTPRoute{
|
||||
Match: []*networking.HTTPMatchRequest{
|
||||
{
|
||||
Uri: &networking.StringMatch{
|
||||
MatchType: &networking.StringMatch_Prefix{
|
||||
Prefix: "/prefix",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expect: &networking.HTTPRoute{
|
||||
Match: []*networking.HTTPMatchRequest{
|
||||
{
|
||||
Uri: &networking.StringMatch{
|
||||
MatchType: &networking.StringMatch_Prefix{
|
||||
Prefix: "/prefix",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Rewrite: &networking.HTTPRewrite{
|
||||
UriRegex: &networking.RegexMatchAndSubstitute{
|
||||
Pattern: "/prefix",
|
||||
Substitution: "/test",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, inputCase := range inputCases {
|
||||
|
||||
Reference in New Issue
Block a user