-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathpath_rules.feature
199 lines (158 loc) · 7.49 KB
/
path_rules.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@sig-network @conformance @release-1.19
Feature: Path rules
An Ingress may define routing rules based on the request path.
If the HTTP request path matches one of the paths in the
Ingress objects, the traffic is routed to its backend service.
Background:
Given an Ingress resource in a new random namespace
"""
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: path-rules
spec:
rules:
- host: "exact-path-rules"
http:
paths:
- path: /foo
pathType: Exact
backend:
service:
name: foo-exact
port:
number: 8080
- host: "prefix-path-rules"
http:
paths:
- path: /foo
pathType: Prefix
backend:
service:
name: foo-prefix
port:
number: 8080
- path: /aaa/bbb
pathType: Prefix
backend:
service:
name: aaa-slash-bbb-prefix
port:
number: 8080
- path: /aaa
pathType: Prefix
backend:
service:
name: aaa-prefix
port:
number: 8080
- host: "mixed-path-rules"
http:
paths:
- path: /foo
pathType: Prefix
backend:
service:
name: foo-prefix
port:
number: 8080
- path: /foo
pathType: Exact
backend:
service:
name: foo-exact
port:
number: 8080
- host: "trailing-slash-path-rules"
http:
paths:
- path: /aaa/bbb/
pathType: Prefix
backend:
service:
name: aaa-slash-bbb-slash-prefix
port:
number: 8080
- path: /foo/
pathType: Exact
backend:
service:
name: foo-slash-exact
port:
number: 8080
"""
Then The Ingress status shows the IP address or FQDN where it is exposed
Scenario: An Ingress with exact path rules should send traffic to the matching backend service
(exact /foo matches request /foo)
When I send a "GET" request to "http://exact-path-rules/foo"
Then the response status-code must be 200
And the response must be served by the "foo-exact" service
Scenario: An Ingress with exact path rules should not match requests with trailing slash
(exact /foo does not match request /foo/)
When I send a "GET" request to "http://exact-path-rules/foo/"
Then the response status-code must be 404
Scenario: An Ingress with exact path rules should be case sensitive
(exact /foo does not match request /FOO)
When I send a "GET" request to "http://exact-path-rules/FOO"
Then the response status-code must be 404
Scenario: An Ingress with exact path rules should not match any other label
(exact /foo does not match request /bar)
When I send a "GET" request to "http://exact-path-rules/bar"
Then the response status-code must be 404
Scenario: An Ingress with prefix path rules should send traffic to the matching backend service
(prefix /foo matches request /foo)
When I send a "GET" request to "http://prefix-path-rules/foo"
Then the response status-code must be 200
And the response must be served by the "foo-prefix" service
Scenario: An Ingress with prefix path rules should ignore the request trailing slash and send traffic to the matching backend service
(prefix /foo matches request /foo/)
When I send a "GET" request to "http://prefix-path-rules/foo/"
Then the response status-code must be 200
And the response must be served by the "foo-prefix" service
Scenario: An Ingress with prefix path rules should be case sensitive
(prefix /foo does not match request /FOO)
When I send a "GET" request to "http://prefix-path-rules/FOO"
Then the response status-code must be 404
Scenario: An Ingress with prefix path rules should match multiple labels, match the longest path, and send traffic to the matching backend service
(prefix /aaa/bbb matches request /aaa/bbb)
When I send a "GET" request to "http://prefix-path-rules/aaa/bbb"
Then the response status-code must be 200
And the response must be served by the "aaa-slash-bbb-prefix" service
Scenario: An Ingress with prefix path rules should match multiple labels, match the longest path, and subpaths and send traffic to the matching backend service
(prefix /aaa/bbb matches request /aaa/bbb/ccc)
When I send a "GET" request to "http://prefix-path-rules/aaa/bbb/ccc"
Then the response status-code must be 200
And the response must be served by the "aaa-slash-bbb-prefix" service
Scenario: An Ingress with prefix path rules should and send traffic to the matching backend service
(prefix /aaa matches request /aaa/ccc)
When I send a "GET" request to "http://prefix-path-rules/aaa/ccc"
Then the response status-code must be 200
And the response must be served by the "aaa-prefix" service
Scenario: An Ingress with prefix path rules should match each labels string prefix
(prefix /aaa does not match request /aaaccc)
When I send a "GET" request to "http://prefix-path-rules/aaaccc"
Then the response status-code must be 404
Scenario: An Ingress with prefix path rules should ignore the request trailing slash and send traffic to the matching backend service
(prefix /foo matches request /foo/)
When I send a "GET" request to "http://prefix-path-rules/foo/"
Then the response status-code must be 200
And the response must be served by the "foo-prefix" service
Scenario: An Ingress with mixed path rules should send traffic to the matching backend service where Exact is preferred
(exact /foo matches request /foo)
When I send a "GET" request to "http://mixed-path-rules/foo"
Then the response status-code must be 200
And the response must be served by the "foo-exact" service
Scenario: An Ingress with a trailing slashes in a prefix path rule should ignore the trailing slash and send traffic to the matching backend service
(prefix /aaa/bbb/ matches request /aaa/bbb)
When I send a "GET" request to "http://trailing-slash-path-rules/aaa/bbb"
Then the response status-code must be 200
And the response must be served by the "aaa-slash-bbb-slash-prefix" service
Scenario: An Ingress with a trailing slashes in a prefix path rule should ignore the trailing slash and send traffic to the matching backend service
(prefix /aaa/bbb/ matches request /aaa/bbb/)
When I send a "GET" request to "http://trailing-slash-path-rules/aaa/bbb/"
Then the response status-code must be 200
And the response must be served by the "aaa-slash-bbb-slash-prefix" service
Scenario: An Ingress with a trailing slashes in an exact path rule should not match requests without a trailing slash
(exact /foo/ does not match request /foo)
When I send a "GET" request to "http://trailing-slash-path-rules/foo"
Then the response status-code must be 404