@@ -490,34 +490,34 @@ func TestCreateServers(t *testing.T) {
490
490
}
491
491
492
492
slashMatches := []httpMatch {
493
- {Method : "POST" , RedirectPath : "/_prefix_route0 " },
494
- {Method : "PATCH" , RedirectPath : "/_prefix_route1 " },
495
- {Any : true , RedirectPath : "/_prefix_route2 " },
493
+ {Method : "POST" , RedirectPath : "@rule0-route0 " },
494
+ {Method : "PATCH" , RedirectPath : "@rule0-route1 " },
495
+ {Any : true , RedirectPath : "@rule0-route2 " },
496
496
}
497
497
testMatches := []httpMatch {
498
498
{
499
499
Method : "GET" ,
500
500
Headers : []string {"Version:V1" , "test:foo" , "my-header:my-value" },
501
501
QueryParams : []string {"GrEat=EXAMPLE" , "test=foo=bar" },
502
- RedirectPath : "/test_prefix_route0 " ,
502
+ RedirectPath : "@rule1-route0 " ,
503
503
},
504
504
}
505
505
exactMatches := []httpMatch {
506
506
{
507
507
Method : "GET" ,
508
- RedirectPath : "/test_exact_route0 " ,
508
+ RedirectPath : "@rule11-route0 " ,
509
509
},
510
510
}
511
511
redirectHeaderMatches := []httpMatch {
512
512
{
513
513
Headers : []string {"redirect:this" },
514
- RedirectPath : "/redirect-with-headers_prefix_route0 " ,
514
+ RedirectPath : "@rule5-route0 " ,
515
515
},
516
516
}
517
517
rewriteHeaderMatches := []httpMatch {
518
518
{
519
519
Headers : []string {"rewrite:this" },
520
- RedirectPath : "/rewrite-with-headers_prefix_route0 " ,
520
+ RedirectPath : "@rule7-route0 " ,
521
521
},
522
522
}
523
523
rewriteProxySetHeaders := []http.Header {
@@ -541,7 +541,7 @@ func TestCreateServers(t *testing.T) {
541
541
invalidFilterHeaderMatches := []httpMatch {
542
542
{
543
543
Headers : []string {"filter:this" },
544
- RedirectPath : "/invalid-filter-with-headers_prefix_route0 " ,
544
+ RedirectPath : "@rule9-route0 " ,
545
545
},
546
546
}
547
547
@@ -553,20 +553,17 @@ func TestCreateServers(t *testing.T) {
553
553
554
554
return []http.Location {
555
555
{
556
- Path : "/_prefix_route0" ,
557
- Internal : true ,
556
+ Path : "@rule0-route0" ,
558
557
ProxyPass : "http://test_foo_80$request_uri" ,
559
558
ProxySetHeaders : baseHeaders ,
560
559
},
561
560
{
562
- Path : "/_prefix_route1" ,
563
- Internal : true ,
561
+ Path : "@rule0-route1" ,
564
562
ProxyPass : "http://test_foo_80$request_uri" ,
565
563
ProxySetHeaders : baseHeaders ,
566
564
},
567
565
{
568
- Path : "/_prefix_route2" ,
569
- Internal : true ,
566
+ Path : "@rule0-route2" ,
570
567
ProxyPass : "http://test_foo_80$request_uri" ,
571
568
ProxySetHeaders : baseHeaders ,
572
569
},
@@ -575,8 +572,7 @@ func TestCreateServers(t *testing.T) {
575
572
HTTPMatchVar : expectedMatchString (slashMatches ),
576
573
},
577
574
{
578
- Path : "/test_prefix_route0" ,
579
- Internal : true ,
575
+ Path : "@rule1-route0" ,
580
576
ProxyPass : "http://$test__route1_rule1$request_uri" ,
581
577
ProxySetHeaders : baseHeaders ,
582
578
},
@@ -623,12 +619,11 @@ func TestCreateServers(t *testing.T) {
623
619
},
624
620
},
625
621
{
626
- Path : "/redirect-with-headers_prefix_route0 " ,
622
+ Path : "@rule5-route0 " ,
627
623
Return : & http.Return {
628
624
Body : "$scheme://foo.example.com:8080$request_uri" ,
629
625
Code : 302 ,
630
626
},
631
- Internal : true ,
632
627
},
633
628
{
634
629
Path : "/redirect-with-headers/" ,
@@ -651,9 +646,8 @@ func TestCreateServers(t *testing.T) {
651
646
ProxySetHeaders : rewriteProxySetHeaders ,
652
647
},
653
648
{
654
- Path : "/rewrite-with-headers_prefix_route0" ,
655
- Rewrites : []string {"^ $request_uri" , "^/rewrite-with-headers(.*)$ /prefix-replacement$1 break" },
656
- Internal : true ,
649
+ Path : "@rule7-route0" ,
650
+ Rewrites : []string {"^/rewrite-with-headers(.*)$ /prefix-replacement$1 break" },
657
651
ProxyPass : "http://test_foo_80" ,
658
652
ProxySetHeaders : rewriteProxySetHeaders ,
659
653
},
@@ -678,11 +672,10 @@ func TestCreateServers(t *testing.T) {
678
672
},
679
673
},
680
674
{
681
- Path : "/invalid-filter-with-headers_prefix_route0 " ,
675
+ Path : "@rule9-route0 " ,
682
676
Return : & http.Return {
683
677
Code : http .StatusInternalServerError ,
684
678
},
685
- Internal : true ,
686
679
},
687
680
{
688
681
Path : "/invalid-filter-with-headers/" ,
@@ -698,10 +691,9 @@ func TestCreateServers(t *testing.T) {
698
691
ProxySetHeaders : baseHeaders ,
699
692
},
700
693
{
701
- Path : "/test_exact_route0 " ,
694
+ Path : "@rule11-route0 " ,
702
695
ProxyPass : "http://test_foo_80$request_uri" ,
703
696
ProxySetHeaders : baseHeaders ,
704
- Internal : true ,
705
697
},
706
698
{
707
699
Path : "= /test" ,
@@ -1274,8 +1266,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
1274
1266
},
1275
1267
},
1276
1268
expected : & rewriteConfig {
1277
- InternalRewrite : "^ $request_uri" ,
1278
- MainRewrite : "^ /full-path break" ,
1269
+ Rewrite : "^ /full-path break" ,
1279
1270
},
1280
1271
msg : "full path" ,
1281
1272
},
@@ -1288,8 +1279,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
1288
1279
},
1289
1280
},
1290
1281
expected : & rewriteConfig {
1291
- InternalRewrite : "^ $request_uri" ,
1292
- MainRewrite : "^/original(.*)$ /prefix-path$1 break" ,
1282
+ Rewrite : "^/original(.*)$ /prefix-path$1 break" ,
1293
1283
},
1294
1284
msg : "prefix path no trailing slashes" ,
1295
1285
},
@@ -1302,8 +1292,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
1302
1292
},
1303
1293
},
1304
1294
expected : & rewriteConfig {
1305
- InternalRewrite : "^ $request_uri" ,
1306
- MainRewrite : "^/original(?:/(.*))?$ /$1 break" ,
1295
+ Rewrite : "^/original(?:/(.*))?$ /$1 break" ,
1307
1296
},
1308
1297
msg : "prefix path empty string" ,
1309
1298
},
@@ -1316,8 +1305,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
1316
1305
},
1317
1306
},
1318
1307
expected : & rewriteConfig {
1319
- InternalRewrite : "^ $request_uri" ,
1320
- MainRewrite : "^/original(?:/(.*))?$ /$1 break" ,
1308
+ Rewrite : "^/original(?:/(.*))?$ /$1 break" ,
1321
1309
},
1322
1310
msg : "prefix path /" ,
1323
1311
},
@@ -1330,8 +1318,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
1330
1318
},
1331
1319
},
1332
1320
expected : & rewriteConfig {
1333
- InternalRewrite : "^ $request_uri" ,
1334
- MainRewrite : "^/original(?:/(.*))?$ /trailing/$1 break" ,
1321
+ Rewrite : "^/original(?:/(.*))?$ /trailing/$1 break" ,
1335
1322
},
1336
1323
msg : "prefix path replacement with trailing /" ,
1337
1324
},
@@ -1344,8 +1331,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
1344
1331
},
1345
1332
},
1346
1333
expected : & rewriteConfig {
1347
- InternalRewrite : "^ $request_uri" ,
1348
- MainRewrite : "^/original/(.*)$ /prefix-path/$1 break" ,
1334
+ Rewrite : "^/original/(.*)$ /prefix-path/$1 break" ,
1349
1335
},
1350
1336
msg : "prefix path original with trailing /" ,
1351
1337
},
@@ -1358,8 +1344,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
1358
1344
},
1359
1345
},
1360
1346
expected : & rewriteConfig {
1361
- InternalRewrite : "^ $request_uri" ,
1362
- MainRewrite : "^/original/(.*)$ /trailing/$1 break" ,
1347
+ Rewrite : "^/original/(.*)$ /trailing/$1 break" ,
1363
1348
},
1364
1349
msg : "prefix path both with trailing slashes" ,
1365
1350
},
@@ -1694,38 +1679,13 @@ func TestCreateMatchLocation(t *testing.T) {
1694
1679
g := NewWithT (t )
1695
1680
1696
1681
expected := http.Location {
1697
- Path : "/path" ,
1698
- Internal : true ,
1682
+ Path : "/path" ,
1699
1683
}
1700
1684
1701
1685
result := createMatchLocation ("/path" )
1702
1686
g .Expect (result ).To (Equal (expected ))
1703
1687
}
1704
1688
1705
- func TestCreatePathForMatch (t * testing.T ) {
1706
- g := NewWithT (t )
1707
-
1708
- tests := []struct {
1709
- expected string
1710
- pathType dataplane.PathType
1711
- panic bool
1712
- }{
1713
- {
1714
- expected : "/path_prefix_route1" ,
1715
- pathType : dataplane .PathTypePrefix ,
1716
- },
1717
- {
1718
- expected : "/path_exact_route1" ,
1719
- pathType : dataplane .PathTypeExact ,
1720
- },
1721
- }
1722
-
1723
- for _ , tc := range tests {
1724
- result := createPathForMatch ("/path" , tc .pathType , 1 )
1725
- g .Expect (result ).To (Equal (tc .expected ))
1726
- }
1727
- }
1728
-
1729
1689
func TestGenerateProxySetHeaders (t * testing.T ) {
1730
1690
tests := []struct {
1731
1691
filters * dataplane.HTTPFilters
0 commit comments