@@ -680,6 +680,37 @@ func TestBuildConfiguration(t *testing.T) {
680
680
},
681
681
)
682
682
683
+ hrAdvancedRouteWithPolicyAndHeaderMatch ,
684
+ groupsHRAdvancedWithHeaderMatch ,
685
+ routeHRAdvancedWithHeaderMatch := createTestResources (
686
+ "hr-advanced-route-with-policy-header-match" ,
687
+ "policy.com" ,
688
+ "listener-80-1" ,
689
+ pathAndType {path : "/rest" , pathType : prefix },
690
+ )
691
+
692
+ pathMatch := helpers .GetPointer (v1.HTTPPathMatch {
693
+ Value : helpers .GetPointer ("/rest" ),
694
+ Type : helpers .GetPointer (v1 .PathMatchPathPrefix ),
695
+ })
696
+
697
+ routeHRAdvancedWithHeaderMatch .Spec .Rules [0 ].Matches = []v1.HTTPRouteMatch {
698
+ {
699
+ Path : pathMatch ,
700
+ Headers : []v1.HTTPHeaderMatch {
701
+ {
702
+ Name : "Referrer" ,
703
+ Type : helpers .GetPointer (v1 .HeaderMatchRegularExpression ),
704
+ Value : "(?i)(mydomain|myotherdomain).+\\ .example\\ .(cloud|com)" ,
705
+ },
706
+ },
707
+ },
708
+ {
709
+ Path : pathMatch ,
710
+ },
711
+ }
712
+ routeHRAdvancedWithHeaderMatch .Spec .Hostnames = []v1.Hostname {"policy.com" }
713
+
683
714
l7RouteWithPolicy .Policies = []* graph.Policy {hrPolicy1 , invalidPolicy }
684
715
685
716
httpsHRWithPolicy , expHTTPSHRWithPolicyGroups , l7HTTPSRouteWithPolicy := createTestResources (
@@ -2346,6 +2377,74 @@ func TestBuildConfiguration(t *testing.T) {
2346
2377
}),
2347
2378
msg : "Simple Gateway and HTTPRoute with policies attached" ,
2348
2379
},
2380
+ {
2381
+ graph : getModifiedGraph (func (g * graph.Graph ) * graph.Graph {
2382
+ gw := g .Gateways [gatewayNsName ]
2383
+ gw .Listeners = append (gw .Listeners , []* graph.Listener {
2384
+ {
2385
+ Name : "listener-80-1" ,
2386
+ GatewayName : gatewayNsName ,
2387
+ Source : listener80 ,
2388
+ Valid : true ,
2389
+ Routes : map [graph.RouteKey ]* graph.L7Route {
2390
+ graph .CreateRouteKey (hrAdvancedRouteWithPolicyAndHeaderMatch ): routeHRAdvancedWithHeaderMatch ,
2391
+ },
2392
+ },
2393
+ }... )
2394
+ gw .Policies = []* graph.Policy {gwPolicy1 , gwPolicy2 }
2395
+ routeHRAdvancedWithHeaderMatch .Policies = []* graph.Policy {hrPolicy1 }
2396
+ g .Routes = map [graph.RouteKey ]* graph.L7Route {
2397
+ graph .CreateRouteKey (hrAdvancedRouteWithPolicyAndHeaderMatch ): routeHRAdvancedWithHeaderMatch ,
2398
+ }
2399
+ return g
2400
+ }),
2401
+ expConf : getModifiedExpectedConfiguration (func (conf Configuration ) Configuration {
2402
+ conf .SSLServers = []VirtualServer {}
2403
+ conf .SSLKeyPairs = map [SSLKeyPairID ]SSLKeyPair {}
2404
+ conf .HTTPServers = []VirtualServer {
2405
+ {
2406
+ IsDefault : true ,
2407
+ Port : 80 ,
2408
+ Policies : []policies.Policy {gwPolicy1 .Source , gwPolicy2 .Source },
2409
+ },
2410
+ {
2411
+ Hostname : "policy.com" ,
2412
+ PathRules : []PathRule {
2413
+ {
2414
+ Path : "/rest" ,
2415
+ PathType : PathTypePrefix ,
2416
+ MatchRules : []MatchRule {
2417
+ {
2418
+ BackendGroup : groupsHRAdvancedWithHeaderMatch [0 ],
2419
+ Source : & hrAdvancedRouteWithPolicyAndHeaderMatch .ObjectMeta ,
2420
+ Match : Match {
2421
+ Headers : []HTTPHeaderMatch {
2422
+ {
2423
+ Name : "Referrer" ,
2424
+ Value : "(?i)(mydomain|myotherdomain).+\\ .example\\ .(cloud|com)" ,
2425
+ Type : "RegularExpression" ,
2426
+ },
2427
+ },
2428
+ },
2429
+ },
2430
+ {
2431
+ BackendGroup : groupsHRAdvancedWithHeaderMatch [0 ],
2432
+ Source : & hrAdvancedRouteWithPolicyAndHeaderMatch .ObjectMeta ,
2433
+ },
2434
+ },
2435
+ Policies : []policies.Policy {hrPolicy1 .Source },
2436
+ },
2437
+ },
2438
+ Port : 80 ,
2439
+ Policies : []policies.Policy {gwPolicy1 .Source , gwPolicy2 .Source },
2440
+ },
2441
+ }
2442
+ conf .Upstreams = []Upstream {fooUpstream }
2443
+ conf .BackendGroups = []BackendGroup {groupsHRAdvancedWithHeaderMatch [0 ]}
2444
+ return conf
2445
+ }),
2446
+ msg : "Gateway and HTTPRoute with policies attached with advanced routing" ,
2447
+ },
2349
2448
{
2350
2449
graph : getModifiedGraph (func (g * graph.Graph ) * graph.Graph {
2351
2450
gw := g .Gateways [gatewayNsName ]
0 commit comments