@@ -12,6 +12,7 @@ import (
1212 "testing"
1313 "time"
1414
15+ "github.com/mccutchen/go-httpbin/v2/httpbin"
1516 "github.com/stretchr/testify/require"
1617)
1718
@@ -21,6 +22,16 @@ func TestIntegration(t *testing.T) {
2122 cwd , err := os .Getwd ()
2223 require .NoError (t , err )
2324
25+ // Setup the httpbin upstream local server.
26+ httpbinHandler := httpbin .New ()
27+ server := & http.Server {Addr : ":1234" , Handler : httpbinHandler }
28+ go func () {
29+ if err := server .ListenAndServe (); err != nil && err != http .ErrServerClosed {
30+ t .Logf ("HTTP server error: %v" , err )
31+ }
32+ }()
33+ t .Cleanup (func () { _ = server .Close () })
34+
2435 // Create a directory for the access logs to be written to.
2536 accessLogsDir := cwd + "/access_logs"
2637 require .NoError (t , os .RemoveAll (accessLogsDir ))
@@ -140,15 +151,15 @@ func TestIntegration(t *testing.T) {
140151 t .Logf ("response: headers=%v, body=%s" , resp .Header , string (body ))
141152 require .Equal (t , 200 , resp .StatusCode )
142153
143- // HttpBin returns a JSON object containing the request headers.
154+ // HttpBin returns a JSON object containing the request headers in this format .
144155 type httpBinHeadersBody struct {
145- Headers map [string ]string `json:"headers"`
156+ Headers map [string ][] string `json:"headers"`
146157 }
147158 var headersBody httpBinHeadersBody
148159 require .NoError (t , json .Unmarshal (body , & headersBody ))
149160
150- require .Equal (t , "envoy-header" , headersBody .Headers ["X-Envoy-Header" ])
151- require .Equal (t , "envoy-header2" , headersBody .Headers ["X-Envoy-Header2" ])
161+ require .Contains (t , headersBody .Headers ["X-Envoy-Header" ], "envoy-header" )
162+ require .Contains (t , headersBody .Headers ["X-Envoy-Header2" ], "envoy-header2" )
152163 require .NotContains (t , headersBody .Headers , "apple" )
153164
154165 // We also need to check that the response headers were mutated.
0 commit comments