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