Skip to content

Commit 9083c72

Browse files
committed
fix unit tests after rebase
1 parent a0b88df commit 9083c72

File tree

2 files changed

+101
-106
lines changed

2 files changed

+101
-106
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,14 @@ type Server struct {
1212

1313
// Location holds all configuration for an HTTP location.
1414
type Location struct {
15-
Return *Return
16-
ProxySSLVerify *ProxySSLVerify
17-
Path string
18-
ProxyPass string
19-
HTTPMatchVar string
20-
Rewrites []string
21-
ProxySetHeaders []Header
22-
AddHeaders []Header
23-
AddHeaderDirectives []Header
24-
AddResponseHeaders []Header
25-
SetResponseHeaders []Header
26-
RemoveResponseHeaders []string
27-
ResponseHeaders ResponseHeaders
15+
Return *Return
16+
ProxySSLVerify *ProxySSLVerify
17+
Path string
18+
ProxyPass string
19+
HTTPMatchVar string
20+
Rewrites []string
21+
ProxySetHeaders []Header
22+
ResponseHeaders ResponseHeaders
2823
}
2924

3025
// Header defines a 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
@@ -579,48 +579,48 @@ func TestCreateServers(t *testing.T) {
579579

580580
return []http.Location{
581581
{
582-
Path: "@rule0-route0",
583-
ProxyPass: "http://test_foo_80$request_uri",
584-
ProxySetHeaders: baseHeaders,
585-
AddHeaderDirectives: baseHeaders,
582+
Path: "@rule0-route0",
583+
ProxyPass: "http://test_foo_80$request_uri",
584+
ProxySetHeaders: baseHeaders,
585+
ResponseHeaders: http.ResponseHeaders{},
586586
},
587587
{
588-
Path: "@rule0-route1",
589-
ProxyPass: "http://test_foo_80$request_uri",
590-
ProxySetHeaders: baseHeaders,
591-
AddHeaderDirectives: baseHeaders,
588+
Path: "@rule0-route1",
589+
ProxyPass: "http://test_foo_80$request_uri",
590+
ProxySetHeaders: baseHeaders,
591+
ResponseHeaders: http.ResponseHeaders{},
592592
},
593593
{
594-
Path: "@rule0-route2",
595-
ProxyPass: "http://test_foo_80$request_uri",
596-
ProxySetHeaders: baseHeaders,
597-
AddHeaderDirectives: baseHeaders,
594+
Path: "@rule0-route2",
595+
ProxyPass: "http://test_foo_80$request_uri",
596+
ProxySetHeaders: baseHeaders,
597+
ResponseHeaders: http.ResponseHeaders{},
598598
},
599599
{
600600
Path: "/",
601601
HTTPMatchVar: expectedMatchString(slashMatches),
602602
},
603603
{
604-
Path: "@rule1-route0",
605-
ProxyPass: "http://$test__route1_rule1$request_uri",
606-
ProxySetHeaders: baseHeaders,
607-
AddHeaderDirectives: baseHeaders,
604+
Path: "@rule1-route0",
605+
ProxyPass: "http://$test__route1_rule1$request_uri",
606+
ProxySetHeaders: baseHeaders,
607+
ResponseHeaders: http.ResponseHeaders{},
608608
},
609609
{
610610
Path: "/test/",
611611
HTTPMatchVar: expectedMatchString(testMatches),
612612
},
613613
{
614-
Path: "/path-only/",
615-
ProxyPass: "http://invalid-backend-ref$request_uri",
616-
ProxySetHeaders: baseHeaders,
617-
AddHeaderDirectives: baseHeaders,
614+
Path: "/path-only/",
615+
ProxyPass: "http://invalid-backend-ref$request_uri",
616+
ProxySetHeaders: baseHeaders,
617+
ResponseHeaders: http.ResponseHeaders{},
618618
},
619619
{
620-
Path: "= /path-only",
621-
ProxyPass: "http://invalid-backend-ref$request_uri",
622-
ProxySetHeaders: baseHeaders,
623-
AddHeaderDirectives: baseHeaders,
620+
Path: "= /path-only",
621+
ProxyPass: "http://invalid-backend-ref$request_uri",
622+
ProxySetHeaders: baseHeaders,
623+
ResponseHeaders: http.ResponseHeaders{},
624624
},
625625
{
626626
Path: "/backend-tls-policy/",
@@ -684,25 +684,25 @@ func TestCreateServers(t *testing.T) {
684684
HTTPMatchVar: expectedMatchString(redirectHeaderMatches),
685685
},
686686
{
687-
Path: "/rewrite/",
688-
Rewrites: []string{"^ /replacement break"},
689-
ProxyPass: "http://test_foo_80",
690-
ProxySetHeaders: rewriteProxySetHeaders,
691-
AddHeaderDirectives: baseHeaders,
687+
Path: "/rewrite/",
688+
Rewrites: []string{"^ /replacement break"},
689+
ProxyPass: "http://test_foo_80",
690+
ProxySetHeaders: rewriteProxySetHeaders,
691+
ResponseHeaders: http.ResponseHeaders{},
692692
},
693693
{
694-
Path: "= /rewrite",
695-
Rewrites: []string{"^ /replacement break"},
696-
ProxyPass: "http://test_foo_80",
697-
ProxySetHeaders: rewriteProxySetHeaders,
698-
AddHeaderDirectives: baseHeaders,
694+
Path: "= /rewrite",
695+
Rewrites: []string{"^ /replacement break"},
696+
ProxyPass: "http://test_foo_80",
697+
ProxySetHeaders: rewriteProxySetHeaders,
698+
ResponseHeaders: http.ResponseHeaders{},
699699
},
700700
{
701-
Path: "@rule7-route0",
702-
Rewrites: []string{"^/rewrite-with-headers(.*)$ /prefix-replacement$1 break"},
703-
ProxyPass: "http://test_foo_80",
704-
ProxySetHeaders: rewriteProxySetHeaders,
705-
AddHeaderDirectives: baseHeaders,
701+
Path: "@rule8-route0",
702+
Rewrites: []string{"^/rewrite-with-headers(.*)$ /prefix-replacement$1 break"},
703+
ProxyPass: "http://test_foo_80",
704+
ProxySetHeaders: rewriteProxySetHeaders,
705+
ResponseHeaders: http.ResponseHeaders{},
706706
},
707707
{
708708
Path: "/rewrite-with-headers/",
@@ -739,16 +739,16 @@ func TestCreateServers(t *testing.T) {
739739
HTTPMatchVar: expectedMatchString(invalidFilterHeaderMatches),
740740
},
741741
{
742-
Path: "= /exact",
743-
ProxyPass: "http://test_foo_80$request_uri",
744-
ProxySetHeaders: baseHeaders,
745-
AddHeaderDirectives: baseHeaders,
742+
Path: "= /exact",
743+
ProxyPass: "http://test_foo_80$request_uri",
744+
ProxySetHeaders: baseHeaders,
745+
ResponseHeaders: http.ResponseHeaders{},
746746
},
747747
{
748-
Path: "@rule11-route0",
749-
ProxyPass: "http://test_foo_80$request_uri",
750-
ProxySetHeaders: baseHeaders,
751-
AddHeaderDirectives: baseHeaders,
748+
Path: "@rule12-route0",
749+
ProxyPass: "http://test_foo_80$request_uri",
750+
ProxySetHeaders: baseHeaders,
751+
ResponseHeaders: http.ResponseHeaders{},
752752
},
753753
{
754754
Path: "= /test",
@@ -779,7 +779,7 @@ func TestCreateServers(t *testing.T) {
779779
Value: "$connection_upgrade",
780780
},
781781
},
782-
AddHeaderDirectives: baseHeaders,
782+
ResponseHeaders: http.ResponseHeaders{},
783783
},
784784
{
785785
Path: "= /proxy-set-headers",
@@ -806,7 +806,7 @@ func TestCreateServers(t *testing.T) {
806806
Value: "$connection_upgrade",
807807
},
808808
},
809-
AddHeaderDirectives: baseHeaders,
809+
ResponseHeaders: http.ResponseHeaders{},
810810
},
811811
}
812812
}
@@ -910,16 +910,16 @@ func TestCreateServersConflicts(t *testing.T) {
910910
},
911911
expLocs: []http.Location{
912912
{
913-
Path: "/coffee/",
914-
ProxyPass: "http://test_foo_80$request_uri",
915-
ProxySetHeaders: baseHeaders,
916-
AddHeaderDirectives: baseHeaders,
913+
Path: "/coffee/",
914+
ProxyPass: "http://test_foo_80$request_uri",
915+
ProxySetHeaders: baseHeaders,
916+
ResponseHeaders: http.ResponseHeaders{},
917917
},
918918
{
919-
Path: "= /coffee",
920-
ProxyPass: "http://test_bar_80$request_uri",
921-
ProxySetHeaders: baseHeaders,
922-
AddHeaderDirectives: baseHeaders,
919+
Path: "= /coffee",
920+
ProxyPass: "http://test_bar_80$request_uri",
921+
ProxySetHeaders: baseHeaders,
922+
ResponseHeaders: http.ResponseHeaders{},
923923
},
924924
createDefaultRootLocation(),
925925
},
@@ -950,16 +950,16 @@ func TestCreateServersConflicts(t *testing.T) {
950950
},
951951
expLocs: []http.Location{
952952
{
953-
Path: "= /coffee",
954-
ProxyPass: "http://test_foo_80$request_uri",
955-
ProxySetHeaders: baseHeaders,
956-
AddHeaderDirectives: baseHeaders,
953+
Path: "= /coffee",
954+
ProxyPass: "http://test_foo_80$request_uri",
955+
ProxySetHeaders: baseHeaders,
956+
ResponseHeaders: http.ResponseHeaders{},
957957
},
958958
{
959-
Path: "/coffee/",
960-
ProxyPass: "http://test_bar_80$request_uri",
961-
ProxySetHeaders: baseHeaders,
962-
AddHeaderDirectives: baseHeaders,
959+
Path: "/coffee/",
960+
ProxyPass: "http://test_bar_80$request_uri",
961+
ProxySetHeaders: baseHeaders,
962+
ResponseHeaders: http.ResponseHeaders{},
963963
},
964964
createDefaultRootLocation(),
965965
},
@@ -1000,16 +1000,16 @@ func TestCreateServersConflicts(t *testing.T) {
10001000
},
10011001
expLocs: []http.Location{
10021002
{
1003-
Path: "/coffee/",
1004-
ProxyPass: "http://test_bar_80$request_uri",
1005-
ProxySetHeaders: baseHeaders,
1006-
AddHeaderDirectives: baseHeaders,
1003+
Path: "/coffee/",
1004+
ProxyPass: "http://test_bar_80$request_uri",
1005+
ProxySetHeaders: baseHeaders,
1006+
ResponseHeaders: http.ResponseHeaders{},
10071007
},
10081008
{
1009-
Path: "= /coffee",
1010-
ProxyPass: "http://test_baz_80$request_uri",
1011-
ProxySetHeaders: baseHeaders,
1012-
AddHeaderDirectives: baseHeaders,
1009+
Path: "= /coffee",
1010+
ProxyPass: "http://test_baz_80$request_uri",
1011+
ProxySetHeaders: baseHeaders,
1012+
ResponseHeaders: http.ResponseHeaders{},
10131013
},
10141014
createDefaultRootLocation(),
10151015
},
@@ -1111,16 +1111,16 @@ func TestCreateLocationsRootPath(t *testing.T) {
11111111
pathRules: getPathRules(false /* rootPath */),
11121112
expLocations: []http.Location{
11131113
{
1114-
Path: "/path-1",
1115-
ProxyPass: "http://test_foo_80$request_uri",
1116-
ProxySetHeaders: baseHeaders,
1117-
AddHeaderDirectives: baseHeaders,
1114+
Path: "/path-1",
1115+
ProxyPass: "http://test_foo_80$request_uri",
1116+
ProxySetHeaders: baseHeaders,
1117+
ResponseHeaders: http.ResponseHeaders{},
11181118
},
11191119
{
1120-
Path: "/path-2",
1121-
ProxyPass: "http://test_foo_80$request_uri",
1122-
ProxySetHeaders: baseHeaders,
1123-
AddHeaderDirectives: baseHeaders,
1120+
Path: "/path-2",
1121+
ProxyPass: "http://test_foo_80$request_uri",
1122+
ProxySetHeaders: baseHeaders,
1123+
ResponseHeaders: http.ResponseHeaders{},
11241124
},
11251125
{
11261126
Path: "/",
@@ -1135,22 +1135,22 @@ func TestCreateLocationsRootPath(t *testing.T) {
11351135
pathRules: getPathRules(true /* rootPath */),
11361136
expLocations: []http.Location{
11371137
{
1138-
Path: "/path-1",
1139-
ProxyPass: "http://test_foo_80$request_uri",
1140-
ProxySetHeaders: baseHeaders,
1141-
AddHeaderDirectives: baseHeaders,
1138+
Path: "/path-1",
1139+
ProxyPass: "http://test_foo_80$request_uri",
1140+
ProxySetHeaders: baseHeaders,
1141+
ResponseHeaders: http.ResponseHeaders{},
11421142
},
11431143
{
1144-
Path: "/path-2",
1145-
ProxyPass: "http://test_foo_80$request_uri",
1146-
ProxySetHeaders: baseHeaders,
1147-
AddHeaderDirectives: baseHeaders,
1144+
Path: "/path-2",
1145+
ProxyPass: "http://test_foo_80$request_uri",
1146+
ProxySetHeaders: baseHeaders,
1147+
ResponseHeaders: http.ResponseHeaders{},
11481148
},
11491149
{
1150-
Path: "/",
1151-
ProxyPass: "http://test_foo_80$request_uri",
1152-
ProxySetHeaders: baseHeaders,
1153-
AddHeaderDirectives: baseHeaders,
1150+
Path: "/",
1151+
ProxyPass: "http://test_foo_80$request_uri",
1152+
ProxySetHeaders: baseHeaders,
1153+
ResponseHeaders: http.ResponseHeaders{},
11541154
},
11551155
},
11561156
},

0 commit comments

Comments
 (0)