Refactor mirror feature
This commit is contained in:
parent
b9e944a8a6
commit
b3146354d4
14 changed files with 178 additions and 128 deletions
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package annotations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
|
@ -35,32 +36,50 @@ var _ = framework.IngressNginxDescribe("Annotations - Mirror", func() {
|
|||
AfterEach(func() {
|
||||
})
|
||||
|
||||
It("should set mirror-uri to /mirror", func() {
|
||||
It("should set mirror-target to http://localhost/mirror", func() {
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/mirror-uri": "/mirror",
|
||||
"nginx.ingress.kubernetes.io/mirror-target": "http://localhost/mirror",
|
||||
}
|
||||
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||
f.EnsureIngress(ing)
|
||||
ing = f.EnsureIngress(ing)
|
||||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, "mirror /mirror;") && strings.Contains(server, "mirror_request_body on;")
|
||||
return strings.Contains(server, fmt.Sprintf("mirror /_mirror-%v;", ing.UID)) &&
|
||||
strings.Contains(server, "mirror_request_body on;")
|
||||
})
|
||||
})
|
||||
|
||||
It("should set mirror-target to https://test.env.com/$request_uri", func() {
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/mirror-target": "https://test.env.com/$request_uri",
|
||||
}
|
||||
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||
ing = f.EnsureIngress(ing)
|
||||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, fmt.Sprintf("mirror /_mirror-%v;", ing.UID)) &&
|
||||
strings.Contains(server, "mirror_request_body on;") &&
|
||||
strings.Contains(server, "proxy_pass https://test.env.com/$request_uri;")
|
||||
})
|
||||
})
|
||||
|
||||
It("should disable mirror-request-body", func() {
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/mirror-uri": "/mirror",
|
||||
"nginx.ingress.kubernetes.io/mirror-uri": "http://localhost/mirror",
|
||||
"nginx.ingress.kubernetes.io/mirror-request-body": "off",
|
||||
}
|
||||
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||
f.EnsureIngress(ing)
|
||||
ing = f.EnsureIngress(ing)
|
||||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, "mirror /mirror;") && strings.Contains(server, "mirror_request_body off;")
|
||||
return strings.Contains(server, fmt.Sprintf("mirror /_mirror-%v;", ing.UID)) &&
|
||||
strings.Contains(server, "mirror_request_body off;")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue