@@ -614,17 +614,17 @@ func TestCreateServers(t *testing.T) {
614
614
{
615
615
Path : "@rule0-route0" ,
616
616
ProxyPass : "http://test_foo_80$request_uri" ,
617
- ProxySetHeaders : baseHeaders ,
617
+ ProxySetHeaders : httpBaseHeaders ,
618
618
},
619
619
{
620
620
Path : "@rule0-route1" ,
621
621
ProxyPass : "http://test_foo_80$request_uri" ,
622
- ProxySetHeaders : baseHeaders ,
622
+ ProxySetHeaders : httpBaseHeaders ,
623
623
},
624
624
{
625
625
Path : "@rule0-route2" ,
626
626
ProxyPass : "http://test_foo_80$request_uri" ,
627
- ProxySetHeaders : baseHeaders ,
627
+ ProxySetHeaders : httpBaseHeaders ,
628
628
},
629
629
{
630
630
Path : "/" ,
@@ -633,7 +633,7 @@ func TestCreateServers(t *testing.T) {
633
633
{
634
634
Path : "@rule1-route0" ,
635
635
ProxyPass : "http://$test__route1_rule1$request_uri" ,
636
- ProxySetHeaders : baseHeaders ,
636
+ ProxySetHeaders : httpBaseHeaders ,
637
637
},
638
638
{
639
639
Path : "/test/" ,
@@ -642,17 +642,17 @@ func TestCreateServers(t *testing.T) {
642
642
{
643
643
Path : "/path-only/" ,
644
644
ProxyPass : "http://invalid-backend-ref$request_uri" ,
645
- ProxySetHeaders : baseHeaders ,
645
+ ProxySetHeaders : httpBaseHeaders ,
646
646
},
647
647
{
648
648
Path : "= /path-only" ,
649
649
ProxyPass : "http://invalid-backend-ref$request_uri" ,
650
- ProxySetHeaders : baseHeaders ,
650
+ ProxySetHeaders : httpBaseHeaders ,
651
651
},
652
652
{
653
653
Path : "/backend-tls-policy/" ,
654
654
ProxyPass : "https://test_btp_80$request_uri" ,
655
- ProxySetHeaders : baseHeaders ,
655
+ ProxySetHeaders : httpBaseHeaders ,
656
656
ProxySSLVerify : & http.ProxySSLVerify {
657
657
Name : "test-btp.example.com" ,
658
658
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
@@ -661,7 +661,7 @@ func TestCreateServers(t *testing.T) {
661
661
{
662
662
Path : "= /backend-tls-policy" ,
663
663
ProxyPass : "https://test_btp_80$request_uri" ,
664
- ProxySetHeaders : baseHeaders ,
664
+ ProxySetHeaders : httpBaseHeaders ,
665
665
ProxySSLVerify : & http.ProxySSLVerify {
666
666
Name : "test-btp.example.com" ,
667
667
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
@@ -765,12 +765,12 @@ func TestCreateServers(t *testing.T) {
765
765
{
766
766
Path : "= /exact" ,
767
767
ProxyPass : "http://test_foo_80$request_uri" ,
768
- ProxySetHeaders : baseHeaders ,
768
+ ProxySetHeaders : httpBaseHeaders ,
769
769
},
770
770
{
771
771
Path : "@rule12-route0" ,
772
772
ProxyPass : "http://test_foo_80$request_uri" ,
773
- ProxySetHeaders : baseHeaders ,
773
+ ProxySetHeaders : httpBaseHeaders ,
774
774
},
775
775
{
776
776
Path : "= /test" ,
@@ -832,7 +832,7 @@ func TestCreateServers(t *testing.T) {
832
832
Path : "= /grpc/method" ,
833
833
ProxyPass : "grpc://test_foo_80" ,
834
834
GRPC : true ,
835
- ProxySetHeaders : nil ,
835
+ ProxySetHeaders : grpcBaseHeaders ,
836
836
},
837
837
{
838
838
Path : "= /grpc-with-backend-tls-policy/method" ,
@@ -842,7 +842,7 @@ func TestCreateServers(t *testing.T) {
842
842
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
843
843
},
844
844
GRPC : true ,
845
- ProxySetHeaders : nil ,
845
+ ProxySetHeaders : grpcBaseHeaders ,
846
846
},
847
847
}
848
848
}
@@ -962,12 +962,12 @@ func TestCreateServersConflicts(t *testing.T) {
962
962
{
963
963
Path : "/coffee/" ,
964
964
ProxyPass : "http://test_foo_80$request_uri" ,
965
- ProxySetHeaders : baseHeaders ,
965
+ ProxySetHeaders : httpBaseHeaders ,
966
966
},
967
967
{
968
968
Path : "= /coffee" ,
969
969
ProxyPass : "http://test_bar_80$request_uri" ,
970
- ProxySetHeaders : baseHeaders ,
970
+ ProxySetHeaders : httpBaseHeaders ,
971
971
},
972
972
createDefaultRootLocation (),
973
973
},
@@ -1000,12 +1000,12 @@ func TestCreateServersConflicts(t *testing.T) {
1000
1000
{
1001
1001
Path : "= /coffee" ,
1002
1002
ProxyPass : "http://test_foo_80$request_uri" ,
1003
- ProxySetHeaders : baseHeaders ,
1003
+ ProxySetHeaders : httpBaseHeaders ,
1004
1004
},
1005
1005
{
1006
1006
Path : "/coffee/" ,
1007
1007
ProxyPass : "http://test_bar_80$request_uri" ,
1008
- ProxySetHeaders : baseHeaders ,
1008
+ ProxySetHeaders : httpBaseHeaders ,
1009
1009
},
1010
1010
createDefaultRootLocation (),
1011
1011
},
@@ -1048,12 +1048,12 @@ func TestCreateServersConflicts(t *testing.T) {
1048
1048
{
1049
1049
Path : "/coffee/" ,
1050
1050
ProxyPass : "http://test_bar_80$request_uri" ,
1051
- ProxySetHeaders : baseHeaders ,
1051
+ ProxySetHeaders : httpBaseHeaders ,
1052
1052
},
1053
1053
{
1054
1054
Path : "= /coffee" ,
1055
1055
ProxyPass : "http://test_baz_80$request_uri" ,
1056
- ProxySetHeaders : baseHeaders ,
1056
+ ProxySetHeaders : httpBaseHeaders ,
1057
1057
},
1058
1058
createDefaultRootLocation (),
1059
1059
},
@@ -1171,12 +1171,12 @@ func TestCreateLocationsRootPath(t *testing.T) {
1171
1171
{
1172
1172
Path : "/path-1" ,
1173
1173
ProxyPass : "http://test_foo_80$request_uri" ,
1174
- ProxySetHeaders : baseHeaders ,
1174
+ ProxySetHeaders : httpBaseHeaders ,
1175
1175
},
1176
1176
{
1177
1177
Path : "/path-2" ,
1178
1178
ProxyPass : "http://test_foo_80$request_uri" ,
1179
- ProxySetHeaders : baseHeaders ,
1179
+ ProxySetHeaders : httpBaseHeaders ,
1180
1180
},
1181
1181
{
1182
1182
Path : "/" ,
@@ -1194,17 +1194,18 @@ func TestCreateLocationsRootPath(t *testing.T) {
1194
1194
{
1195
1195
Path : "/path-1" ,
1196
1196
ProxyPass : "http://test_foo_80$request_uri" ,
1197
- ProxySetHeaders : baseHeaders ,
1197
+ ProxySetHeaders : httpBaseHeaders ,
1198
1198
},
1199
1199
{
1200
1200
Path : "/path-2" ,
1201
1201
ProxyPass : "http://test_foo_80$request_uri" ,
1202
- ProxySetHeaders : baseHeaders ,
1202
+ ProxySetHeaders : httpBaseHeaders ,
1203
1203
},
1204
1204
{
1205
- Path : "/grpc" ,
1206
- ProxyPass : "grpc://test_foo_80" ,
1207
- GRPC : true ,
1205
+ Path : "/grpc" ,
1206
+ ProxyPass : "grpc://test_foo_80" ,
1207
+ GRPC : true ,
1208
+ ProxySetHeaders : grpcBaseHeaders ,
1208
1209
},
1209
1210
{
1210
1211
Path : "/" ,
@@ -1221,17 +1222,17 @@ func TestCreateLocationsRootPath(t *testing.T) {
1221
1222
{
1222
1223
Path : "/path-1" ,
1223
1224
ProxyPass : "http://test_foo_80$request_uri" ,
1224
- ProxySetHeaders : baseHeaders ,
1225
+ ProxySetHeaders : httpBaseHeaders ,
1225
1226
},
1226
1227
{
1227
1228
Path : "/path-2" ,
1228
1229
ProxyPass : "http://test_foo_80$request_uri" ,
1229
- ProxySetHeaders : baseHeaders ,
1230
+ ProxySetHeaders : httpBaseHeaders ,
1230
1231
},
1231
1232
{
1232
1233
Path : "/" ,
1233
1234
ProxyPass : "http://test_foo_80$request_uri" ,
1234
- ProxySetHeaders : baseHeaders ,
1235
+ ProxySetHeaders : httpBaseHeaders ,
1235
1236
},
1236
1237
},
1237
1238
},
@@ -1950,9 +1951,51 @@ func TestGenerateProxySetHeaders(t *testing.T) {
1950
1951
},
1951
1952
},
1952
1953
{
1953
- msg : "grpc" ,
1954
- expectedHeaders : nil ,
1955
- GRPC : true ,
1954
+ msg : "header filter with gRPC" ,
1955
+ GRPC : true ,
1956
+ filters : & dataplane.HTTPFilters {
1957
+ RequestHeaderModifiers : & dataplane.HTTPHeaderFilter {
1958
+ Add : []dataplane.HTTPHeader {
1959
+ {
1960
+ Name : "Authorization" ,
1961
+ Value : "my-auth" ,
1962
+ },
1963
+ },
1964
+ Set : []dataplane.HTTPHeader {
1965
+ {
1966
+ Name : "Accept-Encoding" ,
1967
+ Value : "gzip" ,
1968
+ },
1969
+ },
1970
+ Remove : []string {"my-header" },
1971
+ },
1972
+ },
1973
+ expectedHeaders : []http.Header {
1974
+ {
1975
+ Name : "Authorization" ,
1976
+ Value : "${authorization_header_var}my-auth" ,
1977
+ },
1978
+ {
1979
+ Name : "Accept-Encoding" ,
1980
+ Value : "gzip" ,
1981
+ },
1982
+ {
1983
+ Name : "my-header" ,
1984
+ Value : "" ,
1985
+ },
1986
+ {
1987
+ Name : "Host" ,
1988
+ Value : "$gw_api_compliant_host" ,
1989
+ },
1990
+ {
1991
+ Name : "X-Forwarded-For" ,
1992
+ Value : "$proxy_add_x_forwarded_for" ,
1993
+ },
1994
+ {
1995
+ Name : "Authority" ,
1996
+ Value : "$gw_api_compliant_host" ,
1997
+ },
1998
+ },
1956
1999
},
1957
2000
}
1958
2001
0 commit comments