@@ -4,9 +4,12 @@ import (
44 "fmt"
55 "net"
66
7+ core_mesh "github.com/kumahq/kuma/v2/pkg/core/resources/apis/mesh"
8+ "github.com/kumahq/kuma/v2/pkg/test/resources/builders"
79 . "github.com/onsi/ginkgo/v2"
810 . "github.com/onsi/gomega"
911 "golang.org/x/sync/errgroup"
12+ "google.golang.org/protobuf/types/known/wrapperspb"
1013
1114 config_core "github.com/kumahq/kuma/v2/pkg/config/core"
1215 . "github.com/kumahq/kuma/v2/test/framework"
@@ -18,21 +21,17 @@ import (
1821const nonDefaultMesh = "non-default"
1922
2023func HybridUniversalGlobal () {
21- meshMTLSOn := `
22- type: Mesh
23- name: %s
24- mtls:
25- enabledBackend: ca-1
26- backends:
27- - name: ca-1
28- type: builtin
29- networking:
30- outbound:
31- passthrough: %s
32- routing:
33- zoneEgress: %s
34- `
35-
24+ meshMTLOnFn := func (name string , enableNetworkOutBound , enableZoneIngress bool ) * core_mesh.MeshResource {
25+ m := builders .Mesh ().WithName (nonDefaultMesh ).WithBuiltinMTLSBackend ("ca-1" ).
26+ WithEgressRoutingEnabled ().With (func (resource * core_mesh.MeshResource ) {
27+ resource .Spec .Networking .Outbound .Passthrough = & wrapperspb.BoolValue {
28+ Value : enableNetworkOutBound ,
29+ }
30+ resource .Spec .Routing .ZoneEgress = enableZoneIngress
31+ })
32+
33+ return m .Build ()
34+ }
3635 externalService1 := `
3736type: ExternalService
3837mesh: %s
8685
8786 Expect (NewClusterSetup ().
8887 Install (Kuma (config_core .Global )).
89- Install (YamlUniversal ( fmt . Sprintf ( meshMTLSOn , nonDefaultMesh , " true" , " true" ))).
88+ Install (ResourceUniversal ( meshMTLOnFn ( nonDefaultMesh , true , true ))).
9089 Install (MeshTrafficPermissionAllowAllUniversal (nonDefaultMesh )).
9190 Install (YamlUniversal (ptWaitForWarmOnInit )).
9291 Install (YamlUniversal (fmt .Sprintf (externalService1 , nonDefaultMesh ))).
@@ -159,7 +158,7 @@ conf:
159158 })
160159
161160 It ("passthrough false with zoneegress false" , func () {
162- Expect (YamlUniversal ( fmt . Sprintf ( meshMTLSOn , nonDefaultMesh , " false" , " false" ))(global )).To (Succeed ())
161+ Expect (ResourceUniversal ( meshMTLOnFn ( nonDefaultMesh , false , false ))(global )).To (Succeed ())
163162
164163 By ("reaching external service from k8s" )
165164 Eventually (func (g Gomega ) {
@@ -192,7 +191,7 @@ conf:
192191 })
193192
194193 It ("passthrough false with zoneegress true" , func () {
195- Expect (YamlUniversal ( fmt . Sprintf ( meshMTLSOn , nonDefaultMesh , " false" , " true" ))(global )).To (Succeed ())
194+ Expect (ResourceUniversal ( meshMTLOnFn ( nonDefaultMesh , false , true ))(global )).To (Succeed ())
196195
197196 By ("not reaching external service from k8s when zone egress is down" )
198197 Eventually (func (g Gomega ) {
0 commit comments