@annotations @router.cookie @release-1.22

Feature: Redirect

An Ingress may define redirection rules in its annotations. If the a Request matches the rule defined in a Ingress which have redirection annotations, BFE should return a Response whose header has the corresponding Location and Status Code according to the annotations in the Ingress.

Scenarios
Status Progress

Passed

100.00%

Failed

0.00%
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.url-set` but

no annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-set: "https://www.baidu.com"
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 15s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 302
check_circle
And 0s the response location must be https://www.baidu.com
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.url-set` and

annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-set: "https://www.baidu.com"
bfe.ingress.kubernetes.io/redirect.response-status: 301
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 301
check_circle
And 0s the response location must be https://www.baidu.com
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.url-from-query` but

no annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-from-query
annotations:
bfe.ingress.kubernetes.io/redirect.url-from-query: "location"
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar?location=https://www.baidu.com
check_circle
Then 0s the response status-code must be 302
check_circle
And 0s the response location must be https://www.baidu.com
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.url-from-query` and

annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-from-query
annotations:
bfe.ingress.kubernetes.io/redirect.url-from-query: "location"
bfe.ingress.kubernetes.io/redirect.response-status: 301
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 3s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar?location=https://www.baidu.com
check_circle
Then 0s the response status-code must be 301
check_circle
And 0s the response location must be https://www.baidu.com
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.url-prefix-add` but

no annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-prefix-add: "https://new.org/api"
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 302
check_circle
And 0s the response location must be https://new.org/api/bar
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.url-prefix-add` and

annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-prefix-add: "https://new.org/api"
bfe.ingress.kubernetes.io/redirect.response-status: 301
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 301
check_circle
And 0s the response location must be https://new.org/api/bar
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.scheme-set` but

no annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.scheme-set: https
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 302
check_circle
And 0s the response location must be https://foo.com/bar
Scenario: An Ingress with annotation `bfe.ingress.kubernetes.io/redirect.scheme-set` and

annotation `bfe.ingress.kubernetes.io/redirect.response-status`.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.scheme-set: https
bfe.ingress.kubernetes.io/redirect.response-status: 301
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 301
check_circle
And 0s the response location must be https://foo.com/bar
Scenario: An Ingress with redirect annotations is applied and

then the ingress is updated by removing the redirect annotations.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-set: "https://www.baidu.com"
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 302
check_circle
And 0s the response location must be https://www.baidu.com
check_circle
Then 0s update the ingress +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 3s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 200
Scenario: An Ingress with redirect annotations is applied and

then the ingress is updated by removing the rules.

check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-set: "https://www.baidu.com"
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 302
check_circle
And 0s the response location must be https://www.baidu.com
check_circle
Then 0s update the ingress +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
spec:
defaultBackend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 6s The Ingress status shows the IP address or FQDN where it is exposed
check_circle
When 0s I send a GET request to http://foo.com/bar
check_circle
Then 0s the response status-code must be 200
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-set: aaa-bbb
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 3s The Ingress status should not be success
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-prefix-add: invalid-url
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 0s The Ingress status should not be success
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.url-prefix-add: https://example.org/path#fragment
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 3s The Ingress status should not be success
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.scheme-set: ftp
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 0s The Ingress status should not be success
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.scheme-set: https
bfe.ingress.kubernetes.io/redirect.url-prefix-add: "https://new.org/api"
bfe.ingress.kubernetes.io/redirect.response-status: 301
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 3s The Ingress status should not be success
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.response-status: 301
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 0s The Ingress status should not be success
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.scheme-set: https
bfe.ingress.kubernetes.io/redirect.response-status: 404
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 3s The Ingress status should not be success
check_circle
Given 5s an Ingress resource with redirection annotations +Show Parameter
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: redirect-url-set
annotations:
bfe.ingress.kubernetes.io/redirect.scheme-set: https
bfe.ingress.kubernetes.io/redirect.response-status: some-code
spec:
rules:
- host: "foo.com"
http:
paths:
- path: /bar
pathType: Prefix
backend:
service:
name: foo-exact
port:
number: 3000
check_circle
And 3s The Ingress status should not be success