@@ -641,17 +641,17 @@ func TestCreateServers(t *testing.T) {
641
641
{
642
642
Path : "@rule0-route0" ,
643
643
ProxyPass : "http://test_foo_80$request_uri" ,
644
- ProxySetHeaders : baseHeaders ,
644
+ ProxySetHeaders : httpBaseHeaders ,
645
645
},
646
646
{
647
647
Path : "@rule0-route1" ,
648
648
ProxyPass : "http://test_foo_80$request_uri" ,
649
- ProxySetHeaders : baseHeaders ,
649
+ ProxySetHeaders : httpBaseHeaders ,
650
650
},
651
651
{
652
652
Path : "@rule0-route2" ,
653
653
ProxyPass : "http://test_foo_80$request_uri" ,
654
- ProxySetHeaders : baseHeaders ,
654
+ ProxySetHeaders : httpBaseHeaders ,
655
655
},
656
656
{
657
657
Path : "/" ,
@@ -660,7 +660,7 @@ func TestCreateServers(t *testing.T) {
660
660
{
661
661
Path : "@rule1-route0" ,
662
662
ProxyPass : "http://$test__route1_rule1$request_uri" ,
663
- ProxySetHeaders : baseHeaders ,
663
+ ProxySetHeaders : httpBaseHeaders ,
664
664
},
665
665
{
666
666
Path : "/test/" ,
@@ -669,17 +669,17 @@ func TestCreateServers(t *testing.T) {
669
669
{
670
670
Path : "/path-only/" ,
671
671
ProxyPass : "http://invalid-backend-ref$request_uri" ,
672
- ProxySetHeaders : baseHeaders ,
672
+ ProxySetHeaders : httpBaseHeaders ,
673
673
},
674
674
{
675
675
Path : "= /path-only" ,
676
676
ProxyPass : "http://invalid-backend-ref$request_uri" ,
677
- ProxySetHeaders : baseHeaders ,
677
+ ProxySetHeaders : httpBaseHeaders ,
678
678
},
679
679
{
680
680
Path : "/backend-tls-policy/" ,
681
681
ProxyPass : "https://test_btp_80$request_uri" ,
682
- ProxySetHeaders : baseHeaders ,
682
+ ProxySetHeaders : httpBaseHeaders ,
683
683
ProxySSLVerify : & http.ProxySSLVerify {
684
684
Name : "test-btp.example.com" ,
685
685
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
@@ -688,7 +688,7 @@ func TestCreateServers(t *testing.T) {
688
688
{
689
689
Path : "= /backend-tls-policy" ,
690
690
ProxyPass : "https://test_btp_80$request_uri" ,
691
- ProxySetHeaders : baseHeaders ,
691
+ ProxySetHeaders : httpBaseHeaders ,
692
692
ProxySSLVerify : & http.ProxySSLVerify {
693
693
Name : "test-btp.example.com" ,
694
694
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
@@ -792,12 +792,12 @@ func TestCreateServers(t *testing.T) {
792
792
{
793
793
Path : "= /exact" ,
794
794
ProxyPass : "http://test_foo_80$request_uri" ,
795
- ProxySetHeaders : baseHeaders ,
795
+ ProxySetHeaders : httpBaseHeaders ,
796
796
},
797
797
{
798
798
Path : "@rule12-route0" ,
799
799
ProxyPass : "http://test_foo_80$request_uri" ,
800
- ProxySetHeaders : baseHeaders ,
800
+ ProxySetHeaders : httpBaseHeaders ,
801
801
},
802
802
{
803
803
Path : "= /test" ,
@@ -859,7 +859,7 @@ func TestCreateServers(t *testing.T) {
859
859
Path : "= /grpc/method" ,
860
860
ProxyPass : "grpc://test_foo_80" ,
861
861
GRPC : true ,
862
- ProxySetHeaders : nil ,
862
+ ProxySetHeaders : grpcBaseHeaders ,
863
863
},
864
864
{
865
865
Path : "= /grpc-with-backend-tls-policy/method" ,
@@ -869,7 +869,7 @@ func TestCreateServers(t *testing.T) {
869
869
TrustedCertificate : "/etc/nginx/secrets/test-btp.crt" ,
870
870
},
871
871
GRPC : true ,
872
- ProxySetHeaders : nil ,
872
+ ProxySetHeaders : grpcBaseHeaders ,
873
873
},
874
874
}
875
875
}
@@ -989,12 +989,12 @@ func TestCreateServersConflicts(t *testing.T) {
989
989
{
990
990
Path : "/coffee/" ,
991
991
ProxyPass : "http://test_foo_80$request_uri" ,
992
- ProxySetHeaders : baseHeaders ,
992
+ ProxySetHeaders : httpBaseHeaders ,
993
993
},
994
994
{
995
995
Path : "= /coffee" ,
996
996
ProxyPass : "http://test_bar_80$request_uri" ,
997
- ProxySetHeaders : baseHeaders ,
997
+ ProxySetHeaders : httpBaseHeaders ,
998
998
},
999
999
createDefaultRootLocation (),
1000
1000
},
@@ -1027,12 +1027,12 @@ func TestCreateServersConflicts(t *testing.T) {
1027
1027
{
1028
1028
Path : "= /coffee" ,
1029
1029
ProxyPass : "http://test_foo_80$request_uri" ,
1030
- ProxySetHeaders : baseHeaders ,
1030
+ ProxySetHeaders : httpBaseHeaders ,
1031
1031
},
1032
1032
{
1033
1033
Path : "/coffee/" ,
1034
1034
ProxyPass : "http://test_bar_80$request_uri" ,
1035
- ProxySetHeaders : baseHeaders ,
1035
+ ProxySetHeaders : httpBaseHeaders ,
1036
1036
},
1037
1037
createDefaultRootLocation (),
1038
1038
},
@@ -1075,12 +1075,12 @@ func TestCreateServersConflicts(t *testing.T) {
1075
1075
{
1076
1076
Path : "/coffee/" ,
1077
1077
ProxyPass : "http://test_bar_80$request_uri" ,
1078
- ProxySetHeaders : baseHeaders ,
1078
+ ProxySetHeaders : httpBaseHeaders ,
1079
1079
},
1080
1080
{
1081
1081
Path : "= /coffee" ,
1082
1082
ProxyPass : "http://test_baz_80$request_uri" ,
1083
- ProxySetHeaders : baseHeaders ,
1083
+ ProxySetHeaders : httpBaseHeaders ,
1084
1084
},
1085
1085
createDefaultRootLocation (),
1086
1086
},
@@ -1198,12 +1198,12 @@ func TestCreateLocationsRootPath(t *testing.T) {
1198
1198
{
1199
1199
Path : "/path-1" ,
1200
1200
ProxyPass : "http://test_foo_80$request_uri" ,
1201
- ProxySetHeaders : baseHeaders ,
1201
+ ProxySetHeaders : httpBaseHeaders ,
1202
1202
},
1203
1203
{
1204
1204
Path : "/path-2" ,
1205
1205
ProxyPass : "http://test_foo_80$request_uri" ,
1206
- ProxySetHeaders : baseHeaders ,
1206
+ ProxySetHeaders : httpBaseHeaders ,
1207
1207
},
1208
1208
{
1209
1209
Path : "/" ,
@@ -1221,17 +1221,18 @@ func TestCreateLocationsRootPath(t *testing.T) {
1221
1221
{
1222
1222
Path : "/path-1" ,
1223
1223
ProxyPass : "http://test_foo_80$request_uri" ,
1224
- ProxySetHeaders : baseHeaders ,
1224
+ ProxySetHeaders : httpBaseHeaders ,
1225
1225
},
1226
1226
{
1227
1227
Path : "/path-2" ,
1228
1228
ProxyPass : "http://test_foo_80$request_uri" ,
1229
- ProxySetHeaders : baseHeaders ,
1229
+ ProxySetHeaders : httpBaseHeaders ,
1230
1230
},
1231
1231
{
1232
- Path : "/grpc" ,
1233
- ProxyPass : "grpc://test_foo_80" ,
1234
- GRPC : true ,
1232
+ Path : "/grpc" ,
1233
+ ProxyPass : "grpc://test_foo_80" ,
1234
+ GRPC : true ,
1235
+ ProxySetHeaders : grpcBaseHeaders ,
1235
1236
},
1236
1237
{
1237
1238
Path : "/" ,
@@ -1248,17 +1249,17 @@ func TestCreateLocationsRootPath(t *testing.T) {
1248
1249
{
1249
1250
Path : "/path-1" ,
1250
1251
ProxyPass : "http://test_foo_80$request_uri" ,
1251
- ProxySetHeaders : baseHeaders ,
1252
+ ProxySetHeaders : httpBaseHeaders ,
1252
1253
},
1253
1254
{
1254
1255
Path : "/path-2" ,
1255
1256
ProxyPass : "http://test_foo_80$request_uri" ,
1256
- ProxySetHeaders : baseHeaders ,
1257
+ ProxySetHeaders : httpBaseHeaders ,
1257
1258
},
1258
1259
{
1259
1260
Path : "/" ,
1260
1261
ProxyPass : "http://test_foo_80$request_uri" ,
1261
- ProxySetHeaders : baseHeaders ,
1262
+ ProxySetHeaders : httpBaseHeaders ,
1262
1263
},
1263
1264
},
1264
1265
},
@@ -1977,9 +1978,51 @@ func TestGenerateProxySetHeaders(t *testing.T) {
1977
1978
},
1978
1979
},
1979
1980
{
1980
- msg : "grpc" ,
1981
- expectedHeaders : nil ,
1982
- GRPC : true ,
1981
+ msg : "header filter with gRPC" ,
1982
+ GRPC : true ,
1983
+ filters : & dataplane.HTTPFilters {
1984
+ RequestHeaderModifiers : & dataplane.HTTPHeaderFilter {
1985
+ Add : []dataplane.HTTPHeader {
1986
+ {
1987
+ Name : "Authorization" ,
1988
+ Value : "my-auth" ,
1989
+ },
1990
+ },
1991
+ Set : []dataplane.HTTPHeader {
1992
+ {
1993
+ Name : "Accept-Encoding" ,
1994
+ Value : "gzip" ,
1995
+ },
1996
+ },
1997
+ Remove : []string {"my-header" },
1998
+ },
1999
+ },
2000
+ expectedHeaders : []http.Header {
2001
+ {
2002
+ Name : "Authorization" ,
2003
+ Value : "${authorization_header_var}my-auth" ,
2004
+ },
2005
+ {
2006
+ Name : "Accept-Encoding" ,
2007
+ Value : "gzip" ,
2008
+ },
2009
+ {
2010
+ Name : "my-header" ,
2011
+ Value : "" ,
2012
+ },
2013
+ {
2014
+ Name : "Host" ,
2015
+ Value : "$gw_api_compliant_host" ,
2016
+ },
2017
+ {
2018
+ Name : "X-Forwarded-For" ,
2019
+ Value : "$proxy_add_x_forwarded_for" ,
2020
+ },
2021
+ {
2022
+ Name : "Authority" ,
2023
+ Value : "$gw_api_compliant_host" ,
2024
+ },
2025
+ },
1983
2026
},
1984
2027
}
1985
2028
0 commit comments