Add header Host into mirror annotations (#8178)
This commit is contained in:
parent
ec1b01092e
commit
730b7408ca
4 changed files with 62 additions and 2 deletions
|
|
@ -30,6 +30,7 @@ import (
|
|||
func TestParse(t *testing.T) {
|
||||
requestBody := parser.GetAnnotationWithPrefix("mirror-request-body")
|
||||
backendURL := parser.GetAnnotationWithPrefix("mirror-target")
|
||||
host := parser.GetAnnotationWithPrefix("mirror-host")
|
||||
|
||||
ap := NewParser(&resolver.Mock{})
|
||||
if ap == nil {
|
||||
|
|
@ -45,11 +46,43 @@ func TestParse(t *testing.T) {
|
|||
Source: ngxURI,
|
||||
RequestBody: "on",
|
||||
Target: "https://test.env.com/$request_uri",
|
||||
Host: "test.env.com",
|
||||
}},
|
||||
{map[string]string{requestBody: "off"}, &Config{
|
||||
Source: "",
|
||||
RequestBody: "off",
|
||||
Target: "",
|
||||
Host: "",
|
||||
}},
|
||||
{map[string]string{host: "test.env.com", backendURL: "http://some.test.env.com/$someparam"}, &Config{
|
||||
Source: ngxURI,
|
||||
RequestBody: "on",
|
||||
Target: "http://some.test.env.com/$someparam",
|
||||
Host: "test.env.com",
|
||||
}},
|
||||
{map[string]string{backendURL: "IamNotAURL"}, &Config{
|
||||
Source: ngxURI,
|
||||
RequestBody: "on",
|
||||
Target: "IamNotAURL",
|
||||
Host: "",
|
||||
}},
|
||||
{map[string]string{backendURL: "http://some.test.env.com:2121/$someparam=1&$someotherparam=2"}, &Config{
|
||||
Source: ngxURI,
|
||||
RequestBody: "on",
|
||||
Target: "http://some.test.env.com:2121/$someparam=1&$someotherparam=2",
|
||||
Host: "some.test.env.com",
|
||||
}},
|
||||
{map[string]string{backendURL: "http://some.test.env.com", host: "someInvalidParm.%^&*()_=!@#'\""}, &Config{
|
||||
Source: ngxURI,
|
||||
RequestBody: "on",
|
||||
Target: "http://some.test.env.com",
|
||||
Host: "someInvalidParm.%^&*()_=!@#'\"",
|
||||
}},
|
||||
{map[string]string{backendURL: "http://some.test.env.com", host: "_sbrubles-i\"@xpto:12345"}, &Config{
|
||||
Source: ngxURI,
|
||||
RequestBody: "on",
|
||||
Target: "http://some.test.env.com",
|
||||
Host: "_sbrubles-i\"@xpto:12345",
|
||||
}},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue