Skip to content

Commit cb9322a

Browse files
committed
fix unit tests after rebase
1 parent a167db1 commit cb9322a

File tree

2 files changed

+103
-106
lines changed

2 files changed

+103
-106
lines changed

internal/mode/static/nginx/config/http/config.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@ type Server struct {
1313

1414
// Location holds all configuration for an HTTP location.
1515
type Location struct {
16-
Path string
17-
ProxyPass string
18-
HTTPMatchKey string
19-
ProxySetHeaders []Header
20-
ProxySSLVerify *ProxySSLVerify
21-
Return *Return
22-
Rewrites []string
23-
GRPC bool
24-
HTTPMatchVar string
25-
AddResponseHeaders []Header
26-
SetResponseHeaders []Header
27-
RemoveResponseHeaders []string
28-
ResponseHeaders ResponseHeaders
16+
Path string
17+
ProxyPass string
18+
HTTPMatchKey string
19+
ProxySetHeaders []Header
20+
ProxySSLVerify *ProxySSLVerify
21+
Return *Return
22+
Rewrites []string
23+
GRPC bool
24+
HTTPMatchVar string
25+
ResponseHeaders ResponseHeaders
2926
}
3027

3128
// Header defines an HTTP header to be passed to the proxied server.

internal/mode/static/nginx/config/servers_test.go

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -612,48 +612,48 @@ func TestCreateServers(t *testing.T) {
612612

613613
return []http.Location{
614614
{
615-
Path: "@rule0-route0",
616-
ProxyPass: "http://test_foo_80$request_uri",
617-
ProxySetHeaders: baseHeaders,
618-
AddHeaderDirectives: baseHeaders,
615+
Path: "@rule0-route0",
616+
ProxyPass: "http://test_foo_80$request_uri",
617+
ProxySetHeaders: baseHeaders,
618+
ResponseHeaders: http.ResponseHeaders{},
619619
},
620620
{
621-
Path: "@rule0-route1",
622-
ProxyPass: "http://test_foo_80$request_uri",
623-
ProxySetHeaders: baseHeaders,
624-
AddHeaderDirectives: baseHeaders,
621+
Path: "@rule0-route1",
622+
ProxyPass: "http://test_foo_80$request_uri",
623+
ProxySetHeaders: baseHeaders,
624+
ResponseHeaders: http.ResponseHeaders{},
625625
},
626626
{
627-
Path: "@rule0-route2",
628-
ProxyPass: "http://test_foo_80$request_uri",
629-
ProxySetHeaders: baseHeaders,
630-
AddHeaderDirectives: baseHeaders,
627+
Path: "@rule0-route2",
628+
ProxyPass: "http://test_foo_80$request_uri",
629+
ProxySetHeaders: baseHeaders,
630+
ResponseHeaders: http.ResponseHeaders{},
631631
},
632632
{
633633
Path: "/",
634634
HTTPMatchKey: ssl + "1_0",
635635
},
636636
{
637-
Path: "@rule1-route0",
638-
ProxyPass: "http://$test__route1_rule1$request_uri",
639-
ProxySetHeaders: baseHeaders,
640-
AddHeaderDirectives: baseHeaders,
637+
Path: "@rule1-route0",
638+
ProxyPass: "http://$test__route1_rule1$request_uri",
639+
ProxySetHeaders: baseHeaders,
640+
ResponseHeaders: http.ResponseHeaders{},
641641
},
642642
{
643643
Path: "/test/",
644644
HTTPMatchKey: ssl + "1_1",
645645
},
646646
{
647-
Path: "/path-only/",
648-
ProxyPass: "http://invalid-backend-ref$request_uri",
649-
ProxySetHeaders: baseHeaders,
650-
AddHeaderDirectives: baseHeaders,
647+
Path: "/path-only/",
648+
ProxyPass: "http://invalid-backend-ref$request_uri",
649+
ProxySetHeaders: baseHeaders,
650+
ResponseHeaders: http.ResponseHeaders{},
651651
},
652652
{
653-
Path: "= /path-only",
654-
ProxyPass: "http://invalid-backend-ref$request_uri",
655-
ProxySetHeaders: baseHeaders,
656-
AddHeaderDirectives: baseHeaders,
653+
Path: "= /path-only",
654+
ProxyPass: "http://invalid-backend-ref$request_uri",
655+
ProxySetHeaders: baseHeaders,
656+
ResponseHeaders: http.ResponseHeaders{},
657657
},
658658
{
659659
Path: "/backend-tls-policy/",
@@ -717,25 +717,25 @@ func TestCreateServers(t *testing.T) {
717717
HTTPMatchKey: ssl + "1_6",
718718
},
719719
{
720-
Path: "/rewrite/",
721-
Rewrites: []string{"^ /replacement break"},
722-
ProxyPass: "http://test_foo_80",
723-
ProxySetHeaders: rewriteProxySetHeaders,
724-
AddHeaderDirectives: baseHeaders,
720+
Path: "/rewrite/",
721+
Rewrites: []string{"^ /replacement break"},
722+
ProxyPass: "http://test_foo_80",
723+
ProxySetHeaders: rewriteProxySetHeaders,
724+
ResponseHeaders: http.ResponseHeaders{},
725725
},
726726
{
727-
Path: "= /rewrite",
728-
Rewrites: []string{"^ /replacement break"},
729-
ProxyPass: "http://test_foo_80",
730-
ProxySetHeaders: rewriteProxySetHeaders,
731-
AddHeaderDirectives: baseHeaders,
727+
Path: "= /rewrite",
728+
Rewrites: []string{"^ /replacement break"},
729+
ProxyPass: "http://test_foo_80",
730+
ProxySetHeaders: rewriteProxySetHeaders,
731+
ResponseHeaders: http.ResponseHeaders{},
732732
},
733733
{
734-
Path: "@rule7-route0",
735-
Rewrites: []string{"^/rewrite-with-headers(.*)$ /prefix-replacement$1 break"},
736-
ProxyPass: "http://test_foo_80",
737-
ProxySetHeaders: rewriteProxySetHeaders,
738-
AddHeaderDirectives: baseHeaders,
734+
Path: "@rule8-route0",
735+
Rewrites: []string{"^/rewrite-with-headers(.*)$ /prefix-replacement$1 break"},
736+
ProxyPass: "http://test_foo_80",
737+
ProxySetHeaders: rewriteProxySetHeaders,
738+
ResponseHeaders: http.ResponseHeaders{},
739739
},
740740
{
741741
Path: "/rewrite-with-headers/",
@@ -772,16 +772,16 @@ func TestCreateServers(t *testing.T) {
772772
HTTPMatchKey: ssl + "1_10",
773773
},
774774
{
775-
Path: "= /exact",
776-
ProxyPass: "http://test_foo_80$request_uri",
777-
ProxySetHeaders: baseHeaders,
778-
AddHeaderDirectives: baseHeaders,
775+
Path: "= /exact",
776+
ProxyPass: "http://test_foo_80$request_uri",
777+
ProxySetHeaders: baseHeaders,
778+
ResponseHeaders: http.ResponseHeaders{},
779779
},
780780
{
781-
Path: "@rule11-route0",
782-
ProxyPass: "http://test_foo_80$request_uri",
783-
ProxySetHeaders: baseHeaders,
784-
AddHeaderDirectives: baseHeaders,
781+
Path: "@rule12-route0",
782+
ProxyPass: "http://test_foo_80$request_uri",
783+
ProxySetHeaders: baseHeaders,
784+
ResponseHeaders: http.ResponseHeaders{},
785785
},
786786
{
787787
Path: "= /test",
@@ -812,7 +812,7 @@ func TestCreateServers(t *testing.T) {
812812
Value: "$connection_upgrade",
813813
},
814814
},
815-
AddHeaderDirectives: baseHeaders,
815+
ResponseHeaders: http.ResponseHeaders{},
816816
},
817817
{
818818
Path: "= /proxy-set-headers",
@@ -839,7 +839,7 @@ func TestCreateServers(t *testing.T) {
839839
Value: "$connection_upgrade",
840840
},
841841
},
842-
AddHeaderDirectives: baseHeaders,
842+
ResponseHeaders: http.ResponseHeaders{},
843843
},
844844
{
845845
Path: "= /grpc/method",
@@ -973,16 +973,16 @@ func TestCreateServersConflicts(t *testing.T) {
973973
},
974974
expLocs: []http.Location{
975975
{
976-
Path: "/coffee/",
977-
ProxyPass: "http://test_foo_80$request_uri",
978-
ProxySetHeaders: baseHeaders,
979-
AddHeaderDirectives: baseHeaders,
976+
Path: "/coffee/",
977+
ProxyPass: "http://test_foo_80$request_uri",
978+
ProxySetHeaders: baseHeaders,
979+
ResponseHeaders: http.ResponseHeaders{},
980980
},
981981
{
982-
Path: "= /coffee",
983-
ProxyPass: "http://test_bar_80$request_uri",
984-
ProxySetHeaders: baseHeaders,
985-
AddHeaderDirectives: baseHeaders,
982+
Path: "= /coffee",
983+
ProxyPass: "http://test_bar_80$request_uri",
984+
ProxySetHeaders: baseHeaders,
985+
ResponseHeaders: http.ResponseHeaders{},
986986
},
987987
createDefaultRootLocation(),
988988
},
@@ -1013,16 +1013,16 @@ func TestCreateServersConflicts(t *testing.T) {
10131013
},
10141014
expLocs: []http.Location{
10151015
{
1016-
Path: "= /coffee",
1017-
ProxyPass: "http://test_foo_80$request_uri",
1018-
ProxySetHeaders: baseHeaders,
1019-
AddHeaderDirectives: baseHeaders,
1016+
Path: "= /coffee",
1017+
ProxyPass: "http://test_foo_80$request_uri",
1018+
ProxySetHeaders: baseHeaders,
1019+
ResponseHeaders: http.ResponseHeaders{},
10201020
},
10211021
{
1022-
Path: "/coffee/",
1023-
ProxyPass: "http://test_bar_80$request_uri",
1024-
ProxySetHeaders: baseHeaders,
1025-
AddHeaderDirectives: baseHeaders,
1022+
Path: "/coffee/",
1023+
ProxyPass: "http://test_bar_80$request_uri",
1024+
ProxySetHeaders: baseHeaders,
1025+
ResponseHeaders: http.ResponseHeaders{},
10261026
},
10271027
createDefaultRootLocation(),
10281028
},
@@ -1063,16 +1063,16 @@ func TestCreateServersConflicts(t *testing.T) {
10631063
},
10641064
expLocs: []http.Location{
10651065
{
1066-
Path: "/coffee/",
1067-
ProxyPass: "http://test_bar_80$request_uri",
1068-
ProxySetHeaders: baseHeaders,
1069-
AddHeaderDirectives: baseHeaders,
1066+
Path: "/coffee/",
1067+
ProxyPass: "http://test_bar_80$request_uri",
1068+
ProxySetHeaders: baseHeaders,
1069+
ResponseHeaders: http.ResponseHeaders{},
10701070
},
10711071
{
1072-
Path: "= /coffee",
1073-
ProxyPass: "http://test_baz_80$request_uri",
1074-
ProxySetHeaders: baseHeaders,
1075-
AddHeaderDirectives: baseHeaders,
1072+
Path: "= /coffee",
1073+
ProxyPass: "http://test_baz_80$request_uri",
1074+
ProxySetHeaders: baseHeaders,
1075+
ResponseHeaders: http.ResponseHeaders{},
10761076
},
10771077
createDefaultRootLocation(),
10781078
},
@@ -1188,16 +1188,16 @@ func TestCreateLocationsRootPath(t *testing.T) {
11881188
pathRules: getPathRules(false /* rootPath */, false /* grpc */),
11891189
expLocations: []http.Location{
11901190
{
1191-
Path: "/path-1",
1192-
ProxyPass: "http://test_foo_80$request_uri",
1193-
ProxySetHeaders: baseHeaders,
1194-
AddHeaderDirectives: baseHeaders,
1191+
Path: "/path-1",
1192+
ProxyPass: "http://test_foo_80$request_uri",
1193+
ProxySetHeaders: baseHeaders,
1194+
ResponseHeaders: http.ResponseHeaders{},
11951195
},
11961196
{
1197-
Path: "/path-2",
1198-
ProxyPass: "http://test_foo_80$request_uri",
1199-
ProxySetHeaders: baseHeaders,
1200-
AddHeaderDirectives: baseHeaders,
1197+
Path: "/path-2",
1198+
ProxyPass: "http://test_foo_80$request_uri",
1199+
ProxySetHeaders: baseHeaders,
1200+
ResponseHeaders: http.ResponseHeaders{},
12011201
},
12021202
{
12031203
Path: "/",
@@ -1240,22 +1240,22 @@ func TestCreateLocationsRootPath(t *testing.T) {
12401240
pathRules: getPathRules(true /* rootPath */, false /* grpc */),
12411241
expLocations: []http.Location{
12421242
{
1243-
Path: "/path-1",
1244-
ProxyPass: "http://test_foo_80$request_uri",
1245-
ProxySetHeaders: baseHeaders,
1246-
AddHeaderDirectives: baseHeaders,
1243+
Path: "/path-1",
1244+
ProxyPass: "http://test_foo_80$request_uri",
1245+
ProxySetHeaders: baseHeaders,
1246+
ResponseHeaders: http.ResponseHeaders{},
12471247
},
12481248
{
1249-
Path: "/path-2",
1250-
ProxyPass: "http://test_foo_80$request_uri",
1251-
ProxySetHeaders: baseHeaders,
1252-
AddHeaderDirectives: baseHeaders,
1249+
Path: "/path-2",
1250+
ProxyPass: "http://test_foo_80$request_uri",
1251+
ProxySetHeaders: baseHeaders,
1252+
ResponseHeaders: http.ResponseHeaders{},
12531253
},
12541254
{
1255-
Path: "/",
1256-
ProxyPass: "http://test_foo_80$request_uri",
1257-
ProxySetHeaders: baseHeaders,
1258-
AddHeaderDirectives: baseHeaders,
1255+
Path: "/",
1256+
ProxyPass: "http://test_foo_80$request_uri",
1257+
ProxySetHeaders: baseHeaders,
1258+
ResponseHeaders: http.ResponseHeaders{},
12591259
},
12601260
},
12611261
},

0 commit comments

Comments
 (0)