@@ -332,10 +332,22 @@ func TestDirectFull(t *testing.T) {
332332 for _ , params := range []struct {
333333 AttributionCode string
334334 ExpectedCode string
335+ OS string
335336 }{
336337 {
337338 AttributionCode : `campaign=%28not+set%29&content=%28not+set%29&medium=organic&source=www.google.com` ,
338339 ExpectedCode : `campaign%3D%2528not%2Bset%2529%26content%3D%2528not%2Bset%2529%26dltoken%3D[\w\d-]+%26medium%3Dorganic%26source%3Dwww.google.com` ,
340+ OS : "win" ,
341+ },
342+ {
343+ AttributionCode : `campaign=%28not+set%29&content=%28not+set%29&medium=organic&source=www.google.com` ,
344+ ExpectedCode : `campaign%3D%2528not%2Bset%2529%26content%3D%2528not%2Bset%2529%26dltoken%3D[\w\d-]+%26medium%3Dorganic%26source%3Dwww.google.com` ,
345+ OS : "win64" ,
346+ },
347+ {
348+ AttributionCode : `campaign=%28not+set%29&content=%28not+set%29&medium=organic&source=www.google.com` ,
349+ ExpectedCode : `campaign%3D%2528not%2Bset%2529%26content%3D%2528not%2Bset%2529%26dltoken%3D[\w\d-]+%26medium%3Dorganic%26source%3Dwww.google.com` ,
350+ OS : "win64-aarch64" ,
339351 },
340352 } {
341353 testHook .Reset ()
@@ -346,7 +358,11 @@ func TestDirectFull(t *testing.T) {
346358 base64Code := base64 .URLEncoding .WithPadding ('.' ).EncodeToString ([]byte (params .AttributionCode ))
347359 req := httptest .NewRequest (
348360 "GET" ,
349- `http://test/?product=firefox-stub&os=win&lang=en-US&attribution_code=` + url .QueryEscape (base64Code ),
361+ fmt .Sprintf (
362+ "http://test/?product=firefox-stub&os=%s&lang=en-US&attribution_code=%s" ,
363+ params .OS ,
364+ url .QueryEscape (base64Code ),
365+ ),
350366 nil ,
351367 )
352368 svc .ServeHTTP (recorder , req )
@@ -467,4 +483,27 @@ func TestStubServiceErrorCases(t *testing.T) {
467483 t .Errorf ("service did not return bouncer redirect status: %d loc: %s" , code , location )
468484 }
469485 })
486+
487+ t .Run ("unsupported OS" , func (t * testing.T ) {
488+ base64Code := base64 .URLEncoding .WithPadding ('.' ).EncodeToString ([]byte ("campaign=test" ))
489+
490+ for _ , params := range []struct { OS string }{
491+ {OS : "linux" },
492+ {OS : "linux64" },
493+ } {
494+ expectedLocation := fmt .Sprintf ("https://download.mozilla.org/?lang=en-US&os=%s&product=firefox-latest-ssl" , params .OS )
495+
496+ recorder := fetchURL (fmt .Sprintf (
497+ "http://test/?product=firefox-latest-ssl&os=%s&lang=en-US&attribution_code=%s" ,
498+ params .OS ,
499+ url .QueryEscape (base64Code ),
500+ ))
501+ code := recorder .Code
502+ location := recorder .HeaderMap .Get ("Location" )
503+
504+ if code != 302 || location != expectedLocation {
505+ t .Errorf ("service did not return bouncer redirect status: %d loc: %s (os=%s)" , code , location , params .OS )
506+ }
507+ }
508+ })
470509}
0 commit comments