-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
- Loading branch information
1 parent
0e34794
commit 5fb579d
Showing
6 changed files
with
209 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
test/e2e_env/kubernetes/gateway/delegated_meshproxypatch.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package gateway | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
. "github.com/kumahq/kuma/test/framework" | ||
"github.com/kumahq/kuma/test/framework/client" | ||
"github.com/kumahq/kuma/test/framework/envs/kubernetes" | ||
"github.com/kumahq/kuma/test/server/types" | ||
) | ||
|
||
func MeshProxyPatch(config *delegatedE2EConfig) func() { | ||
GinkgoHelper() | ||
|
||
return func() { | ||
It("should add a header using Lua filter", func() { | ||
// given | ||
meshProxyPatch := fmt.Sprintf(` | ||
apiVersion: kuma.io/v1alpha1 | ||
kind: MeshProxyPatch | ||
metadata: | ||
name: backend-lua-filter | ||
namespace: %s | ||
labels: | ||
kuma.io/mesh: %s | ||
spec: | ||
targetRef: | ||
kind: Mesh | ||
default: | ||
appendModifications: | ||
- httpFilter: | ||
operation: AddBefore | ||
match: | ||
name: envoy.filters.http.router | ||
origin: outbound | ||
value: | | ||
name: envoy.filters.http.lua | ||
typedConfig: | ||
'@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua | ||
inline_code: | | ||
function envoy_on_request(request_handle) | ||
request_handle:headers():add("X-Header", "test") | ||
end | ||
`, Config.KumaNamespace, config.mesh) | ||
|
||
// when | ||
err := kubernetes.Cluster.Install(YamlK8s(meshProxyPatch)) | ||
|
||
// then | ||
Expect(err).ToNot(HaveOccurred()) | ||
Eventually(func() ([]types.EchoResponse, error) { | ||
return client.CollectResponses( | ||
kubernetes.Cluster, | ||
"demo-client", | ||
fmt.Sprintf("http://%s/test-server", config.kicIP), | ||
client.FromKubernetesPod(config.namespaceOutsideMesh, "demo-client"), | ||
) | ||
}, "30s", "1s").Should(ContainElement(HaveField( | ||
`Received.Headers`, | ||
HaveKeyWithValue("X-Header", ContainElement("test")), | ||
))) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters