Skip to content

Commit febeeba

Browse files
committed
update conformance tests to support 307/308 redirects
Signed-off-by: Dave Winiarski <[email protected]>
1 parent aff0586 commit febeeba

12 files changed

+383
-1
lines changed

conformance/tests/httproute-redirect-host-and-status.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,30 @@ var HTTPRouteRedirectHostAndStatus = suite.ConformanceTest{
7272
Host: "example.org",
7373
},
7474
Namespace: ns,
75+
}, {
76+
Request: http.Request{
77+
Path: "/host-and-temporary",
78+
UnfollowRedirect: true,
79+
},
80+
Response: http.Response{
81+
StatusCode: 307,
82+
},
83+
RedirectRequest: &roundtripper.RedirectRequest{
84+
Host: "example.org",
85+
},
86+
Namespace: ns,
87+
}, {
88+
Request: http.Request{
89+
Path: "/host-and-permanent",
90+
UnfollowRedirect: true,
91+
},
92+
Response: http.Response{
93+
StatusCode: 308,
94+
},
95+
RedirectRequest: &roundtripper.RedirectRequest{
96+
Host: "example.org",
97+
},
98+
Namespace: ns,
7599
},
76100
}
77101
for i := range testCases {

conformance/tests/httproute-redirect-host-and-status.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,21 @@ spec:
2424
requestRedirect:
2525
statusCode: 301
2626
hostname: example.org
27-
27+
- matches:
28+
- path:
29+
type: PathPrefix
30+
value: /host-and-temporary
31+
filters:
32+
- type: RequestRedirect
33+
requestRedirect:
34+
statusCode: 307
35+
hostname: example.org
36+
- matches:
37+
- path:
38+
type: PathPrefix
39+
value: /host-and-permanent
40+
filters:
41+
- type: RequestRedirect
42+
requestRedirect:
43+
statusCode: 308
44+
hostname: example.org

conformance/tests/httproute-redirect-path.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,30 @@ var HTTPRouteRedirectPath = suite.ConformanceTest{
9898
Path: "/replacement-prefix",
9999
},
100100
Namespace: ns,
101+
}, {
102+
Request: http.Request{
103+
Path: "/path-and-temporary",
104+
UnfollowRedirect: true,
105+
},
106+
Response: http.Response{
107+
StatusCode: 307,
108+
},
109+
RedirectRequest: &roundtripper.RedirectRequest{
110+
Path: "/replacement-prefix",
111+
},
112+
Namespace: ns,
113+
}, {
114+
Request: http.Request{
115+
Path: "/path-and-permanent",
116+
UnfollowRedirect: true,
117+
},
118+
Response: http.Response{
119+
StatusCode: 308,
120+
},
121+
RedirectRequest: &roundtripper.RedirectRequest{
122+
Path: "/replacement-prefix",
123+
},
124+
Namespace: ns,
101125
}, {
102126
Request: http.Request{
103127
Path: "/full-path-and-host",
@@ -123,6 +147,30 @@ var HTTPRouteRedirectPath = suite.ConformanceTest{
123147
Path: "/replacement-full",
124148
},
125149
Namespace: ns,
150+
}, {
151+
Request: http.Request{
152+
Path: "/full-path-and-temporary",
153+
UnfollowRedirect: true,
154+
},
155+
Response: http.Response{
156+
StatusCode: 307,
157+
},
158+
RedirectRequest: &roundtripper.RedirectRequest{
159+
Path: "/replacement-full",
160+
},
161+
Namespace: ns,
162+
}, {
163+
Request: http.Request{
164+
Path: "/full-path-and-permanent",
165+
UnfollowRedirect: true,
166+
},
167+
Response: http.Response{
168+
StatusCode: 308,
169+
},
170+
RedirectRequest: &roundtripper.RedirectRequest{
171+
Path: "/replacement-full",
172+
},
173+
Namespace: ns,
126174
},
127175
}
128176
for i := range testCases {

conformance/tests/httproute-redirect-path.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ spec:
4949
type: ReplacePrefixMatch
5050
replacePrefixMatch: /replacement-prefix
5151
statusCode: 301
52+
- matches:
53+
- path:
54+
type: PathPrefix
55+
value: /path-and-temporary
56+
filters:
57+
- type: RequestRedirect
58+
requestRedirect:
59+
path:
60+
type: ReplacePrefixMatch
61+
replacePrefixMatch: /replacement-prefix
62+
statusCode: 307
63+
- matches:
64+
- path:
65+
type: PathPrefix
66+
value: /path-and-permanent
67+
filters:
68+
- type: RequestRedirect
69+
requestRedirect:
70+
path:
71+
type: ReplacePrefixMatch
72+
replacePrefixMatch: /replacement-prefix
73+
statusCode: 308
5274
- matches:
5375
- path:
5476
type: PathPrefix
@@ -71,3 +93,25 @@ spec:
7193
type: ReplaceFullPath
7294
replaceFullPath: /replacement-full
7395
statusCode: 301
96+
- matches:
97+
- path:
98+
type: PathPrefix
99+
value: /full-path-and-temporary
100+
filters:
101+
- type: RequestRedirect
102+
requestRedirect:
103+
path:
104+
type: ReplaceFullPath
105+
replaceFullPath: /replacement-full
106+
statusCode: 307
107+
- matches:
108+
- path:
109+
type: PathPrefix
110+
value: /full-path-and-permanent
111+
filters:
112+
- type: RequestRedirect
113+
requestRedirect:
114+
path:
115+
type: ReplaceFullPath
116+
replaceFullPath: /replacement-full
117+
statusCode: 308

conformance/tests/httproute-redirect-port.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,32 @@ var HTTPRouteRedirectPort = suite.ConformanceTest{
9999
Host: "example.org",
100100
},
101101
Namespace: ns,
102+
}, {
103+
Request: http.Request{
104+
Path: "/port-and-temporary",
105+
UnfollowRedirect: true,
106+
},
107+
Response: http.Response{
108+
StatusCode: 307,
109+
},
110+
RedirectRequest: &roundtripper.RedirectRequest{
111+
Port: "8083",
112+
Host: "example.org",
113+
},
114+
Namespace: ns,
115+
}, {
116+
Request: http.Request{
117+
Path: "/port-and-permanent",
118+
UnfollowRedirect: true,
119+
},
120+
Response: http.Response{
121+
StatusCode: 308,
122+
},
123+
RedirectRequest: &roundtripper.RedirectRequest{
124+
Port: "8083",
125+
Host: "example.org",
126+
},
127+
Namespace: ns,
102128
},
103129
}
104130
for i := range testCases {

conformance/tests/httproute-redirect-port.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,23 @@ spec:
4343
port: 8083
4444
hostname: example.org
4545
statusCode: 302
46+
- matches:
47+
- path:
48+
type: PathPrefix
49+
value: /port-and-temporary
50+
filters:
51+
- type: RequestRedirect
52+
requestRedirect:
53+
port: 8083
54+
hostname: example.org
55+
statusCode: 307
56+
- matches:
57+
- path:
58+
type: PathPrefix
59+
value: /port-and-permanent
60+
filters:
61+
- type: RequestRedirect
62+
requestRedirect:
63+
port: 8083
64+
hostname: example.org
65+
statusCode: 308

conformance/tests/httproute-redirect-scheme.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@ var HTTPRouteRedirectScheme = suite.ConformanceTest{
9999
Host: "example.org",
100100
},
101101
Namespace: ns,
102+
}, {
103+
Request: http.Request{
104+
Path: "/scheme-and-temporary",
105+
UnfollowRedirect: true,
106+
},
107+
Response: http.Response{
108+
StatusCode: 307,
109+
},
110+
RedirectRequest: &roundtripper.RedirectRequest{
111+
Scheme: "https",
112+
Host: "example.org",
113+
},
114+
Namespace: ns,
115+
}, {
116+
Request: http.Request{
117+
Path: "/scheme-and-permanent",
118+
UnfollowRedirect: true,
119+
},
120+
Response: http.Response{
121+
StatusCode: 308,
122+
},
102123
},
103124
}
104125
for i := range testCases {

conformance/tests/httproute-redirect-scheme.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ spec:
3333
requestRedirect:
3434
scheme: "https"
3535
statusCode: 301
36+
- matches:
37+
- path:
38+
type: PathPrefix
39+
value: /scheme-and-temporary
40+
filters:
41+
- type: RequestRedirect
42+
requestRedirect:
43+
scheme: "https"
44+
statusCode: 307
3645
- matches:
3746
- path:
3847
type: PathPrefix
@@ -43,4 +52,13 @@ spec:
4352
scheme: "https"
4453
statusCode: 302
4554
hostname: example.org
55+
- matches:
56+
- path:
57+
type: PathPrefix
58+
value: /scheme-and-permanent
59+
filters:
60+
- type: RequestRedirect
61+
requestRedirect:
62+
scheme: "https"
63+
statusCode: 308
4664

conformance/tests/mesh/httproute-redirect-host-and-status.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,34 @@ var MeshHTTPRouteRedirectHostAndStatus = suite.ConformanceTest{
7070
},
7171
Namespace: ns,
7272
},
73+
{
74+
Request: http.Request{
75+
Host: "echo",
76+
Path: "/host-and-temporary",
77+
UnfollowRedirect: true,
78+
},
79+
Response: http.Response{
80+
StatusCode: 307,
81+
},
82+
RedirectRequest: &roundtripper.RedirectRequest{
83+
Host: "example.org",
84+
},
85+
Namespace: ns,
86+
},
87+
{
88+
Request: http.Request{
89+
Host: "echo",
90+
Path: "/host-and-permanent",
91+
UnfollowRedirect: true,
92+
},
93+
Response: http.Response{
94+
StatusCode: 308,
95+
},
96+
RedirectRequest: &roundtripper.RedirectRequest{
97+
Host: "example.org",
98+
},
99+
Namespace: ns,
100+
},
73101
}
74102
for i := range testCases {
75103
// Declare tc here to avoid loop variable

conformance/tests/mesh/httproute-redirect-host-and-status.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,22 @@ spec:
2727
requestRedirect:
2828
statusCode: 301
2929
hostname: example.org
30+
- matches:
31+
- path:
32+
type: PathPrefix
33+
value: /host-and-temporary
34+
filters:
35+
- type: RequestRedirect
36+
requestRedirect:
37+
statusCode: 307
38+
hostname: example.org
39+
- matches:
40+
- path:
41+
type: PathPrefix
42+
value: /host-and-permanent
43+
filters:
44+
- type: RequestRedirect
45+
requestRedirect:
46+
statusCode: 308
47+
hostname: example.org
3048

0 commit comments

Comments
 (0)