@@ -649,19 +649,19 @@ func TestCreateServers(t *testing.T) {
649
649
{
650
650
Path : "@rule0-route0" ,
651
651
ProxyPass : "http://test_foo_80$request_uri" ,
652
- ProxySetHeaders : baseHeaders ,
652
+ ProxySetHeaders : httpBaseHeaders ,
653
653
ResponseHeaders : http.ResponseHeaders {},
654
654
},
655
655
{
656
656
Path : "@rule0-route1" ,
657
657
ProxyPass : "http://test_foo_80$request_uri" ,
658
- ProxySetHeaders : baseHeaders ,
658
+ ProxySetHeaders : httpBaseHeaders ,
659
659
ResponseHeaders : http.ResponseHeaders {},
660
660
},
661
661
{
662
662
Path : "@rule0-route2" ,
663
663
ProxyPass : "http://test_foo_80$request_uri" ,
664
- ProxySetHeaders : baseHeaders ,
664
+ ProxySetHeaders : httpBaseHeaders ,
665
665
ResponseHeaders : http.ResponseHeaders {},
666
666
},
667
667
{
@@ -671,7 +671,7 @@ func TestCreateServers(t *testing.T) {
671
671
{
672
672
Path : "@rule1-route0" ,
673
673
ProxyPass : "http://$test__route1_rule1$request_uri" ,
674
- ProxySetHeaders : baseHeaders ,
674
+ ProxySetHeaders : httpBaseHeaders ,
675
675
ResponseHeaders : http.ResponseHeaders {},
676
676
},
677
677
{
@@ -681,19 +681,19 @@ func TestCreateServers(t *testing.T) {
681
681
{
682
682
Path : "/path-only/" ,
683
683
ProxyPass : "http://invalid-backend-ref$request_uri" ,
684
- ProxySetHeaders : baseHeaders ,
684
+ ProxySetHeaders : httpBaseHeaders ,
685
685
ResponseHeaders : http.ResponseHeaders {},
686
686
},
687
687
{
688
688
Path : "= /path-only" ,
689
689
ProxyPass : "http://invalid-backend-ref$request_uri" ,
690
- ProxySetHeaders : baseHeaders ,
690
+ ProxySetHeaders : httpBaseHeaders ,
691
691
ResponseHeaders : http.ResponseHeaders {},
692
692
},
693
693
{
694
694
Path : "/backend-tls-policy/" ,
695
695
ProxyPass : "https://test_btp_80$request_uri" ,
696
- ProxySetHeaders : baseHeaders ,
696
+ ProxySetHeaders : httpBaseHeaders ,
697
697
ProxySSLVerify : & http.ProxySSLVerify {
698
698
Name : "test-btp.example.com" ,
699
699
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
@@ -702,7 +702,7 @@ func TestCreateServers(t *testing.T) {
702
702
{
703
703
Path : "= /backend-tls-policy" ,
704
704
ProxyPass : "https://test_btp_80$request_uri" ,
705
- ProxySetHeaders : baseHeaders ,
705
+ ProxySetHeaders : httpBaseHeaders ,
706
706
ProxySSLVerify : & http.ProxySSLVerify {
707
707
Name : "test-btp.example.com" ,
708
708
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
@@ -809,13 +809,13 @@ func TestCreateServers(t *testing.T) {
809
809
{
810
810
Path : "= /exact" ,
811
811
ProxyPass : "http://test_foo_80$request_uri" ,
812
- ProxySetHeaders : baseHeaders ,
812
+ ProxySetHeaders : httpBaseHeaders ,
813
813
ResponseHeaders : http.ResponseHeaders {},
814
814
},
815
815
{
816
816
Path : "@rule12-route0" ,
817
817
ProxyPass : "http://test_foo_80$request_uri" ,
818
- ProxySetHeaders : baseHeaders ,
818
+ ProxySetHeaders : httpBaseHeaders ,
819
819
ResponseHeaders : http.ResponseHeaders {},
820
820
},
821
821
{
@@ -898,7 +898,7 @@ func TestCreateServers(t *testing.T) {
898
898
Path : "= /grpc/method" ,
899
899
ProxyPass : "grpc://test_foo_80" ,
900
900
GRPC : true ,
901
- ProxySetHeaders : nil ,
901
+ ProxySetHeaders : grpcBaseHeaders ,
902
902
},
903
903
{
904
904
Path : "= /grpc-with-backend-tls-policy/method" ,
@@ -908,7 +908,7 @@ func TestCreateServers(t *testing.T) {
908
908
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
909
909
},
910
910
GRPC : true ,
911
- ProxySetHeaders : nil ,
911
+ ProxySetHeaders : grpcBaseHeaders ,
912
912
},
913
913
}
914
914
}
@@ -1028,13 +1028,13 @@ func TestCreateServersConflicts(t *testing.T) {
1028
1028
{
1029
1029
Path : "/coffee/" ,
1030
1030
ProxyPass : "http://test_foo_80$request_uri" ,
1031
- ProxySetHeaders : baseHeaders ,
1031
+ ProxySetHeaders : httpBaseHeaders ,
1032
1032
ResponseHeaders : http.ResponseHeaders {},
1033
1033
},
1034
1034
{
1035
1035
Path : "= /coffee" ,
1036
1036
ProxyPass : "http://test_bar_80$request_uri" ,
1037
- ProxySetHeaders : baseHeaders ,
1037
+ ProxySetHeaders : httpBaseHeaders ,
1038
1038
ResponseHeaders : http.ResponseHeaders {},
1039
1039
},
1040
1040
createDefaultRootLocation (),
@@ -1068,13 +1068,13 @@ func TestCreateServersConflicts(t *testing.T) {
1068
1068
{
1069
1069
Path : "= /coffee" ,
1070
1070
ProxyPass : "http://test_foo_80$request_uri" ,
1071
- ProxySetHeaders : baseHeaders ,
1071
+ ProxySetHeaders : httpBaseHeaders ,
1072
1072
ResponseHeaders : http.ResponseHeaders {},
1073
1073
},
1074
1074
{
1075
1075
Path : "/coffee/" ,
1076
1076
ProxyPass : "http://test_bar_80$request_uri" ,
1077
- ProxySetHeaders : baseHeaders ,
1077
+ ProxySetHeaders : httpBaseHeaders ,
1078
1078
ResponseHeaders : http.ResponseHeaders {},
1079
1079
},
1080
1080
createDefaultRootLocation (),
@@ -1118,13 +1118,13 @@ func TestCreateServersConflicts(t *testing.T) {
1118
1118
{
1119
1119
Path : "/coffee/" ,
1120
1120
ProxyPass : "http://test_bar_80$request_uri" ,
1121
- ProxySetHeaders : baseHeaders ,
1121
+ ProxySetHeaders : httpBaseHeaders ,
1122
1122
ResponseHeaders : http.ResponseHeaders {},
1123
1123
},
1124
1124
{
1125
1125
Path : "= /coffee" ,
1126
1126
ProxyPass : "http://test_baz_80$request_uri" ,
1127
- ProxySetHeaders : baseHeaders ,
1127
+ ProxySetHeaders : httpBaseHeaders ,
1128
1128
ResponseHeaders : http.ResponseHeaders {},
1129
1129
},
1130
1130
createDefaultRootLocation (),
@@ -1243,13 +1243,13 @@ func TestCreateLocationsRootPath(t *testing.T) {
1243
1243
{
1244
1244
Path : "/path-1" ,
1245
1245
ProxyPass : "http://test_foo_80$request_uri" ,
1246
- ProxySetHeaders : baseHeaders ,
1246
+ ProxySetHeaders : httpBaseHeaders ,
1247
1247
ResponseHeaders : http.ResponseHeaders {},
1248
1248
},
1249
1249
{
1250
1250
Path : "/path-2" ,
1251
1251
ProxyPass : "http://test_foo_80$request_uri" ,
1252
- ProxySetHeaders : baseHeaders ,
1252
+ ProxySetHeaders : httpBaseHeaders ,
1253
1253
ResponseHeaders : http.ResponseHeaders {},
1254
1254
},
1255
1255
{
@@ -1268,17 +1268,18 @@ func TestCreateLocationsRootPath(t *testing.T) {
1268
1268
{
1269
1269
Path : "/path-1" ,
1270
1270
ProxyPass : "http://test_foo_80$request_uri" ,
1271
- ProxySetHeaders : baseHeaders ,
1271
+ ProxySetHeaders : httpBaseHeaders ,
1272
1272
},
1273
1273
{
1274
1274
Path : "/path-2" ,
1275
1275
ProxyPass : "http://test_foo_80$request_uri" ,
1276
- ProxySetHeaders : baseHeaders ,
1276
+ ProxySetHeaders : httpBaseHeaders ,
1277
1277
},
1278
1278
{
1279
- Path : "/grpc" ,
1280
- ProxyPass : "grpc://test_foo_80" ,
1281
- GRPC : true ,
1279
+ Path : "/grpc" ,
1280
+ ProxyPass : "grpc://test_foo_80" ,
1281
+ GRPC : true ,
1282
+ ProxySetHeaders : grpcBaseHeaders ,
1282
1283
},
1283
1284
{
1284
1285
Path : "/" ,
@@ -1295,19 +1296,19 @@ func TestCreateLocationsRootPath(t *testing.T) {
1295
1296
{
1296
1297
Path : "/path-1" ,
1297
1298
ProxyPass : "http://test_foo_80$request_uri" ,
1298
- ProxySetHeaders : baseHeaders ,
1299
+ ProxySetHeaders : httpBaseHeaders ,
1299
1300
ResponseHeaders : http.ResponseHeaders {},
1300
1301
},
1301
1302
{
1302
1303
Path : "/path-2" ,
1303
1304
ProxyPass : "http://test_foo_80$request_uri" ,
1304
- ProxySetHeaders : baseHeaders ,
1305
+ ProxySetHeaders : httpBaseHeaders ,
1305
1306
ResponseHeaders : http.ResponseHeaders {},
1306
1307
},
1307
1308
{
1308
1309
Path : "/" ,
1309
1310
ProxyPass : "http://test_foo_80$request_uri" ,
1310
- ProxySetHeaders : baseHeaders ,
1311
+ ProxySetHeaders : httpBaseHeaders ,
1311
1312
ResponseHeaders : http.ResponseHeaders {},
1312
1313
},
1313
1314
},
@@ -2027,9 +2028,51 @@ func TestGenerateProxySetHeaders(t *testing.T) {
2027
2028
},
2028
2029
},
2029
2030
{
2030
- msg : "grpc" ,
2031
- expectedHeaders : nil ,
2032
- GRPC : true ,
2031
+ msg : "header filter with gRPC" ,
2032
+ GRPC : true ,
2033
+ filters : & dataplane.HTTPFilters {
2034
+ RequestHeaderModifiers : & dataplane.HTTPHeaderFilter {
2035
+ Add : []dataplane.HTTPHeader {
2036
+ {
2037
+ Name : "Authorization" ,
2038
+ Value : "my-auth" ,
2039
+ },
2040
+ },
2041
+ Set : []dataplane.HTTPHeader {
2042
+ {
2043
+ Name : "Accept-Encoding" ,
2044
+ Value : "gzip" ,
2045
+ },
2046
+ },
2047
+ Remove : []string {"my-header" },
2048
+ },
2049
+ },
2050
+ expectedHeaders : []http.Header {
2051
+ {
2052
+ Name : "Authorization" ,
2053
+ Value : "${authorization_header_var}my-auth" ,
2054
+ },
2055
+ {
2056
+ Name : "Accept-Encoding" ,
2057
+ Value : "gzip" ,
2058
+ },
2059
+ {
2060
+ Name : "my-header" ,
2061
+ Value : "" ,
2062
+ },
2063
+ {
2064
+ Name : "Host" ,
2065
+ Value : "$gw_api_compliant_host" ,
2066
+ },
2067
+ {
2068
+ Name : "X-Forwarded-For" ,
2069
+ Value : "$proxy_add_x_forwarded_for" ,
2070
+ },
2071
+ {
2072
+ Name : "Authority" ,
2073
+ Value : "$gw_api_compliant_host" ,
2074
+ },
2075
+ },
2033
2076
},
2034
2077
}
2035
2078
0 commit comments