44 "encoding/base64"
55 "fmt"
66 "io"
7- "io/ioutil"
87 "net/http"
98 "net/http/httptest"
109 "net/url"
@@ -119,7 +118,7 @@ func TestRedirectResponse(t *testing.T) {
119118}
120119
121120func TestRedirectFull (t * testing.T ) {
122- testFileBytes , err := ioutil .ReadFile ("../../testdata/test-stub.exe" )
121+ testFileBytes , err := os .ReadFile ("../../testdata/test-stub.exe" )
123122 if err != nil {
124123 t .Fatal ("could not read test-stub.exe" , err )
125124 }
@@ -278,7 +277,7 @@ func TestRedirectFull(t *testing.T) {
278277 req .Header .Set ("Referer" , params .Referer )
279278 svc .ServeHTTP (recorder , req )
280279
281- location := recorder .HeaderMap .Get ("Location" )
280+ location := recorder .Result (). Header .Get ("Location" )
282281 if location == "" {
283282 t .Fatal ("Location is not set" )
284283 }
@@ -295,7 +294,7 @@ func TestRedirectFull(t *testing.T) {
295294 t .Fatalf ("request was not 200 res: %d" , resp .StatusCode )
296295 }
297296
298- bodyBytes , err := ioutil .ReadAll (resp .Body )
297+ bodyBytes , err := io .ReadAll (resp .Body )
299298 if err != nil {
300299 t .Fatal ("could not read body" , err )
301300 }
@@ -364,7 +363,7 @@ func TestRedirectFull(t *testing.T) {
364363}
365364
366365func TestDirectFull (t * testing.T ) {
367- testFileBytes , err := ioutil .ReadFile ("../../testdata/test-stub.exe" )
366+ testFileBytes , err := os .ReadFile ("../../testdata/test-stub.exe" )
368367 if err != nil {
369368 t .Fatal ("could not read test-stub.exe" , err )
370369 }
@@ -431,7 +430,7 @@ func TestDirectFull(t *testing.T) {
431430 t .Fatalf ("request was not 200 res: %d" , recorder .Code )
432431 }
433432
434- bodyBytes , err := ioutil .ReadAll (recorder .Body )
433+ bodyBytes , err := io .ReadAll (recorder .Body )
435434 if err != nil {
436435 t .Fatal ("could not read body" , err )
437436 }
@@ -529,7 +528,7 @@ func TestStubServiceErrorCases(t *testing.T) {
529528 t .Run ("no attribution_code" , func (t * testing.T ) {
530529 recorder := fetchURL (`http://test/?product=firefox-stub&os=win&lang=en-US` )
531530 code := recorder .Code
532- location := recorder .HeaderMap .Get ("Location" )
531+ location := recorder .Result (). Header .Get ("Location" )
533532 if code != 302 || location != "https://download.mozilla.org/?lang=en-US&os=win&product=firefox-stub" {
534533 t .Errorf ("service did not return bouncer redirect status: %d loc: %s" , code , location )
535534 }
@@ -538,7 +537,7 @@ func TestStubServiceErrorCases(t *testing.T) {
538537 t .Run ("invalid attribution_code" , func (t * testing.T ) {
539538 recorder := fetchURL (`http://test/?product=firefox-stub&os=win&lang=en-US&attribution_code=invalidcode` )
540539 code := recorder .Code
541- location := recorder .HeaderMap .Get ("Location" )
540+ location := recorder .Result (). Header .Get ("Location" )
542541 if code != 302 || location != "https://download.mozilla.org/?lang=en-US&os=win&product=firefox-stub" {
543542 t .Errorf ("service did not return bouncer redirect status: %d loc: %s" , code , location )
544543 }
@@ -559,7 +558,7 @@ func TestStubServiceErrorCases(t *testing.T) {
559558 url .QueryEscape (base64Code ),
560559 ))
561560 code := recorder .Code
562- location := recorder .HeaderMap .Get ("Location" )
561+ location := recorder .Result (). Header .Get ("Location" )
563562
564563 if code != 302 || location != expectedLocation {
565564 t .Errorf ("service did not return bouncer redirect status: %d loc: %s (os=%s)" , code , location , params .OS )
0 commit comments