From 5e34d17ebb2060adcd176850f01f6937f4e39f92 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Thu, 17 Jun 2021 17:01:20 +0200 Subject: [PATCH 01/14] Smaato: Send multiple requests --- adapters/smaato/image.go | 40 +- adapters/smaato/image_test.go | 56 +-- adapters/smaato/richmedia.go | 35 +- adapters/smaato/richmedia_test.go | 52 ++- adapters/smaato/smaato.go | 352 ++++++++++-------- .../exemplary/multiple-impressions.json | 352 ++++++++++++++++++ .../supplemental/bad-adm-response.json | 3 +- .../smaatotest/supplemental/bad-ext-req.json | 54 --- .../bad-imp-banner-format-req.json | 61 --- .../bad-imp-banner-format-request.json | 28 ++ .../supplemental/bad-imp-ext-request.json | 29 ++ .../supplemental/bad-site-ext-request.json | 34 ++ ...400.json => bad-status-code-response.json} | 2 +- ...eq.json => bad-user-ext-data-request.json} | 16 +- ...ext-req.json => bad-user-ext-request.json} | 23 +- .../supplemental/no-app-site-request.json | 30 ++ ...tus-code-204.json => no-bid-response.json} | 4 +- ...info.json => no-consent-info-request.json} | 0 .../{no-imp-req.json => no-imp-request.json} | 7 +- 19 files changed, 778 insertions(+), 400 deletions(-) create mode 100644 adapters/smaato/smaatotest/exemplary/multiple-impressions.json delete mode 100644 adapters/smaato/smaatotest/supplemental/bad-ext-req.json delete mode 100644 adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json create mode 100644 adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-request.json create mode 100644 adapters/smaato/smaatotest/supplemental/bad-imp-ext-request.json create mode 100644 adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json rename adapters/smaato/smaatotest/supplemental/{status-code-400.json => bad-status-code-response.json} (99%) rename adapters/smaato/smaatotest/supplemental/{bad-user-ext-data-req.json => bad-user-ext-data-request.json} (79%) rename adapters/smaato/smaatotest/supplemental/{bad-user-ext-req.json => bad-user-ext-request.json} (62%) create mode 100644 adapters/smaato/smaatotest/supplemental/no-app-site-request.json rename adapters/smaato/smaatotest/supplemental/{status-code-204.json => no-bid-response.json} (97%) rename adapters/smaato/smaatotest/supplemental/{no-consent-info.json => no-consent-info-request.json} (100%) rename adapters/smaato/smaatotest/supplemental/{no-imp-req.json => no-imp-request.json} (59%) diff --git a/adapters/smaato/image.go b/adapters/smaato/image.go index 582206ccb0c..6efb513473f 100644 --- a/adapters/smaato/image.go +++ b/adapters/smaato/image.go @@ -22,32 +22,24 @@ type img struct { Ctaurl string `json:"ctaurl"` } -func extractAdmImage(adapterResponseAdm string) (string, error) { - var imgMarkup string - var err error - +func extractAdmImage(adMarkup string) (string, error) { var imageAd imageAd - err = json.Unmarshal([]byte(adapterResponseAdm), &imageAd) - var image = imageAd.Image - - if err == nil { - var clickEvent strings.Builder - var impressionTracker strings.Builder - - for _, clicktracker := range image.Clicktrackers { - clickEvent.WriteString("fetch(decodeURIComponent('" + url.QueryEscape(clicktracker) + "'.replace(/\\+/g, ' ')), " + - "{cache: 'no-cache'});") - } - - for _, impression := range image.Impressiontrackers { + if err := json.Unmarshal([]byte(adMarkup), &imageAd); err != nil { + return "", err + } - impressionTracker.WriteString(fmt.Sprintf(``, impression)) - } + var clickEvent strings.Builder + for _, clicktracker := range imageAd.Image.Clicktrackers { + clickEvent.WriteString("fetch(decodeURIComponent('" + url.QueryEscape(clicktracker) + "'.replace(/\\+/g, ' ')), " + + "{cache: 'no-cache'});") + } - imgMarkup = fmt.Sprintf(`
%s
`, - &clickEvent, url.QueryEscape(image.Img.Ctaurl), image. - Img.URL, image.Img.W, image.Img. - H, &impressionTracker) + var impressionTracker strings.Builder + for _, impression := range imageAd.Image.Impressiontrackers { + impressionTracker.WriteString(fmt.Sprintf(``, impression)) } - return imgMarkup, err + + return fmt.Sprintf(`
`+ + `%s`+ + `
`, &clickEvent, url.QueryEscape(imageAd.Image.Img.Ctaurl), imageAd.Image.Img.URL, imageAd.Image.Img.W, imageAd.Image.Img.H, &impressionTracker), nil } diff --git a/adapters/smaato/image_test.go b/adapters/smaato/image_test.go index 5f39c857201..aa9e7abf80f 100644 --- a/adapters/smaato/image_test.go +++ b/adapters/smaato/image_test.go @@ -4,40 +4,52 @@ import ( "testing" ) -func TestRenderAdMarkup(t *testing.T) { +func TestExtractAdmImage(t *testing.T) { type args struct { - adType adMarkupType - adapterResponseAdm string + adMarkup string } - expectedResult := `
` + - `` + - `` + - `
` - tests := []struct { - testName string - args args - result string + testName string + args args + expectedAdMarkup string + expectedError string }{ - {"imageTest", args{"Img", - "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\"," + + {"extract image", + args{"{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\"," + "\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"}," + "\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"]," + "\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}"}, - expectedResult, + `
` + + `` + + `` + + `
`, + "", + }, + {"invalid adMarkup", + args{"{"}, + "", + "unexpected end of JSON input", }, } + for _, tt := range tests { t.Run(tt.testName, func(t *testing.T) { - got, err := renderAdMarkup(tt.args.adType, tt.args.adapterResponseAdm) - if err != nil { - t.Errorf("error rendering ad markup: %v", err) + adMarkup, err := extractAdmImage(tt.args.adMarkup) + if tt.expectedError != "" { + if err == nil { + t.Errorf("extractAdmImage() expectedError %v", tt.expectedError) + } else if err.Error() != tt.expectedError { + t.Errorf("extractAdmImage() err = %v, expectedError %v", err, tt.expectedError) + } + } else if err != nil { + t.Errorf("extractAdmImage() unexpected err = %v", err) } - if got != tt.result { - t.Errorf("renderAdMarkup() got = %v, result %v", got, tt.result) + + if adMarkup != tt.expectedAdMarkup { + t.Errorf("extractAdmImage() adMarkup = %v, expectedAdMarkup %v", adMarkup, tt.expectedAdMarkup) } }) } diff --git a/adapters/smaato/richmedia.go b/adapters/smaato/richmedia.go index 1c94a3555c1..2c350a6b5db 100644 --- a/adapters/smaato/richmedia.go +++ b/adapters/smaato/richmedia.go @@ -23,30 +23,21 @@ type richmedia struct { } func extractAdmRichMedia(adapterResponseAdm string) (string, error) { - var richMediaMarkup string - var err error - var richMediaAd richMediaAd - err = json.Unmarshal([]byte(adapterResponseAdm), &richMediaAd) - var richMedia = richMediaAd.RichMedia - - if err == nil { - var clickEvent strings.Builder - var impressionTracker strings.Builder - - for _, clicktracker := range richMedia.Clicktrackers { - clickEvent.WriteString("fetch(decodeURIComponent('" + url.QueryEscape(clicktracker) + "'), " + - "{cache: 'no-cache'});") - } - for _, impression := range richMedia.Impressiontrackers { + if err := json.Unmarshal([]byte(adapterResponseAdm), &richMediaAd); err != nil { + return "", err + } - impressionTracker.WriteString(fmt.Sprintf(``, impression)) - } + var clickEvent strings.Builder + var impressionTracker strings.Builder - richMediaMarkup = fmt.Sprintf(`
%s%s
`, - &clickEvent, - richMedia.MediaData.Content, - &impressionTracker) + for _, clicktracker := range richMediaAd.RichMedia.Clicktrackers { + clickEvent.WriteString("fetch(decodeURIComponent('" + url.QueryEscape(clicktracker) + "'), " + + "{cache: 'no-cache'});") + } + for _, impression := range richMediaAd.RichMedia.Impressiontrackers { + impressionTracker.WriteString(fmt.Sprintf(``, impression)) } - return richMediaMarkup, err + + return fmt.Sprintf(`
%s%s
`, &clickEvent, richMediaAd.RichMedia.MediaData.Content, &impressionTracker), nil } diff --git a/adapters/smaato/richmedia_test.go b/adapters/smaato/richmedia_test.go index 20fa1ba353c..d597c16dcf4 100644 --- a/adapters/smaato/richmedia_test.go +++ b/adapters/smaato/richmedia_test.go @@ -6,33 +6,47 @@ import ( func TestExtractAdmRichMedia(t *testing.T) { type args struct { - adType adMarkupType - adapterResponseAdm string + adMarkup string } - expectedResult := `
hello
` + - `
` tests := []struct { - testName string - args args - result string + testName string + args args + expectedAdMarkup string + expectedError string }{ - {"richmediaTest", args{"Richmedia", "{\"richmedia\":{\"mediadata\":{\"content\":\"
hello
\"," + - "" + "\"w\":350," + - "\"h\":50},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"]," + - "\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}"}, - expectedResult, + {"extract richmedia", + args{"{\"richmedia\":{\"mediadata\":{\"content\":\"
hello
\"," + + "" + "\"w\":350," + + "\"h\":50},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"]," + + "\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}"}, + `
hello
` + + `
`, + "", + }, + {"invalid adMarkup", + args{"{"}, + "", + "unexpected end of JSON input", }, } + for _, tt := range tests { t.Run(tt.testName, func(t *testing.T) { - got, err := renderAdMarkup(tt.args.adType, tt.args.adapterResponseAdm) - if err != nil { - t.Errorf("error rendering ad markup: %v", err) + adMarkup, err := extractAdmRichMedia(tt.args.adMarkup) + if tt.expectedError != "" { + if err == nil { + t.Errorf("extractAdmRichMedia() expectedError %v", tt.expectedError) + } else if err.Error() != tt.expectedError { + t.Errorf("extractAdmRichMedia() err = %v, expectedError %v", err, tt.expectedError) + } + } else if err != nil { + t.Errorf("extractAdmRichMedia() unexpected err = %v", err) } - if got != tt.result { - t.Errorf("renderAdMarkup() got = %v, result %v", got, tt.result) + + if adMarkup != tt.expectedAdMarkup { + t.Errorf("extractAdmRichMedia() adMarkup = %v, expectedAdMarkup %v", adMarkup, tt.expectedAdMarkup) } }) } diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 9aea2e1e614..0c09b6658e8 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -26,7 +26,7 @@ const ( // SmaatoAdapter describes a Smaato prebid server adapter. type SmaatoAdapter struct { - URI string + endpoint string } //userExt defines User.Ext object for Smaato @@ -49,117 +49,65 @@ type siteExtData struct { Keywords string `json:"keywords"` } +// Setting ext client info +type bidRequestExt struct { + Client string `json:"client"` +} + // Builder builds a new instance of the Smaato adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &SmaatoAdapter{ - URI: config.Endpoint, + endpoint: config.Endpoint, } return bidder, nil } // MakeRequests makes the HTTP requests which should be made to fetch bids. func (a *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - errs := make([]error, 0, len(request.Imp)) - if len(request.Imp) == 0 { - errs = append(errs, &errortypes.BadInput{Message: "no impressions in bid request"}) - return nil, errs - } - - // Use bidRequestExt of first imp to retrieve params which are valid for all imps, e.g. publisherId - publisherID, err := jsonparser.GetString(request.Imp[0].Ext, "bidder", "publisherId") - if err != nil { - errs = append(errs, err) - return nil, errs - } - - for i := 0; i < len(request.Imp); i++ { - err := parseImpressionObject(&request.Imp[i]) - // If the parsing is failed, remove imp and add the error. - if err != nil { - errs = append(errs, err) - request.Imp = append(request.Imp[:i], request.Imp[i+1:]...) - i-- - } - } + impressionCount := len(request.Imp) + errors := make([]error, 0, impressionCount) - if request.Site != nil { - siteCopy := *request.Site - siteCopy.Publisher = &openrtb2.Publisher{ID: publisherID} - - if request.Site.Ext != nil { - var siteExt siteExt - err := json.Unmarshal([]byte(request.Site.Ext), &siteExt) - if err != nil { - errs = append(errs, err) - return nil, errs - } - siteCopy.Keywords = siteExt.Data.Keywords - siteCopy.Ext = nil - } - request.Site = &siteCopy + if impressionCount == 0 { + errors = append(errors, &errortypes.BadInput{Message: "No impressions in bid request."}) + return nil, errors } - if request.App != nil { - appCopy := *request.App - appCopy.Publisher = &openrtb2.Publisher{ID: publisherID} - - request.App = &appCopy + // set data in request that is common for all requests + if err := prepareCommonRequest(request); err != nil { + errors = append(errors, err) + return nil, errors } - if request.User != nil && request.User.Ext != nil { - var userExt userExt - var userExtRaw map[string]json.RawMessage + requests := make([]*adapters.RequestData, 0, impressionCount) - rawExtErr := json.Unmarshal(request.User.Ext, &userExtRaw) - if rawExtErr != nil { - errs = append(errs, rawExtErr) - return nil, errs - } + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") - userExtErr := json.Unmarshal([]byte(request.User.Ext), &userExt) - if userExtErr != nil { - errs = append(errs, userExtErr) - return nil, errs + imps := request.Imp + for impIndex := range imps { + // set data in request that is individual per impression + request.Imp = imps[impIndex : impIndex+1] + if err := prepareIndividualRequest(request); err != nil { + errors = append(errors, err) + continue } - userCopy := *request.User - extractUserExtAttributes(userExt, &userCopy) - delete(userExtRaw, "data") - userCopy.Ext, err = json.Marshal(userExtRaw) + reqJSON, err := json.Marshal(request) if err != nil { - errs = append(errs, err) - return nil, errs + errors = append(errors, err) + continue } - request.User = &userCopy - } - // Setting ext client info - type bidRequestExt struct { - Client string `json:"client"` + requests = append(requests, &adapters.RequestData{ + Method: "POST", + Uri: a.endpoint, + Body: reqJSON, + Headers: headers, + }) } - request.Ext, err = json.Marshal(bidRequestExt{Client: clientVersion}) - if err != nil { - errs = append(errs, err) - return nil, errs - } - reqJSON, err := json.Marshal(request) - if err != nil { - errs = append(errs, err) - return nil, errs - } - - uri := a.URI - - headers := http.Header{} - headers.Add("Content-Type", "application/json;charset=utf-8") - headers.Add("Accept", "application/json") - return []*adapters.RequestData{{ - Method: "POST", - Uri: uri, - Body: reqJSON, - Headers: headers, - }}, errs + return requests, errors } // MakeBids unpacks the server's response into Bids. @@ -168,14 +116,10 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR return nil, nil } - if response.StatusCode == http.StatusBadRequest { - return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), - }} - } - if response.StatusCode != http.StatusOK { - return nil, []error{fmt.Errorf("unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)} + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", response.StatusCode), + }} } var bidResp openrtb2.BidResponse @@ -189,20 +133,19 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR for i := 0; i < len(sb.Bid); i++ { bid := sb.Bid[i] - markupType, markupTypeErr := getAdMarkupType(response, bid.AdM) - if markupTypeErr != nil { - return nil, []error{markupTypeErr} + adMarkupType, err := getAdMarkupType(response, bid.AdM) + if err != nil { + return nil, []error{err} } - var markupError error - bid.AdM, markupError = renderAdMarkup(markupType, bid.AdM) - if markupError != nil { - return nil, []error{markupError} + bid.AdM, err = renderAdMarkup(adMarkupType, bid.AdM) + if err != nil { + return nil, []error{err} } - bidType, bidTypeErr := markupTypeToBidType(markupType) - if bidTypeErr != nil { - return nil, []error{bidTypeErr} + bidType, err := convertAdMarkupTypeToMediaType(adMarkupType) + if err != nil { + return nil, []error{err} } bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ @@ -214,24 +157,39 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR return bidResponse, nil } +func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkupType, error) { + if admType := adMarkupType(response.Headers.Get("X-SMT-ADTYPE")); admType != "" { + return admType, nil + } else if strings.HasPrefix(adMarkup, `{"image":`) { + return smtAdTypeImg, nil + } else if strings.HasPrefix(adMarkup, `{"richmedia":`) { + return smtAdTypeRichmedia, nil + } else if strings.HasPrefix(adMarkup, `", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6524", + "crid": "CR69382", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "postbid_iframe", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + }, + "type": "banner" + } + ] + }, + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6524", + "crid": "CR69382", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "postbid_iframe", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768 + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-adm-response.json b/adapters/smaato/smaatotest/supplemental/bad-adm-response.json index db724565d52..8c6ad1b1ff0 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-adm-response.json +++ b/adapters/smaato/smaatotest/supplemental/bad-adm-response.json @@ -162,10 +162,9 @@ } } ], - "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "Invalid ad markup {\"badmedia\":{\"mediadata\":{\"content\":\"
hello
\", \"w\":350,\"h\":50},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "value": "Invalid ad markup {\"badmedia\":{\"mediadata\":{\"content\":\"
hello
\", \"w\":350,\"h\":50},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}.", "comparison": "literal" } ] diff --git a/adapters/smaato/smaatotest/supplemental/bad-ext-req.json b/adapters/smaato/smaatotest/supplemental/bad-ext-req.json deleted file mode 100644 index 0c970fc5bad..00000000000 --- a/adapters/smaato/smaatotest/supplemental/bad-ext-req.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "mockBidRequest": { - "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", - "site": { - "page": "prebid.org", - "publisher": { - "id": "1" - } - }, - "imp": [ - { - "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", - "banner": { - "format": [ - { - "w": 320, - "h": 50 - }, - { - "w": 320, - "h": 250 - } - ] - }, - "ext": { - } - } - ], - "device": { - "ua": "test-user-agent", - "ip": "123.123.123.123", - "language": "en", - "dnt": 0 - }, - "user": { - "ext": { - "consent": "gdprConsentString" - } - }, - "regs": { - "coppa": 1, - "ext": { - "gdpr": 1, - "us_privacy": "uspConsentString" - } - } - }, - "expectedMakeRequestsErrors": [ - { - "value": "Key path not found", - "comparison": "literal" - } - ] -} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json b/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json deleted file mode 100644 index 768b4ef9d2c..00000000000 --- a/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "mockBidRequest": { - "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", - "imp": [ - { - "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", - "banner": { - "format": [] - }, - "ext": { - "bidder": { - "publisherId": "1100042525", - "adspaceId": "130563103" - } - } - } - ], - "site": { - "page": "prebid.org", - "publisher": { - "id": "1" - } - } - }, - "httpCalls": [ - { - "expectedRequest": { - "headers": { - "Content-Type": ["application/json;charset=utf-8"], - "Accept": ["application/json"] - }, - "uri": "https://prebid/bidder", - "body": { - "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", - "imp": [], - "site": { - "page": "prebid.org", - "publisher": { - "id": "1100042525" - } - }, - "ext": { - "client": "prebid_server_0.2" - } - } - } - } - ], - "expectedMakeRequestsErrors": [ - { - "value": "No sizes provided for Banner []", - "comparison": "literal" - } - ], - "expectedMakeBidsErrors": [ - { - "value": "unexpected status code: 0. Run with request.debug = 1 for more info", - "comparison": "literal" - } - ] -} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-request.json b/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-request.json new file mode 100644 index 00000000000..0c3661bdf69 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-request.json @@ -0,0 +1,28 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder" + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "No sizes provided for Banner.", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-imp-ext-request.json b/adapters/smaato/smaatotest/supplemental/bad-imp-ext-request.json new file mode 100644 index 00000000000..61601910530 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/bad-imp-ext-request.json @@ -0,0 +1,29 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder" + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + } + ] + }, + "ext": { + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Key path not found", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json b/adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json new file mode 100644 index 00000000000..8045ccd22d2 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json @@ -0,0 +1,34 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "page": "prebid.org", + "ext": "" + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type smaato.siteExt", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/status-code-400.json b/adapters/smaato/smaatotest/supplemental/bad-status-code-response.json similarity index 99% rename from adapters/smaato/smaatotest/supplemental/status-code-400.json rename to adapters/smaato/smaatotest/supplemental/bad-status-code-response.json index fc84c93e269..90020a14455 100644 --- a/adapters/smaato/smaatotest/supplemental/status-code-400.json +++ b/adapters/smaato/smaatotest/supplemental/bad-status-code-response.json @@ -137,7 +137,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info.", "comparison": "literal" } ] diff --git a/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-req.json b/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-request.json similarity index 79% rename from adapters/smaato/smaatotest/supplemental/bad-user-ext-data-req.json rename to adapters/smaato/smaatotest/supplemental/bad-user-ext-data-request.json index 9e65fce1c3e..dce69556988 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-req.json +++ b/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-request.json @@ -2,10 +2,7 @@ "mockBidRequest": { "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", "site": { - "page": "prebid.org", - "publisher": { - "id": "1" - } + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder" }, "imp": [ { @@ -37,17 +34,10 @@ "dnt": 0 }, "user": { - "gender": "M", "ext": { "data": { - "keywords":"a,b", - "gender": "M", - "yob": "", - "geo": { - "country": "ca" - } - }, - "consent":"yes" + "yob": "" + } } }, "regs": { diff --git a/adapters/smaato/smaatotest/supplemental/bad-user-ext-req.json b/adapters/smaato/smaatotest/supplemental/bad-user-ext-request.json similarity index 62% rename from adapters/smaato/smaatotest/supplemental/bad-user-ext-req.json rename to adapters/smaato/smaatotest/supplemental/bad-user-ext-request.json index 7f05b2dff14..f8ec41e22ed 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-user-ext-req.json +++ b/adapters/smaato/smaatotest/supplemental/bad-user-ext-request.json @@ -2,10 +2,7 @@ "mockBidRequest": { "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", "site": { - "page": "prebid.org", - "publisher": { - "id": "1" - } + "page": "prebid.org" }, "imp": [ { @@ -15,10 +12,6 @@ { "w": 320, "h": 50 - }, - { - "w": 320, - "h": 250 } ] }, @@ -30,22 +23,8 @@ } } ], - "device": { - "ua": "test-user-agent", - "ip": "123.123.123.123", - "language": "en", - "dnt": 0 - }, "user": { - "gender": "M", "ext": 99 - }, - "regs": { - "coppa": 1, - "ext": { - "gdpr": 1, - "us_privacy": "uspConsentString" - } } }, "expectedMakeRequestsErrors": [ diff --git a/adapters/smaato/smaatotest/supplemental/no-app-site-request.json b/adapters/smaato/smaatotest/supplemental/no-app-site-request.json new file mode 100644 index 00000000000..04a73b4f40d --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/no-app-site-request.json @@ -0,0 +1,30 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Missing Site/App.", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/status-code-204.json b/adapters/smaato/smaatotest/supplemental/no-bid-response.json similarity index 97% rename from adapters/smaato/smaatotest/supplemental/status-code-204.json rename to adapters/smaato/smaatotest/supplemental/no-bid-response.json index b409597f986..bcc16415d4c 100644 --- a/adapters/smaato/smaatotest/supplemental/status-code-204.json +++ b/adapters/smaato/smaatotest/supplemental/no-bid-response.json @@ -133,7 +133,5 @@ "status": 204 } } - ], - "expectedBidResponses": [], - "expectedMakeBidsErrors": [] + ] } \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/no-consent-info.json b/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json similarity index 100% rename from adapters/smaato/smaatotest/supplemental/no-consent-info.json rename to adapters/smaato/smaatotest/supplemental/no-consent-info-request.json diff --git a/adapters/smaato/smaatotest/supplemental/no-imp-req.json b/adapters/smaato/smaatotest/supplemental/no-imp-request.json similarity index 59% rename from adapters/smaato/smaatotest/supplemental/no-imp-req.json rename to adapters/smaato/smaatotest/supplemental/no-imp-request.json index bfaf51e6ea8..eab4f2a0697 100644 --- a/adapters/smaato/smaatotest/supplemental/no-imp-req.json +++ b/adapters/smaato/smaatotest/supplemental/no-imp-request.json @@ -2,15 +2,12 @@ "mockBidRequest": { "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", "site": { - "page": "prebid.org", - "publisher": { - "id": "1" - } + "page": "prebid.org" } }, "expectedMakeRequestsErrors": [ { - "value": "no impressions in bid request", + "value": "No impressions in bid request.", "comparison": "literal" } ] From 47dab764301a9fb5c0e7398ff723a1ee7a90f4b8 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Mon, 21 Jun 2021 17:14:11 +0200 Subject: [PATCH 02/14] Smaato: Add AdPods --- adapters/smaato/params_test.go | 2 + adapters/smaato/smaato.go | 251 ++++++-- adapters/smaato/smaato_test.go | 76 +++ .../smaatotest/params/{ => race}/banner.json | 0 .../smaato/smaatotest/params/race/video.json | 4 + .../supplemental/bad-media-type-request.json | 27 + .../smaatotest/video/multiple-adpods.json | 539 ++++++++++++++++++ .../smaato/smaatotest/video/single-adpod.json | 285 +++++++++ .../bad-adbreak-id-request.json | 90 +++ .../videosupplemental/bad-adm-response.json | 269 +++++++++ .../bad-bid-ext-response.json | 267 +++++++++ .../bad-media-type-request.json | 37 ++ .../bad-publisher-id-request.json | 90 +++ openrtb_ext/imp_smaato.go | 5 +- static/bidder-params/smaato.json | 20 +- 15 files changed, 1905 insertions(+), 57 deletions(-) rename adapters/smaato/smaatotest/params/{ => race}/banner.json (100%) create mode 100644 adapters/smaato/smaatotest/params/race/video.json create mode 100644 adapters/smaato/smaatotest/supplemental/bad-media-type-request.json create mode 100644 adapters/smaato/smaatotest/video/multiple-adpods.json create mode 100644 adapters/smaato/smaatotest/video/single-adpod.json create mode 100644 adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json create mode 100644 adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json create mode 100644 adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json create mode 100644 adapters/smaato/smaatotest/videosupplemental/bad-media-type-request.json create mode 100644 adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json diff --git a/adapters/smaato/params_test.go b/adapters/smaato/params_test.go index 6c71cbe75c6..2e29550a394 100644 --- a/adapters/smaato/params_test.go +++ b/adapters/smaato/params_test.go @@ -41,6 +41,8 @@ func TestInvalidParams(t *testing.T) { var validParams = []string{ `{"publisherId":"test-id-1234-smaato","adspaceId": "1123581321"}`, + `{"publisherId":"test-id-1234-smaato","adbreakId": "4123581321"}`, + `{"publisherId":"test-id-1234-smaato","adspaceId": "1123581321","adbreakId": "4123581321"}`, } var invalidParams = []string{ diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 0c09b6658e8..e75cefcc855 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -3,6 +3,7 @@ package smaato import ( "encoding/json" "fmt" + "github.com/prebid/prebid-server/metrics" "net/http" "strings" @@ -29,7 +30,7 @@ type SmaatoAdapter struct { endpoint string } -//userExt defines User.Ext object for Smaato +// userExt defines User.Ext object for Smaato type userExt struct { Data userExtData `json:"data"` } @@ -40,7 +41,7 @@ type userExtData struct { Yob int64 `json:"yob"` } -//userExt defines Site.Ext object for Smaato +// siteExt defines Site.Ext object for Smaato type siteExt struct { Data siteExtData `json:"data"` } @@ -49,11 +50,16 @@ type siteExtData struct { Keywords string `json:"keywords"` } -// Setting ext client info +// bidRequestExt defines BidRequest.Ext object for Smaato type bidRequestExt struct { Client string `json:"client"` } +// bidExt defines Bid.Ext object for Smaato +type bidExt struct { + Duration int `json:"duration"` +} + // Builder builds a new instance of the Smaato adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &SmaatoAdapter{ @@ -64,50 +70,22 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters // MakeRequests makes the HTTP requests which should be made to fetch bids. func (a *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - impressionCount := len(request.Imp) - errors := make([]error, 0, impressionCount) - - if impressionCount == 0 { - errors = append(errors, &errortypes.BadInput{Message: "No impressions in bid request."}) - return nil, errors + if len(request.Imp) == 0 { + return nil, []error{&errortypes.BadInput{Message: "No impressions in bid request."}} } // set data in request that is common for all requests if err := prepareCommonRequest(request); err != nil { - errors = append(errors, err) - return nil, errors + return nil, []error{err} } - requests := make([]*adapters.RequestData, 0, impressionCount) - - headers := http.Header{} - headers.Add("Content-Type", "application/json;charset=utf-8") - headers.Add("Accept", "application/json") - - imps := request.Imp - for impIndex := range imps { - // set data in request that is individual per impression - request.Imp = imps[impIndex : impIndex+1] - if err := prepareIndividualRequest(request); err != nil { - errors = append(errors, err) - continue - } - - reqJSON, err := json.Marshal(request) - if err != nil { - errors = append(errors, err) - continue - } + isVideoEntryPoint := reqInfo.PbsEntryPoint == metrics.ReqTypeVideo - requests = append(requests, &adapters.RequestData{ - Method: "POST", - Uri: a.endpoint, - Body: reqJSON, - Headers: headers, - }) + if isVideoEntryPoint { + return a.makePodRequests(request) + } else { + return a.makeIndividualRequests(request) } - - return requests, errors } // MakeBids unpacks the server's response into Bids. @@ -129,32 +107,117 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR bidResponse := adapters.NewBidderResponseWithBidsCapacity(5) - for _, sb := range bidResp.SeatBid { - for i := 0; i < len(sb.Bid); i++ { - bid := sb.Bid[i] + var errors []error + for _, seatBid := range bidResp.SeatBid { + for i := 0; i < len(seatBid.Bid); i++ { + bid := seatBid.Bid[i] adMarkupType, err := getAdMarkupType(response, bid.AdM) if err != nil { - return nil, []error{err} + errors = append(errors, err) + continue } bid.AdM, err = renderAdMarkup(adMarkupType, bid.AdM) if err != nil { - return nil, []error{err} + errors = append(errors, err) + continue } bidType, err := convertAdMarkupTypeToMediaType(adMarkupType) if err != nil { - return nil, []error{err} + errors = append(errors, err) + continue + } + + bidVideo, err := buildBidVideo(&bid, bidType) + if err != nil { + errors = append(errors, err) + continue } bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &bid, - BidType: bidType, + Bid: &bid, + BidType: bidType, + BidVideo: bidVideo, }) } } - return bidResponse, nil + return bidResponse, errors +} + +func (a *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { + imps := request.Imp + + requests := make([]*adapters.RequestData, 0, len(imps)) + errors := make([]error, 0, len(imps)) + + for impIndex := range imps { + request.Imp = imps[impIndex : impIndex+1] + if err := prepareIndividualRequest(request); err != nil { + errors = append(errors, err) + continue + } + + requestData, err := a.makeRequest(request) + if err != nil { + errors = append(errors, err) + continue + } + + requests = append(requests, requestData) + } + + return requests, errors +} + +func (a *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { + pods, orderedKeys := groupImpressionsByPod(request.Imp) + requests := make([]*adapters.RequestData, 0, len(pods)) + errors := make([]error, 0, len(request.Imp)) + + for _, key := range orderedKeys { + var adPodImpErrors []error + request.Imp, adPodImpErrors = filterPodImpressions(pods[key]) + if adPodImpErrors != nil { + errors = append(errors, adPodImpErrors...) + } + + if len(request.Imp) > 0 { + if err := preparePodRequest(request); err != nil { + errors = append(errors, err) + continue + } + + requestData, err := a.makeRequest(request) + if err != nil { + errors = append(errors, err) + continue + } + + requests = append(requests, requestData) + } + } + + return requests, errors +} + +func (a *SmaatoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { + reqJSON, err := json.Marshal(request) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + + return &adapters.RequestData{ + Method: "POST", + Uri: a.endpoint, + Body: reqJSON, + Headers: headers, + }, nil } func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkupType, error) { @@ -212,9 +275,7 @@ func prepareCommonRequest(request *openrtb2.BidRequest) error { return err } - if err := setApp(request); err != nil { - return err - } + setApp(request) return setExt(request) } @@ -226,7 +287,16 @@ func prepareIndividualRequest(request *openrtb2.BidRequest) error { return err } - return setImp(imp) + return setImpForAdspace(imp) +} + +func preparePodRequest(request *openrtb2.BidRequest) error { + if err := setPublisherId(request, &request.Imp[0]); err != nil { + return err + } + + err := setImpForAdBreak(request.Imp) + return err } func setUser(request *openrtb2.BidRequest) error { @@ -299,12 +369,11 @@ func setSite(request *openrtb2.BidRequest) error { return nil } -func setApp(request *openrtb2.BidRequest) error { +func setApp(request *openrtb2.BidRequest) { if request.App != nil { appCopy := *request.App request.App = &appCopy } - return nil } func setPublisherId(request *openrtb2.BidRequest, imp *openrtb2.Imp) error { @@ -326,7 +395,7 @@ func setPublisherId(request *openrtb2.BidRequest, imp *openrtb2.Imp) error { } } -func setImp(imp *openrtb2.Imp) error { +func setImpForAdspace(imp *openrtb2.Imp) error { adSpaceID, err := jsonparser.GetString(imp.Ext, "bidder", "adspaceId") if err != nil { return err @@ -352,6 +421,24 @@ func setImp(imp *openrtb2.Imp) error { return &errortypes.BadInput{Message: "Invalid MediaType. Smaato only supports Banner and Video."} } +func setImpForAdBreak(imps []openrtb2.Imp) error { + adBreakID, err := jsonparser.GetString(imps[0].Ext, "bidder", "adbreakId") + if err != nil { + return err + } + + for i := range imps { + imps[i].TagID = adBreakID + imps[i].Ext = nil + + videoCopy := *(imps[i].Video) + videoCopy.Sequence = int8(i + 1) + imps[i].Video = &videoCopy + } + + return nil +} + func setBannerDimension(banner *openrtb2.Banner) (*openrtb2.Banner, error) { if banner.W != nil && banner.H != nil { return banner, nil @@ -365,3 +452,57 @@ func setBannerDimension(banner *openrtb2.Banner) (*openrtb2.Banner, error) { return &bannerCopy, nil } + +func groupImpressionsByPod(imps []openrtb2.Imp) (map[string]([]openrtb2.Imp), []string) { + pods := make(map[string][]openrtb2.Imp) + orderKeys := make([]string, 0) + + for _, imp := range imps { + pod := strings.Split(imp.ID, "_")[0] + _, present := pods[pod] + pods[pod] = append(pods[pod], imp) + if !present { + orderKeys = append(orderKeys, pod) + } + } + return pods, orderKeys +} + +func filterPodImpressions(imps []openrtb2.Imp) ([]openrtb2.Imp, []error) { + var n int + errors := make([]error, 0, len(imps)) + for _, imp := range imps { + if imp.Video == nil { + errors = append(errors, &errortypes.BadInput{Message: "Invalid MediaType. Smaato only supports Video for AdPod."}) + continue + } + imps[n] = imp + n++ + } + return imps[:n], errors +} + +func buildBidVideo(bid *openrtb2.Bid, bidType openrtb_ext.BidType) (*openrtb_ext.ExtBidPrebidVideo, error) { + if bidType != openrtb_ext.BidTypeVideo { + return nil, nil + } + + if bid.Ext == nil { + return nil, nil + } + + var primaryCategory string + if len(bid.Cat) > 0 { + primaryCategory = bid.Cat[0] + } + + var bidExt bidExt + if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + return nil, err + } + + return &openrtb_ext.ExtBidPrebidVideo{ + Duration: bidExt.Duration, + PrimaryCategory: primaryCategory, + }, nil +} diff --git a/adapters/smaato/smaato_test.go b/adapters/smaato/smaato_test.go index c7c4a65017f..f0e95120d7a 100644 --- a/adapters/smaato/smaato_test.go +++ b/adapters/smaato/smaato_test.go @@ -1,6 +1,9 @@ package smaato import ( + "encoding/json" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" "testing" "github.com/prebid/prebid-server/adapters/adapterstest" @@ -18,3 +21,76 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "smaatotest", bidder) } + +func TestVideoWithCategoryAndDuration(t *testing.T) { + bidder := &SmaatoAdapter{} + + mockedReq := &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ + ID: "1_1", + Video: &openrtb2.Video{ + W: 640, + H: 360, + MIMEs: []string{"video/mp4"}, + MaxDuration: 60, + Protocols: []openrtb2.Protocol{2, 3, 5, 6}, + }, + Ext: json.RawMessage( + `{ + "bidder": { + "publisherId": "12345" + "adbreakId": "4123456" + } + }`, + )}, + }, + } + mockedExtReq := &adapters.RequestData{} + mockedBidResponse := &openrtb2.BidResponse{ + ID: "some-id", + SeatBid: []openrtb2.SeatBid{{ + Seat: "some-seat", + Bid: []openrtb2.Bid{{ + ID: "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + ImpID: "1_1", + Price: 0.01, + AdM: "", + Cat: []string{"IAB1"}, + Ext: json.RawMessage( + `{ + "duration": 5 + }`, + ), + }}, + }}, + } + body, _ := json.Marshal(mockedBidResponse) + mockedRes := &adapters.ResponseData{ + StatusCode: 200, + Body: body, + } + + expectedBidCount := 1 + expectedBidType := openrtb_ext.BidTypeVideo + expectedBidDuration := 5 + expectedBidCategory := "IAB1" + expectedErrorCount := 0 + + bidResponse, errors := bidder.MakeBids(mockedReq, mockedExtReq, mockedRes) + + if len(bidResponse.Bids) != expectedBidCount { + t.Errorf("should have 1 bid, bids=%v", bidResponse.Bids) + } + if bidResponse.Bids[0].BidType != expectedBidType { + t.Errorf("bid type should be video, bidType=%s", bidResponse.Bids[0].BidType) + } + if bidResponse.Bids[0].BidVideo.Duration != expectedBidDuration { + t.Errorf("video duration should be set") + } + if bidResponse.Bids[0].Bid.Cat[0] != expectedBidCategory { + t.Errorf("bid category should be set") + } + if len(errors) != expectedErrorCount { + t.Errorf("should not have any errors, errors=%v", errors) + } +} diff --git a/adapters/smaato/smaatotest/params/banner.json b/adapters/smaato/smaatotest/params/race/banner.json similarity index 100% rename from adapters/smaato/smaatotest/params/banner.json rename to adapters/smaato/smaatotest/params/race/banner.json diff --git a/adapters/smaato/smaatotest/params/race/video.json b/adapters/smaato/smaatotest/params/race/video.json new file mode 100644 index 00000000000..a84c44d4d8e --- /dev/null +++ b/adapters/smaato/smaatotest/params/race/video.json @@ -0,0 +1,4 @@ +{ + "publisherId": "1100042525", + "adspaceId": "130563103" +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-media-type-request.json b/adapters/smaato/smaatotest/supplemental/bad-media-type-request.json new file mode 100644 index 00000000000..2b59495c829 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/bad-media-type-request.json @@ -0,0 +1,27 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "native": { + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Invalid MediaType. Smaato only supports Banner and Video.", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/video/multiple-adpods.json b/adapters/smaato/smaatotest/video/multiple-adpods.json new file mode 100644 index 00000000000..7e8d03ab0b9 --- /dev/null +++ b/adapters/smaato/smaatotest/video/multiple-adpods.json @@ -0,0 +1,539 @@ +{ + "mockBidRequest": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + }, + { + "id": "1_2", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + }, + { + "id": "2_1", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + }, + { + "id": "2_2", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + } + ], + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "device": { + "ua": "test-user-agent" + }, + "user": { + "ext": { + "data": {} + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 1 + } + }, + { + "id": "1_2", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 2 + } + } + ], + "user": { + "ext": { + } + }, + "device": { + "ua": "test-user-agent" + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": { + "duration": 30 + } + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + }, + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "2_1", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 1 + } + }, + { + "id": "2_2", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 2 + } + } + ], + "user": { + "ext": { + } + }, + "device": { + "ua": "test-user-agent" + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "2_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "2_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": { + "duration": 30 + } + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + "type": "video" + + }, + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": { + "duration": 30 + } + }, + "type": "video" + } + ] + }, + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "2_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + "type": "video" + }, + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "2_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": { + "duration": 30 + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/video/single-adpod.json b/adapters/smaato/smaatotest/video/single-adpod.json new file mode 100644 index 00000000000..25aeb55e932 --- /dev/null +++ b/adapters/smaato/smaatotest/video/single-adpod.json @@ -0,0 +1,285 @@ +{ + "mockBidRequest": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + }, + { + "id": "1_2", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + } + ], + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "device": { + "ua": "test-user-agent" + }, + "user": { + "ext": { + "data": {} + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 1 + } + }, + { + "id": "1_2", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 2 + } + } + ], + "user": { + "ext": { + } + }, + "device": { + "ua": "test-user-agent" + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": { + "duration": 30 + } + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + "type": "video" + }, + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": { + "duration": 30 + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json b/adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json new file mode 100644 index 00000000000..300220a0afa --- /dev/null +++ b/adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json @@ -0,0 +1,90 @@ +{ + "mockBidRequest": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1234567" + } + } + }, + { + "id": "1_2", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1234567" + } + } + } + ], + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "device": { + "ua": "test-user-agent" + }, + "user": { + "ext": { + "data": {} + } + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "Key path not found", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json new file mode 100644 index 00000000000..6947a3ee50a --- /dev/null +++ b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json @@ -0,0 +1,269 @@ +{ + "mockBidRequest": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + }, + { + "id": "1_2", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + } + ], + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "device": { + "ua": "test-user-agent" + }, + "user": { + "ext": { + "data": {} + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 1 + } + }, + { + "id": "1_2", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 2 + } + } + ], + "user": { + "ext": { + } + }, + "device": { + "ua": "test-user-agent" + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": { + "duration": 30 + } + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Invalid ad markup .", + "comparison": "literal" + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json new file mode 100644 index 00000000000..37ae363537c --- /dev/null +++ b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json @@ -0,0 +1,267 @@ +{ + "mockBidRequest": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + }, + { + "id": "1_2", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + } + ], + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "device": { + "ua": "test-user-agent" + }, + "user": { + "ext": { + "data": {} + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 1 + } + }, + { + "id": "1_2", + "tagid": "400000001", + "video": { + "w": 1024, + "h": 768, + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ], + "sequence": 2 + } + } + ], + "user": { + "ext": { + } + }, + "device": { + "ua": "test-user-agent" + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_2", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB2"], + "ext": "" + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type smaato.bidExt", + "comparison": "literal" + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1_1", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768, + "cat": ["IAB1"], + "ext": { + "duration": 5 + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-media-type-request.json b/adapters/smaato/smaatotest/videosupplemental/bad-media-type-request.json new file mode 100644 index 00000000000..1c345de029d --- /dev/null +++ b/adapters/smaato/smaatotest/videosupplemental/bad-media-type-request.json @@ -0,0 +1,37 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "1_1", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adbreakId": "400000001" + } + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Invalid MediaType. Smaato only supports Video for AdPod.", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json b/adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json new file mode 100644 index 00000000000..2a40d82ad58 --- /dev/null +++ b/adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json @@ -0,0 +1,90 @@ +{ + "mockBidRequest": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "1_1", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "adbreakId": "400000001" + } + } + }, + { + "id": "1_2", + "video": { + "mimes": [ + "video/mp4", + "video/3gpp" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ] + }, + "ext": { + "bidder": { + "adbreakId": "400000001" + } + } + } + ], + "site": { + "publisher": { + "id": "1100042525" + }, + "content": { + "title": "a-title", + "season": "a-season", + "series": "a-series", + "episode": 1, + "len": 900, + "livestream": 1 + } + }, + "device": { + "ua": "test-user-agent" + }, + "user": { + "ext": { + "data": {} + } + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "Key path not found", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/openrtb_ext/imp_smaato.go b/openrtb_ext/imp_smaato.go index 10de97fb017..14dcb73bdf3 100644 --- a/openrtb_ext/imp_smaato.go +++ b/openrtb_ext/imp_smaato.go @@ -1,9 +1,12 @@ package openrtb_ext // ExtImpSmaato defines the contract for bidrequest.imp[i].ext.smaato -// PublisherId and AdSpaceId are mandatory parameters, others are optional parameters +// PublisherId and AdSpaceId are mandatory parameters for non adpod (long-form video) requests, others are optional parameters +// PublisherId and AdBreakId are mandatory parameters for adpod (long-form video) requests, others are optional parameters // AdSpaceId is identifier for specific ad placement or ad tag +// AdBreakId is identifier for specific ad placement or ad tag type ExtImpSmaato struct { PublisherID string `json:"publisherId"` AdSpaceID string `json:"adspaceId"` + AdBreakID string `json:"adbreakId"` } diff --git a/static/bidder-params/smaato.json b/static/bidder-params/smaato.json index aa91c4bacc5..e4584b86860 100644 --- a/static/bidder-params/smaato.json +++ b/static/bidder-params/smaato.json @@ -11,7 +11,25 @@ "adspaceId": { "type": "string", "description": "Identifier for specific ad placement is SOMA `adspaceId`" + }, + "adbreakId": { + "type": "string", + "description": "Identifier for specific adpod placement is SOMA `adbreakId`" } }, - "required": ["publisherId","adspaceId"] + "required": [ + "publisherId" + ], + "anyOf": [ + { + "required": [ + "adspaceId" + ] + }, + { + "required": [ + "adbreakId" + ] + } + ] } \ No newline at end of file From 54bb9f4569c94c39c1990213174e169a3efb29d9 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Tue, 22 Jun 2021 16:53:13 +0200 Subject: [PATCH 03/14] Smaato: Increase client version --- adapters/smaato/smaato.go | 2 +- .../smaato/smaatotest/exemplary/multiple-impressions.json | 4 ++-- adapters/smaato/smaatotest/exemplary/simple-banner-app.json | 2 +- .../smaatotest/exemplary/simple-banner-richMedia-app.json | 2 +- .../smaato/smaatotest/exemplary/simple-banner-richMedia.json | 2 +- adapters/smaato/smaatotest/exemplary/simple-banner.json | 2 +- adapters/smaato/smaatotest/exemplary/video-app.json | 2 +- adapters/smaato/smaatotest/exemplary/video.json | 2 +- adapters/smaato/smaatotest/supplemental/bad-adm-response.json | 2 +- .../smaatotest/supplemental/bad-status-code-response.json | 2 +- adapters/smaato/smaatotest/supplemental/no-bid-response.json | 2 +- .../smaatotest/supplemental/no-consent-info-request.json | 2 +- adapters/smaato/smaatotest/video/multiple-adpods.json | 4 ++-- adapters/smaato/smaatotest/video/single-adpod.json | 2 +- .../smaato/smaatotest/videosupplemental/bad-adm-response.json | 2 +- .../smaatotest/videosupplemental/bad-bid-ext-response.json | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index e75cefcc855..c097d5751fa 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -15,7 +15,7 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) -const clientVersion = "prebid_server_0.2" +const clientVersion = "prebid_server_0.3" type adMarkupType string diff --git a/adapters/smaato/smaatotest/exemplary/multiple-impressions.json b/adapters/smaato/smaatotest/exemplary/multiple-impressions.json index 43aafb36738..651daf4c1fe 100644 --- a/adapters/smaato/smaatotest/exemplary/multiple-impressions.json +++ b/adapters/smaato/smaatotest/exemplary/multiple-impressions.json @@ -159,7 +159,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, @@ -264,7 +264,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-app.json b/adapters/smaato/smaatotest/exemplary/simple-banner-app.json index 8194f568c28..8adf354abb4 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner-app.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-app.json @@ -160,7 +160,7 @@ "keywords": "keywords" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json index 46722c4ff71..80ac7d64eac 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json @@ -164,7 +164,7 @@ "keywords": "keywords" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json index 1018dbc39ac..db4e56e2a2f 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json @@ -129,7 +129,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner.json b/adapters/smaato/smaatotest/exemplary/simple-banner.json index 0ba4050a143..a170235f28d 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner.json @@ -125,7 +125,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/video-app.json b/adapters/smaato/smaatotest/exemplary/video-app.json index bf939eb078a..412b0a0e8ab 100644 --- a/adapters/smaato/smaatotest/exemplary/video-app.json +++ b/adapters/smaato/smaatotest/exemplary/video-app.json @@ -165,7 +165,7 @@ "keywords": "keywords" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/video.json b/adapters/smaato/smaatotest/exemplary/video.json index bad3825bb62..4df5c00fb75 100644 --- a/adapters/smaato/smaatotest/exemplary/video.json +++ b/adapters/smaato/smaatotest/exemplary/video.json @@ -122,7 +122,7 @@ } }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/supplemental/bad-adm-response.json b/adapters/smaato/smaatotest/supplemental/bad-adm-response.json index 8c6ad1b1ff0..885c077e624 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-adm-response.json +++ b/adapters/smaato/smaatotest/supplemental/bad-adm-response.json @@ -125,7 +125,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/supplemental/bad-status-code-response.json b/adapters/smaato/smaatotest/supplemental/bad-status-code-response.json index 90020a14455..a087594325e 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-status-code-response.json +++ b/adapters/smaato/smaatotest/supplemental/bad-status-code-response.json @@ -125,7 +125,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/supplemental/no-bid-response.json b/adapters/smaato/smaatotest/supplemental/no-bid-response.json index bcc16415d4c..c8821d2d944 100644 --- a/adapters/smaato/smaatotest/supplemental/no-bid-response.json +++ b/adapters/smaato/smaatotest/supplemental/no-bid-response.json @@ -125,7 +125,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json b/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json index b9a4294b00b..947aaf617c0 100644 --- a/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json +++ b/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json @@ -72,7 +72,7 @@ } }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/video/multiple-adpods.json b/adapters/smaato/smaatotest/video/multiple-adpods.json index 7e8d03ab0b9..5b9951058ce 100644 --- a/adapters/smaato/smaatotest/video/multiple-adpods.json +++ b/adapters/smaato/smaatotest/video/multiple-adpods.json @@ -228,7 +228,7 @@ } }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, @@ -374,7 +374,7 @@ } }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/video/single-adpod.json b/adapters/smaato/smaatotest/video/single-adpod.json index 25aeb55e932..1122f586897 100644 --- a/adapters/smaato/smaatotest/video/single-adpod.json +++ b/adapters/smaato/smaatotest/video/single-adpod.json @@ -170,7 +170,7 @@ } }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json index 6947a3ee50a..502cdbcc444 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json @@ -170,7 +170,7 @@ } }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json index 37ae363537c..f3bafe23278 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json @@ -170,7 +170,7 @@ } }, "ext": { - "client": "prebid_server_0.2" + "client": "prebid_server_0.3" } } }, From 8d2d2df14ff05467b5a26fd771116067d3651ee8 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Thu, 24 Jun 2021 12:32:23 +0200 Subject: [PATCH 04/14] Smaato: Add bid.exp from header --- adapters/smaato/smaato.go | 15 +++++++++++++++ .../exemplary/multiple-impressions.json | 6 ++++-- .../smaatotest/exemplary/simple-banner-app.json | 3 ++- .../exemplary/simple-banner-richMedia-app.json | 3 ++- .../exemplary/simple-banner-richMedia.json | 3 ++- .../smaatotest/exemplary/simple-banner.json | 3 ++- .../smaato/smaatotest/exemplary/video-app.json | 3 ++- adapters/smaato/smaatotest/exemplary/video.json | 3 ++- .../supplemental/no-consent-info-request.json | 3 ++- .../smaato/smaatotest/video/multiple-adpods.json | 12 ++++++++---- .../smaato/smaatotest/video/single-adpod.json | 6 ++++-- .../videosupplemental/bad-adm-response.json | 3 ++- .../videosupplemental/bad-bid-ext-response.json | 3 ++- 13 files changed, 49 insertions(+), 17 deletions(-) diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index c097d5751fa..1b3b4e03c90 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -5,7 +5,9 @@ import ( "fmt" "github.com/prebid/prebid-server/metrics" "net/http" + "strconv" "strings" + "time" "github.com/buger/jsonparser" "github.com/mxmCherry/openrtb/v15/openrtb2" @@ -136,6 +138,8 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR continue } + bid.Exp = getTTLFromHeaderOrDefault(response) + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bid, BidType: bidType, @@ -236,6 +240,17 @@ func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkup } } +func getTTLFromHeaderOrDefault(response *adapters.ResponseData) int64 { + ttl := int64(300) + + if expiresAtMillis, err := strconv.ParseInt(response.Headers.Get("X-SMT-Expires"), 10, 64); err == nil { + nowMillis := time.Now().UnixNano() / 1000000 + ttl = (expiresAtMillis - nowMillis) / 1000 + } + + return ttl +} + func renderAdMarkup(adMarkupType adMarkupType, adMarkup string) (string, error) { switch adMarkupType { case smtAdTypeImg: diff --git a/adapters/smaato/smaatotest/exemplary/multiple-impressions.json b/adapters/smaato/smaatotest/exemplary/multiple-impressions.json index 651daf4c1fe..e86fea8eb04 100644 --- a/adapters/smaato/smaatotest/exemplary/multiple-impressions.json +++ b/adapters/smaato/smaatotest/exemplary/multiple-impressions.json @@ -319,7 +319,8 @@ "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", "price": 0.01, "w": 350, - "h": 50 + "h": 50, + "exp": 300 }, "type": "banner" } @@ -342,7 +343,8 @@ "nurl": "https://nurl", "price": 0.01, "w": 1024, - "h": 768 + "h": 768, + "exp": 300 }, "type": "video" } diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-app.json b/adapters/smaato/smaatotest/exemplary/simple-banner-app.json index 8adf354abb4..2752fa6e6c7 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner-app.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-app.json @@ -215,7 +215,8 @@ "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", "price": 0.01, "w": 350, - "h": 50 + "h": 50, + "exp": 300 }, "type": "banner" } diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json index 80ac7d64eac..bc3a3c28c87 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json @@ -219,7 +219,8 @@ "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", "price": 0.01, "w": 350, - "h": 50 + "h": 50, + "exp": 300 }, "type": "banner" } diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json index db4e56e2a2f..7f81d39cd81 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json @@ -184,7 +184,8 @@ "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", "price": 0.01, "w": 350, - "h": 50 + "h": 50, + "exp": 300 }, "type": "banner" } diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner.json b/adapters/smaato/smaatotest/exemplary/simple-banner.json index a170235f28d..f83e347a684 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner.json @@ -180,7 +180,8 @@ "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", "price": 0.01, "w": 350, - "h": 50 + "h": 50, + "exp": 300 }, "type": "banner" } diff --git a/adapters/smaato/smaatotest/exemplary/video-app.json b/adapters/smaato/smaatotest/exemplary/video-app.json index 412b0a0e8ab..317003f52b3 100644 --- a/adapters/smaato/smaatotest/exemplary/video-app.json +++ b/adapters/smaato/smaatotest/exemplary/video-app.json @@ -220,7 +220,8 @@ "nurl": "https://nurl", "price": 0.01, "w": 1024, - "h": 768 + "h": 768, + "exp": 300 }, "type": "video" } diff --git a/adapters/smaato/smaatotest/exemplary/video.json b/adapters/smaato/smaatotest/exemplary/video.json index 4df5c00fb75..85699129180 100644 --- a/adapters/smaato/smaatotest/exemplary/video.json +++ b/adapters/smaato/smaatotest/exemplary/video.json @@ -177,7 +177,8 @@ "nurl": "https://nurl", "price": 0.01, "w": 1024, - "h": 768 + "h": 768, + "exp": 300 }, "type": "video" } diff --git a/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json b/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json index 947aaf617c0..72f8a2e3b9d 100644 --- a/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json +++ b/adapters/smaato/smaatotest/supplemental/no-consent-info-request.json @@ -127,7 +127,8 @@ "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", "price": 0.01, "w": 350, - "h": 50 + "h": 50, + "exp": 300 }, "type": "banner" } diff --git a/adapters/smaato/smaatotest/video/multiple-adpods.json b/adapters/smaato/smaatotest/video/multiple-adpods.json index 5b9951058ce..11ae8e56d27 100644 --- a/adapters/smaato/smaatotest/video/multiple-adpods.json +++ b/adapters/smaato/smaatotest/video/multiple-adpods.json @@ -457,7 +457,8 @@ "cat": ["IAB1"], "ext": { "duration": 5 - } + }, + "exp": 300 }, "type": "video" @@ -480,7 +481,8 @@ "cat": ["IAB2"], "ext": { "duration": 30 - } + }, + "exp": 300 }, "type": "video" } @@ -507,7 +509,8 @@ "cat": ["IAB1"], "ext": { "duration": 5 - } + }, + "exp": 300 }, "type": "video" }, @@ -529,7 +532,8 @@ "cat": ["IAB2"], "ext": { "duration": 30 - } + }, + "exp": 300 }, "type": "video" } diff --git a/adapters/smaato/smaatotest/video/single-adpod.json b/adapters/smaato/smaatotest/video/single-adpod.json index 1122f586897..ff1134e5845 100644 --- a/adapters/smaato/smaatotest/video/single-adpod.json +++ b/adapters/smaato/smaatotest/video/single-adpod.json @@ -253,7 +253,8 @@ "cat": ["IAB1"], "ext": { "duration": 5 - } + }, + "exp": 300 }, "type": "video" }, @@ -275,7 +276,8 @@ "cat": ["IAB2"], "ext": { "duration": 30 - } + }, + "exp": 300 }, "type": "video" } diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json index 502cdbcc444..821692251c4 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json @@ -259,7 +259,8 @@ "cat": ["IAB1"], "ext": { "duration": 5 - } + }, + "exp": 300 }, "type": "video" } diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json index f3bafe23278..ec119cb7189 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json @@ -257,7 +257,8 @@ "cat": ["IAB1"], "ext": { "duration": 5 - } + }, + "exp": 300 }, "type": "video" } From 59c9b70ee0163a0ed0ce540979cac496de0fbfec Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Thu, 24 Jun 2021 13:08:54 +0200 Subject: [PATCH 05/14] Smaato: Improve error messages --- adapters/smaato/image.go | 5 +- adapters/smaato/image_test.go | 2 +- adapters/smaato/richmedia.go | 9 ++- adapters/smaato/richmedia_test.go | 2 +- adapters/smaato/smaato.go | 14 ++-- .../supplemental/bad-site-ext-request.json | 2 +- .../bad-user-ext-data-request.json | 2 +- .../supplemental/bad-user-ext-request.json | 2 +- .../supplemental/no-adspace-id-request.json | 74 +++++++++++++++++++ ...uest.json => no-publisher-id-request.json} | 2 +- .../bad-adbreak-id-request.json | 2 +- .../bad-bid-ext-response.json | 2 +- .../bad-publisher-id-request.json | 2 +- 13 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 adapters/smaato/smaatotest/supplemental/no-adspace-id-request.json rename adapters/smaato/smaatotest/supplemental/{bad-imp-ext-request.json => no-publisher-id-request.json} (91%) diff --git a/adapters/smaato/image.go b/adapters/smaato/image.go index 6efb513473f..ef4df287c1a 100644 --- a/adapters/smaato/image.go +++ b/adapters/smaato/image.go @@ -3,6 +3,7 @@ package smaato import ( "encoding/json" "fmt" + "github.com/prebid/prebid-server/errortypes" "net/url" "strings" ) @@ -25,7 +26,9 @@ type img struct { func extractAdmImage(adMarkup string) (string, error) { var imageAd imageAd if err := json.Unmarshal([]byte(adMarkup), &imageAd); err != nil { - return "", err + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Invalid ad markup %s.", adMarkup), + } } var clickEvent strings.Builder diff --git a/adapters/smaato/image_test.go b/adapters/smaato/image_test.go index aa9e7abf80f..b09489c5ce1 100644 --- a/adapters/smaato/image_test.go +++ b/adapters/smaato/image_test.go @@ -31,7 +31,7 @@ func TestExtractAdmImage(t *testing.T) { {"invalid adMarkup", args{"{"}, "", - "unexpected end of JSON input", + "Invalid ad markup {.", }, } diff --git a/adapters/smaato/richmedia.go b/adapters/smaato/richmedia.go index 2c350a6b5db..58798feabcd 100644 --- a/adapters/smaato/richmedia.go +++ b/adapters/smaato/richmedia.go @@ -3,6 +3,7 @@ package smaato import ( "encoding/json" "fmt" + "github.com/prebid/prebid-server/errortypes" "net/url" "strings" ) @@ -22,10 +23,12 @@ type richmedia struct { Clicktrackers []string `json:"clicktrackers"` } -func extractAdmRichMedia(adapterResponseAdm string) (string, error) { +func extractAdmRichMedia(adMarkup string) (string, error) { var richMediaAd richMediaAd - if err := json.Unmarshal([]byte(adapterResponseAdm), &richMediaAd); err != nil { - return "", err + if err := json.Unmarshal([]byte(adMarkup), &richMediaAd); err != nil { + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Invalid ad markup %s.", adMarkup), + } } var clickEvent strings.Builder diff --git a/adapters/smaato/richmedia_test.go b/adapters/smaato/richmedia_test.go index d597c16dcf4..d1bfede80a1 100644 --- a/adapters/smaato/richmedia_test.go +++ b/adapters/smaato/richmedia_test.go @@ -28,7 +28,7 @@ func TestExtractAdmRichMedia(t *testing.T) { {"invalid adMarkup", args{"{"}, "", - "unexpected end of JSON input", + "Invalid ad markup {.", }, } diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 1b3b4e03c90..3fd8e10b916 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -322,10 +322,10 @@ func setUser(request *openrtb2.BidRequest) error { var userExtRaw map[string]json.RawMessage if err = json.Unmarshal(request.User.Ext, &userExtRaw); err != nil { - return err + return &errortypes.BadInput{Message: "Invalid user.ext."} } if err = json.Unmarshal(request.User.Ext, &userExt); err != nil { - return err + return &errortypes.BadInput{Message: "Invalid user.ext.data."} } userCopy := *request.User @@ -372,7 +372,7 @@ func setSite(request *openrtb2.BidRequest) error { var siteExt siteExt if err := json.Unmarshal(request.Site.Ext, &siteExt); err != nil { - return err + return &errortypes.BadInput{Message: "Invalid site.ext."} } siteCopy.Keywords = siteExt.Data.Keywords @@ -394,7 +394,7 @@ func setApp(request *openrtb2.BidRequest) { func setPublisherId(request *openrtb2.BidRequest, imp *openrtb2.Imp) error { publisherID, err := jsonparser.GetString(imp.Ext, "bidder", "publisherId") if err != nil { - return err + return &errortypes.BadInput{Message: "Missing publisherId parameter."} } if request.Site != nil { @@ -413,7 +413,7 @@ func setPublisherId(request *openrtb2.BidRequest, imp *openrtb2.Imp) error { func setImpForAdspace(imp *openrtb2.Imp) error { adSpaceID, err := jsonparser.GetString(imp.Ext, "bidder", "adspaceId") if err != nil { - return err + return &errortypes.BadInput{Message: "Missing adspaceId parameter."} } if imp.Banner != nil { @@ -439,7 +439,7 @@ func setImpForAdspace(imp *openrtb2.Imp) error { func setImpForAdBreak(imps []openrtb2.Imp) error { adBreakID, err := jsonparser.GetString(imps[0].Ext, "bidder", "adbreakId") if err != nil { - return err + return &errortypes.BadInput{Message: "Missing adbreakId parameter."} } for i := range imps { @@ -513,7 +513,7 @@ func buildBidVideo(bid *openrtb2.Bid, bidType openrtb_ext.BidType) (*openrtb_ext var bidExt bidExt if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { - return nil, err + return nil, &errortypes.BadServerResponse{Message: "Invalid bid.ext."} } return &openrtb_ext.ExtBidPrebidVideo{ diff --git a/adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json b/adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json index 8045ccd22d2..0df53e6c0bc 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json +++ b/adapters/smaato/smaatotest/supplemental/bad-site-ext-request.json @@ -27,7 +27,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type smaato.siteExt", + "value": "Invalid site.ext.", "comparison": "literal" } ] diff --git a/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-request.json b/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-request.json index dce69556988..10f5ad474c6 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-request.json +++ b/adapters/smaato/smaatotest/supplemental/bad-user-ext-data-request.json @@ -50,7 +50,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field userExtData.data.yob of type int64", + "value": "Invalid user.ext.data.", "comparison": "literal" } ] diff --git a/adapters/smaato/smaatotest/supplemental/bad-user-ext-request.json b/adapters/smaato/smaatotest/supplemental/bad-user-ext-request.json index f8ec41e22ed..26df372e14f 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-user-ext-request.json +++ b/adapters/smaato/smaatotest/supplemental/bad-user-ext-request.json @@ -29,7 +29,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal number into Go value of type map[string]json.RawMessage", + "value": "Invalid user.ext.", "comparison": "literal" } ] diff --git a/adapters/smaato/smaatotest/supplemental/no-adspace-id-request.json b/adapters/smaato/smaatotest/supplemental/no-adspace-id-request.json new file mode 100644 index 00000000000..88b0a4080e6 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/no-adspace-id-request.json @@ -0,0 +1,74 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "Missing adspaceId parameter.", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-imp-ext-request.json b/adapters/smaato/smaatotest/supplemental/no-publisher-id-request.json similarity index 91% rename from adapters/smaato/smaatotest/supplemental/bad-imp-ext-request.json rename to adapters/smaato/smaatotest/supplemental/no-publisher-id-request.json index 61601910530..60a0af594a8 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-imp-ext-request.json +++ b/adapters/smaato/smaatotest/supplemental/no-publisher-id-request.json @@ -22,7 +22,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Key path not found", + "value": "Missing publisherId parameter.", "comparison": "literal" } ] diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json b/adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json index 300220a0afa..308648d3f64 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-adbreak-id-request.json @@ -83,7 +83,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Key path not found", + "value": "Missing adbreakId parameter.", "comparison": "literal" } ] diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json index ec119cb7189..2a69771abc3 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json @@ -231,7 +231,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type smaato.bidExt", + "value": "Invalid bid.ext.", "comparison": "literal" } ], diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json b/adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json index 2a40d82ad58..1615b670e9b 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-publisher-id-request.json @@ -83,7 +83,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Key path not found", + "value": "Missing publisherId parameter.", "comparison": "literal" } ] From 78243757a42f67e7e96628d88e04dc830e7be190 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Thu, 24 Jun 2021 13:22:22 +0200 Subject: [PATCH 06/14] Smaato: Add video.ext.context to bidRequests --- adapters/smaato/smaato.go | 8 ++++++++ .../smaatotest/video/multiple-adpods.json | 20 +++++++++++++++---- .../smaato/smaatotest/video/single-adpod.json | 10 ++++++++-- .../videosupplemental/bad-adm-response.json | 10 ++++++++-- .../bad-bid-ext-response.json | 10 ++++++++-- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 3fd8e10b916..6734dab744f 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -62,6 +62,11 @@ type bidExt struct { Duration int `json:"duration"` } +// videoExt defines Video.Ext object for Smaato +type videoExt struct { + Context string `json:"context,omitempty"` +} + // Builder builds a new instance of the Smaato adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &SmaatoAdapter{ @@ -447,7 +452,10 @@ func setImpForAdBreak(imps []openrtb2.Imp) error { imps[i].Ext = nil videoCopy := *(imps[i].Video) + videoCopy.Sequence = int8(i + 1) + videoCopy.Ext, _ = json.Marshal(&videoExt{Context: "adpod"}) + imps[i].Video = &videoCopy } diff --git a/adapters/smaato/smaatotest/video/multiple-adpods.json b/adapters/smaato/smaatotest/video/multiple-adpods.json index 11ae8e56d27..c909dc15f25 100644 --- a/adapters/smaato/smaatotest/video/multiple-adpods.json +++ b/adapters/smaato/smaatotest/video/multiple-adpods.json @@ -178,7 +178,10 @@ "api": [ 7 ], - "sequence": 1 + "sequence": 1, + "ext": { + "context": "adpod" + } } }, { @@ -203,7 +206,10 @@ "api": [ 7 ], - "sequence": 2 + "sequence": 2, + "ext": { + "context": "adpod" + } } } ], @@ -324,7 +330,10 @@ "api": [ 7 ], - "sequence": 1 + "sequence": 1, + "ext": { + "context": "adpod" + } } }, { @@ -349,7 +358,10 @@ "api": [ 7 ], - "sequence": 2 + "sequence": 2, + "ext": { + "context": "adpod" + } } } ], diff --git a/adapters/smaato/smaatotest/video/single-adpod.json b/adapters/smaato/smaatotest/video/single-adpod.json index ff1134e5845..b5bc09d495c 100644 --- a/adapters/smaato/smaatotest/video/single-adpod.json +++ b/adapters/smaato/smaatotest/video/single-adpod.json @@ -120,7 +120,10 @@ "api": [ 7 ], - "sequence": 1 + "sequence": 1, + "ext": { + "context": "adpod" + } } }, { @@ -145,7 +148,10 @@ "api": [ 7 ], - "sequence": 2 + "sequence": 2, + "ext": { + "context": "adpod" + } } } ], diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json index 821692251c4..b13906ce066 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-adm-response.json @@ -120,7 +120,10 @@ "api": [ 7 ], - "sequence": 1 + "sequence": 1, + "ext": { + "context": "adpod" + } } }, { @@ -145,7 +148,10 @@ "api": [ 7 ], - "sequence": 2 + "sequence": 2, + "ext": { + "context": "adpod" + } } } ], diff --git a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json index 2a69771abc3..2e0556ff15e 100644 --- a/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json +++ b/adapters/smaato/smaatotest/videosupplemental/bad-bid-ext-response.json @@ -120,7 +120,10 @@ "api": [ 7 ], - "sequence": 1 + "sequence": 1, + "ext": { + "context": "adpod" + } } }, { @@ -145,7 +148,10 @@ "api": [ 7 ], - "sequence": 2 + "sequence": 2, + "ext": { + "context": "adpod" + } } } ], From ddbe5f01403c79ac6973e14acee5f05ef5b79cbc Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Fri, 25 Jun 2021 11:52:47 +0200 Subject: [PATCH 07/14] Smaato: Test Headers --- adapters/smaato/clock.go | 18 ++ adapters/smaato/smaato.go | 25 ++- adapters/smaato/smaato_test.go | 6 + .../supplemental/adtype-header-response.json | 194 ++++++++++++++++++ .../bad-adtype-header-response.json | 174 ++++++++++++++++ .../bad-expires-header-response.json | 194 ++++++++++++++++++ .../supplemental/expires-header-response.json | 194 ++++++++++++++++++ 7 files changed, 794 insertions(+), 11 deletions(-) create mode 100644 adapters/smaato/clock.go create mode 100644 adapters/smaato/smaatotest/supplemental/adtype-header-response.json create mode 100644 adapters/smaato/smaatotest/supplemental/bad-adtype-header-response.json create mode 100644 adapters/smaato/smaatotest/supplemental/bad-expires-header-response.json create mode 100644 adapters/smaato/smaatotest/supplemental/expires-header-response.json diff --git a/adapters/smaato/clock.go b/adapters/smaato/clock.go new file mode 100644 index 00000000000..858120b37d6 --- /dev/null +++ b/adapters/smaato/clock.go @@ -0,0 +1,18 @@ +package smaato + +import "time" + +type clock interface { + Now() time.Time +} + +type realClock struct{} +type mockClock time.Time + +func (_ realClock) Now() time.Time { + return time.Now() +} + +func (mockClock mockClock) Now() time.Time { + return time.Time(mockClock) +} diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 6734dab744f..2df9bc24492 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -3,18 +3,16 @@ package smaato import ( "encoding/json" "fmt" - "github.com/prebid/prebid-server/metrics" - "net/http" - "strconv" - "strings" - "time" - "github.com/buger/jsonparser" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/metrics" "github.com/prebid/prebid-server/openrtb_ext" + "net/http" + "strconv" + "strings" ) const clientVersion = "prebid_server_0.3" @@ -29,6 +27,7 @@ const ( // SmaatoAdapter describes a Smaato prebid server adapter. type SmaatoAdapter struct { + clock clock endpoint string } @@ -70,6 +69,7 @@ type videoExt struct { // Builder builds a new instance of the Smaato adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &SmaatoAdapter{ + clock: realClock{}, endpoint: config.Endpoint, } return bidder, nil @@ -143,7 +143,7 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR continue } - bid.Exp = getTTLFromHeaderOrDefault(response) + bid.Exp = a.getTTLFromHeaderOrDefault(response) bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bid, @@ -230,7 +230,7 @@ func (a *SmaatoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.Req } func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkupType, error) { - if admType := adMarkupType(response.Headers.Get("X-SMT-ADTYPE")); admType != "" { + if admType := adMarkupType(response.Headers.Get("X-Smt-Adtype")); admType != "" { return admType, nil } else if strings.HasPrefix(adMarkup, `{"image":`) { return smtAdTypeImg, nil @@ -245,12 +245,15 @@ func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkup } } -func getTTLFromHeaderOrDefault(response *adapters.ResponseData) int64 { +func (a *SmaatoAdapter) getTTLFromHeaderOrDefault(response *adapters.ResponseData) int64 { ttl := int64(300) - if expiresAtMillis, err := strconv.ParseInt(response.Headers.Get("X-SMT-Expires"), 10, 64); err == nil { - nowMillis := time.Now().UnixNano() / 1000000 + if expiresAtMillis, err := strconv.ParseInt(response.Headers.Get("X-Smt-Expires"), 10, 64); err == nil { + nowMillis := a.clock.Now().UnixNano() / 1000000 ttl = (expiresAtMillis - nowMillis) / 1000 + if ttl < 0 { + ttl = 0 + } } return ttl diff --git a/adapters/smaato/smaato_test.go b/adapters/smaato/smaato_test.go index f0e95120d7a..413665e2d90 100644 --- a/adapters/smaato/smaato_test.go +++ b/adapters/smaato/smaato_test.go @@ -4,7 +4,9 @@ import ( "encoding/json" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" + "github.com/stretchr/testify/assert" "testing" + "time" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -19,6 +21,10 @@ func TestJsonSamples(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } + smaatoAdapter, _ := bidder.(*SmaatoAdapter) + assert.NotNil(t, smaatoAdapter.clock) + smaatoAdapter.clock = mockClock(time.Date(2021, 6, 25, 10, 00, 0, 0, time.UTC)) + adapterstest.RunJSONBidderTest(t, "smaatotest", bidder) } diff --git a/adapters/smaato/smaatotest/supplemental/adtype-header-response.json b/adapters/smaato/smaatotest/supplemental/adtype-header-response.json new file mode 100644 index 00000000000..59302b6de59 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/adtype-header-response.json @@ -0,0 +1,194 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.3" + } + } + }, + "mockResponse": { + "status": 200, + "headers": { + "X-Smt-Adtype": ["Img"] + }, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\",\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50, + "exp": 300 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-adtype-header-response.json b/adapters/smaato/smaatotest/supplemental/bad-adtype-header-response.json new file mode 100644 index 00000000000..cfb23bbef85 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/bad-adtype-header-response.json @@ -0,0 +1,174 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.3" + } + } + }, + "mockResponse": { + "status": 200, + "headers": { + "X-Smt-Adtype": ["something"] + }, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\",\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unknown markup type something.", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/bad-expires-header-response.json b/adapters/smaato/smaatotest/supplemental/bad-expires-header-response.json new file mode 100644 index 00000000000..8e41524493d --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/bad-expires-header-response.json @@ -0,0 +1,194 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.3" + } + } + }, + "mockResponse": { + "status": 200, + "headers": { + "X-Smt-Expires": ["something"] + }, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\",\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50, + "exp": 300 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/expires-header-response.json b/adapters/smaato/smaatotest/supplemental/expires-header-response.json new file mode 100644 index 00000000000..90a78e626cf --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/expires-header-response.json @@ -0,0 +1,194 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.3" + } + } + }, + "mockResponse": { + "status": 200, + "headers": { + "X-Smt-Expires": ["1624618800000"] + }, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\",\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50, + "exp": 3600 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file From cd4dcb8e35778ea21630465a1a7e4b0bb5549054 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Fri, 25 Jun 2021 12:40:56 +0200 Subject: [PATCH 08/14] Smaato: Rename receiver --- adapters/smaato/smaato.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 2df9bc24492..222de756ef4 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -76,7 +76,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{Message: "No impressions in bid request."}} } @@ -89,14 +89,14 @@ func (a *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adap isVideoEntryPoint := reqInfo.PbsEntryPoint == metrics.ReqTypeVideo if isVideoEntryPoint { - return a.makePodRequests(request) + return adapter.makePodRequests(request) } else { - return a.makeIndividualRequests(request) + return adapter.makeIndividualRequests(request) } } // MakeBids unpacks the server's response into Bids. -func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -143,7 +143,7 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR continue } - bid.Exp = a.getTTLFromHeaderOrDefault(response) + bid.Exp = adapter.getTTLFromHeaderOrDefault(response) bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bid, @@ -155,7 +155,7 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR return bidResponse, errors } -func (a *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { +func (adapter *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { imps := request.Imp requests := make([]*adapters.RequestData, 0, len(imps)) @@ -168,7 +168,7 @@ func (a *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidRequest) ([] continue } - requestData, err := a.makeRequest(request) + requestData, err := adapter.makeRequest(request) if err != nil { errors = append(errors, err) continue @@ -180,7 +180,7 @@ func (a *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidRequest) ([] return requests, errors } -func (a *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { +func (adapter *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { pods, orderedKeys := groupImpressionsByPod(request.Imp) requests := make([]*adapters.RequestData, 0, len(pods)) errors := make([]error, 0, len(request.Imp)) @@ -198,7 +198,7 @@ func (a *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapte continue } - requestData, err := a.makeRequest(request) + requestData, err := adapter.makeRequest(request) if err != nil { errors = append(errors, err) continue @@ -211,7 +211,7 @@ func (a *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapte return requests, errors } -func (a *SmaatoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { +func (adapter *SmaatoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { reqJSON, err := json.Marshal(request) if err != nil { return nil, err @@ -223,7 +223,7 @@ func (a *SmaatoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.Req return &adapters.RequestData{ Method: "POST", - Uri: a.endpoint, + Uri: adapter.endpoint, Body: reqJSON, Headers: headers, }, nil @@ -245,11 +245,11 @@ func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkup } } -func (a *SmaatoAdapter) getTTLFromHeaderOrDefault(response *adapters.ResponseData) int64 { +func (adapter *SmaatoAdapter) getTTLFromHeaderOrDefault(response *adapters.ResponseData) int64 { ttl := int64(300) if expiresAtMillis, err := strconv.ParseInt(response.Headers.Get("X-Smt-Expires"), 10, 64); err == nil { - nowMillis := a.clock.Now().UnixNano() / 1000000 + nowMillis := adapter.clock.Now().UnixNano() / 1000000 ttl = (expiresAtMillis - nowMillis) / 1000 if ttl < 0 { ttl = 0 From 2cd4338a4b34c30d69d7de57d3a8a8eefa15c169 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Tue, 29 Jun 2021 07:31:36 +0200 Subject: [PATCH 09/14] Smaato: PR - use timeutil --- adapters/smaato/clock.go | 18 ------------------ adapters/smaato/smaato.go | 5 +++-- adapters/smaato/smaato_test.go | 10 +++++++++- 3 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 adapters/smaato/clock.go diff --git a/adapters/smaato/clock.go b/adapters/smaato/clock.go deleted file mode 100644 index 858120b37d6..00000000000 --- a/adapters/smaato/clock.go +++ /dev/null @@ -1,18 +0,0 @@ -package smaato - -import "time" - -type clock interface { - Now() time.Time -} - -type realClock struct{} -type mockClock time.Time - -func (_ realClock) Now() time.Time { - return time.Now() -} - -func (mockClock mockClock) Now() time.Time { - return time.Time(mockClock) -} diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 222de756ef4..3d9eefe4f90 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/metrics" "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/util/timeutil" "net/http" "strconv" "strings" @@ -27,7 +28,7 @@ const ( // SmaatoAdapter describes a Smaato prebid server adapter. type SmaatoAdapter struct { - clock clock + clock timeutil.Time endpoint string } @@ -69,7 +70,7 @@ type videoExt struct { // Builder builds a new instance of the Smaato adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &SmaatoAdapter{ - clock: realClock{}, + clock: &timeutil.RealTime{}, endpoint: config.Endpoint, } return bidder, nil diff --git a/adapters/smaato/smaato_test.go b/adapters/smaato/smaato_test.go index 413665e2d90..cd282697162 100644 --- a/adapters/smaato/smaato_test.go +++ b/adapters/smaato/smaato_test.go @@ -23,7 +23,7 @@ func TestJsonSamples(t *testing.T) { smaatoAdapter, _ := bidder.(*SmaatoAdapter) assert.NotNil(t, smaatoAdapter.clock) - smaatoAdapter.clock = mockClock(time.Date(2021, 6, 25, 10, 00, 0, 0, time.UTC)) + smaatoAdapter.clock = &mockTime{time: time.Date(2021, 6, 25, 10, 00, 0, 0, time.UTC)} adapterstest.RunJSONBidderTest(t, "smaatotest", bidder) } @@ -100,3 +100,11 @@ func TestVideoWithCategoryAndDuration(t *testing.T) { t.Errorf("should not have any errors, errors=%v", errors) } } + +type mockTime struct { + time time.Time +} + +func (mt *mockTime) Now() time.Time { + return mt.time +} From 124db8794d621f9ff1db2f2df6e35fe0536b1cb9 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Wed, 7 Jul 2021 09:10:25 +0200 Subject: [PATCH 10/14] Smaato: PR fixes --- adapters/smaato/image.go | 7 ++-- adapters/smaato/image_test.go | 43 ++++++++++------------- adapters/smaato/richmedia.go | 5 ++- adapters/smaato/richmedia_test.go | 43 ++++++++++------------- adapters/smaato/smaato.go | 58 +++++++++++-------------------- 5 files changed, 67 insertions(+), 89 deletions(-) diff --git a/adapters/smaato/image.go b/adapters/smaato/image.go index ef4df287c1a..a4dad157bd1 100644 --- a/adapters/smaato/image.go +++ b/adapters/smaato/image.go @@ -42,7 +42,8 @@ func extractAdmImage(adMarkup string) (string, error) { impressionTracker.WriteString(fmt.Sprintf(``, impression)) } - return fmt.Sprintf(`
`+ - `%s`+ - `
`, &clickEvent, url.QueryEscape(imageAd.Image.Img.Ctaurl), imageAd.Image.Img.URL, imageAd.Image.Img.W, imageAd.Image.Img.H, &impressionTracker), nil + imageAdMarkup := fmt.Sprintf(`
%s
`, + &clickEvent, url.QueryEscape(imageAd.Image.Img.Ctaurl), imageAd.Image.Img.URL, imageAd.Image.Img.W, imageAd.Image.Img.H, &impressionTracker) + + return imageAdMarkup, nil } diff --git a/adapters/smaato/image_test.go b/adapters/smaato/image_test.go index b09489c5ce1..1ba99ddd7c5 100644 --- a/adapters/smaato/image_test.go +++ b/adapters/smaato/image_test.go @@ -1,56 +1,51 @@ package smaato import ( + "github.com/stretchr/testify/assert" "testing" ) func TestExtractAdmImage(t *testing.T) { - type args struct { - adMarkup string - } tests := []struct { testName string - args args + adMarkup string expectedAdMarkup string expectedError string }{ - {"extract image", - args{"{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\"," + + { + testName: "extract image", + adMarkup: "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\"," + "\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"}," + "\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"]," + - "\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}"}, - `
` + `` + `` + `
`, - "", + expectedError: "", }, - {"invalid adMarkup", - args{"{"}, - "", - "Invalid ad markup {.", + { + testName: "invalid adMarkup", + adMarkup: "{", + expectedAdMarkup: "", + expectedError: "Invalid ad markup {.", }, } for _, tt := range tests { t.Run(tt.testName, func(t *testing.T) { - adMarkup, err := extractAdmImage(tt.args.adMarkup) + adMarkup, err := extractAdmImage(tt.adMarkup) + if tt.expectedError != "" { - if err == nil { - t.Errorf("extractAdmImage() expectedError %v", tt.expectedError) - } else if err.Error() != tt.expectedError { - t.Errorf("extractAdmImage() err = %v, expectedError %v", err, tt.expectedError) - } - } else if err != nil { - t.Errorf("extractAdmImage() unexpected err = %v", err) + assert.EqualError(t, err, tt.expectedError) + } else { + assert.NoError(t, err) } - if adMarkup != tt.expectedAdMarkup { - t.Errorf("extractAdmImage() adMarkup = %v, expectedAdMarkup %v", adMarkup, tt.expectedAdMarkup) - } + assert.Equal(t, tt.expectedAdMarkup, adMarkup) }) } } diff --git a/adapters/smaato/richmedia.go b/adapters/smaato/richmedia.go index 58798feabcd..a8865361d38 100644 --- a/adapters/smaato/richmedia.go +++ b/adapters/smaato/richmedia.go @@ -42,5 +42,8 @@ func extractAdmRichMedia(adMarkup string) (string, error) { impressionTracker.WriteString(fmt.Sprintf(``, impression)) } - return fmt.Sprintf(`
%s%s
`, &clickEvent, richMediaAd.RichMedia.MediaData.Content, &impressionTracker), nil + richmediaAdMarkup := fmt.Sprintf(`
%s%s
`, + &clickEvent, richMediaAd.RichMedia.MediaData.Content, &impressionTracker) + + return richmediaAdMarkup, nil } diff --git a/adapters/smaato/richmedia_test.go b/adapters/smaato/richmedia_test.go index d1bfede80a1..eff559852be 100644 --- a/adapters/smaato/richmedia_test.go +++ b/adapters/smaato/richmedia_test.go @@ -1,53 +1,48 @@ package smaato import ( + "github.com/stretchr/testify/assert" "testing" ) func TestExtractAdmRichMedia(t *testing.T) { - type args struct { - adMarkup string - } tests := []struct { testName string - args args + adMarkup string expectedAdMarkup string expectedError string }{ - {"extract richmedia", - args{"{\"richmedia\":{\"mediadata\":{\"content\":\"
hello
\"," + + { + testName: "extract richmedia", + adMarkup: "{\"richmedia\":{\"mediadata\":{\"content\":\"
hello
\"," + "" + "\"w\":350," + "\"h\":50},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"]," + - "\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}"}, - `
hello
` + `
`, - "", + expectedError: "", }, - {"invalid adMarkup", - args{"{"}, - "", - "Invalid ad markup {.", + { + testName: "invalid adMarkup", + adMarkup: "{", + expectedAdMarkup: "", + expectedError: "Invalid ad markup {.", }, } for _, tt := range tests { t.Run(tt.testName, func(t *testing.T) { - adMarkup, err := extractAdmRichMedia(tt.args.adMarkup) + adMarkup, err := extractAdmRichMedia(tt.adMarkup) + if tt.expectedError != "" { - if err == nil { - t.Errorf("extractAdmRichMedia() expectedError %v", tt.expectedError) - } else if err.Error() != tt.expectedError { - t.Errorf("extractAdmRichMedia() err = %v, expectedError %v", err, tt.expectedError) - } - } else if err != nil { - t.Errorf("extractAdmRichMedia() unexpected err = %v", err) + assert.EqualError(t, err, tt.expectedError) + } else { + assert.NoError(t, err) } - if adMarkup != tt.expectedAdMarkup { - t.Errorf("extractAdmRichMedia() adMarkup = %v, expectedAdMarkup %v", adMarkup, tt.expectedAdMarkup) - } + assert.Equal(t, tt.expectedAdMarkup, adMarkup) }) } } diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 3d9eefe4f90..f4e3bd059b4 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -182,31 +182,24 @@ func (adapter *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidReques } func (adapter *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { - pods, orderedKeys := groupImpressionsByPod(request.Imp) + pods, orderedKeys, errors := groupImpressionsByPod(request.Imp) requests := make([]*adapters.RequestData, 0, len(pods)) - errors := make([]error, 0, len(request.Imp)) for _, key := range orderedKeys { - var adPodImpErrors []error - request.Imp, adPodImpErrors = filterPodImpressions(pods[key]) - if adPodImpErrors != nil { - errors = append(errors, adPodImpErrors...) - } - - if len(request.Imp) > 0 { - if err := preparePodRequest(request); err != nil { - errors = append(errors, err) - continue - } + request.Imp = pods[key] - requestData, err := adapter.makeRequest(request) - if err != nil { - errors = append(errors, err) - continue - } + if err := preparePodRequest(request); err != nil { + errors = append(errors, err) + continue + } - requests = append(requests, requestData) + requestData, err := adapter.makeRequest(request) + if err != nil { + errors = append(errors, err) + continue } + + requests = append(requests, requestData) } return requests, errors @@ -480,33 +473,24 @@ func setBannerDimension(banner *openrtb2.Banner) (*openrtb2.Banner, error) { return &bannerCopy, nil } -func groupImpressionsByPod(imps []openrtb2.Imp) (map[string]([]openrtb2.Imp), []string) { +func groupImpressionsByPod(imps []openrtb2.Imp) (map[string]([]openrtb2.Imp), []string, []error) { pods := make(map[string][]openrtb2.Imp) orderKeys := make([]string, 0) - - for _, imp := range imps { - pod := strings.Split(imp.ID, "_")[0] - _, present := pods[pod] - pods[pod] = append(pods[pod], imp) - if !present { - orderKeys = append(orderKeys, pod) - } - } - return pods, orderKeys -} - -func filterPodImpressions(imps []openrtb2.Imp) ([]openrtb2.Imp, []error) { - var n int errors := make([]error, 0, len(imps)) + for _, imp := range imps { if imp.Video == nil { errors = append(errors, &errortypes.BadInput{Message: "Invalid MediaType. Smaato only supports Video for AdPod."}) continue } - imps[n] = imp - n++ + + pod := strings.Split(imp.ID, "_")[0] + if _, present := pods[pod]; !present { + orderKeys = append(orderKeys, pod) + } + pods[pod] = append(pods[pod], imp) } - return imps[:n], errors + return pods, orderKeys, errors } func buildBidVideo(bid *openrtb2.Bid, bidType openrtb_ext.BidType) (*openrtb_ext.ExtBidPrebidVideo, error) { From 682056a30f3c019c172b6f3bddb17614127333ac Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Wed, 7 Jul 2021 19:17:06 +0200 Subject: [PATCH 11/14] Smaato: More PR fixes --- adapters/smaato/smaato.go | 25 +++++++++++-------------- adapters/smaato/smaato_test.go | 3 +++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index f4e3bd059b4..1951e5954d7 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -3,6 +3,10 @@ package smaato import ( "encoding/json" "fmt" + "net/http" + "strconv" + "strings" + "github.com/buger/jsonparser" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" @@ -11,9 +15,6 @@ import ( "github.com/prebid/prebid-server/metrics" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/util/timeutil" - "net/http" - "strconv" - "strings" ) const clientVersion = "prebid_server_0.3" @@ -312,8 +313,7 @@ func preparePodRequest(request *openrtb2.BidRequest) error { return err } - err := setImpForAdBreak(request.Imp) - return err + return setImpForAdBreak(request.Imp) } func setUser(request *openrtb2.BidRequest) error { @@ -332,19 +332,16 @@ func setUser(request *openrtb2.BidRequest) error { userCopy := *request.User - gender := userExt.Data.Gender - if gender != "" { - userCopy.Gender = gender + if userExt.Data.Gender != "" { + userCopy.Gender = userExt.Data.Gender } - yob := userExt.Data.Yob - if yob != 0 { - userCopy.Yob = yob + if userExt.Data.Yob != 0 { + userCopy.Yob = userExt.Data.Yob } - keywords := userExt.Data.Keywords - if keywords != "" { - userCopy.Keywords = keywords + if userExt.Data.Keywords != "" { + userCopy.Keywords = userExt.Data.Keywords } delete(userExtRaw, "data") diff --git a/adapters/smaato/smaato_test.go b/adapters/smaato/smaato_test.go index cd282697162..8a5f31228d6 100644 --- a/adapters/smaato/smaato_test.go +++ b/adapters/smaato/smaato_test.go @@ -93,6 +93,9 @@ func TestVideoWithCategoryAndDuration(t *testing.T) { if bidResponse.Bids[0].BidVideo.Duration != expectedBidDuration { t.Errorf("video duration should be set") } + if bidResponse.Bids[0].BidVideo.PrimaryCategory != expectedBidCategory { + t.Errorf("bid category should be set") + } if bidResponse.Bids[0].Bid.Cat[0] != expectedBidCategory { t.Errorf("bid category should be set") } From 33c3a7cf6957f1985b5683b192124bf58fee79b3 Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Tue, 13 Jul 2021 10:56:17 +0200 Subject: [PATCH 12/14] Smaato: Additional PR fixes --- adapters/smaato/smaato.go | 60 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 1951e5954d7..2fb4ba35a75 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -33,11 +33,7 @@ type SmaatoAdapter struct { endpoint string } -// userExt defines User.Ext object for Smaato -type userExt struct { - Data userExtData `json:"data"` -} - +// userExtData defines User.Ext.Data object for Smaato type userExtData struct { Keywords string `json:"keywords"` Gender string `json:"gender"` @@ -163,8 +159,8 @@ func (adapter *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidReques requests := make([]*adapters.RequestData, 0, len(imps)) errors := make([]error, 0, len(imps)) - for impIndex := range imps { - request.Imp = imps[impIndex : impIndex+1] + for _, imp := range imps { + request.Imp = []openrtb2.Imp{imp} if err := prepareIndividualRequest(request); err != nil { errors = append(errors, err) continue @@ -317,42 +313,46 @@ func preparePodRequest(request *openrtb2.BidRequest) error { } func setUser(request *openrtb2.BidRequest) error { - var err error - if request.User != nil && request.User.Ext != nil { - var userExt userExt var userExtRaw map[string]json.RawMessage - if err = json.Unmarshal(request.User.Ext, &userExtRaw); err != nil { + if err := json.Unmarshal(request.User.Ext, &userExtRaw); err != nil { return &errortypes.BadInput{Message: "Invalid user.ext."} } - if err = json.Unmarshal(request.User.Ext, &userExt); err != nil { - return &errortypes.BadInput{Message: "Invalid user.ext.data."} - } - userCopy := *request.User + if userExtDataRaw, present := userExtRaw["data"]; present { + var err error + var userExtData userExtData - if userExt.Data.Gender != "" { - userCopy.Gender = userExt.Data.Gender - } + if err = json.Unmarshal(userExtDataRaw, &userExtData); err != nil { + return &errortypes.BadInput{Message: "Invalid user.ext.data."} + } - if userExt.Data.Yob != 0 { - userCopy.Yob = userExt.Data.Yob - } + userCopy := *request.User - if userExt.Data.Keywords != "" { - userCopy.Keywords = userExt.Data.Keywords - } + if userExtData.Gender != "" { + userCopy.Gender = userExtData.Gender + } - delete(userExtRaw, "data") - if userCopy.Ext, err = json.Marshal(userExtRaw); err != nil { - return err - } + if userExtData.Yob != 0 { + userCopy.Yob = userExtData.Yob + } + + if userExtData.Keywords != "" { + userCopy.Keywords = userExtData.Keywords + } + + delete(userExtRaw, "data") - request.User = &userCopy + if userCopy.Ext, err = json.Marshal(userExtRaw); err != nil { + return err + } + + request.User = &userCopy + } } - return err + return nil } func setExt(request *openrtb2.BidRequest) error { From 67abd0dfa8b28ecc8a3b867f7173e21f5e1d14be Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Wed, 14 Jul 2021 08:26:24 +0200 Subject: [PATCH 13/14] Smaato: Rename adapter type --- adapters/smaato/smaato.go | 18 +++++++++--------- adapters/smaato/smaato_test.go | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 2fb4ba35a75..f891c1d14b4 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -27,8 +27,8 @@ const ( smtAdTypeVideo adMarkupType = "Video" ) -// SmaatoAdapter describes a Smaato prebid server adapter. -type SmaatoAdapter struct { +// adapter describes a Smaato prebid server adapter. +type adapter struct { clock timeutil.Time endpoint string } @@ -66,7 +66,7 @@ type videoExt struct { // Builder builds a new instance of the Smaato adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { - bidder := &SmaatoAdapter{ + bidder := &adapter{ clock: &timeutil.RealTime{}, endpoint: config.Endpoint, } @@ -74,7 +74,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (adapter *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{Message: "No impressions in bid request."}} } @@ -94,7 +94,7 @@ func (adapter *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo } // MakeBids unpacks the server's response into Bids. -func (adapter *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -153,7 +153,7 @@ func (adapter *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, ext return bidResponse, errors } -func (adapter *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { +func (adapter *adapter) makeIndividualRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { imps := request.Imp requests := make([]*adapters.RequestData, 0, len(imps)) @@ -178,7 +178,7 @@ func (adapter *SmaatoAdapter) makeIndividualRequests(request *openrtb2.BidReques return requests, errors } -func (adapter *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { +func (adapter *adapter) makePodRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { pods, orderedKeys, errors := groupImpressionsByPod(request.Imp) requests := make([]*adapters.RequestData, 0, len(pods)) @@ -202,7 +202,7 @@ func (adapter *SmaatoAdapter) makePodRequests(request *openrtb2.BidRequest) ([]* return requests, errors } -func (adapter *SmaatoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { +func (adapter *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { reqJSON, err := json.Marshal(request) if err != nil { return nil, err @@ -236,7 +236,7 @@ func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkup } } -func (adapter *SmaatoAdapter) getTTLFromHeaderOrDefault(response *adapters.ResponseData) int64 { +func (adapter *adapter) getTTLFromHeaderOrDefault(response *adapters.ResponseData) int64 { ttl := int64(300) if expiresAtMillis, err := strconv.ParseInt(response.Headers.Get("X-Smt-Expires"), 10, 64); err == nil { diff --git a/adapters/smaato/smaato_test.go b/adapters/smaato/smaato_test.go index 8a5f31228d6..0012bd6158d 100644 --- a/adapters/smaato/smaato_test.go +++ b/adapters/smaato/smaato_test.go @@ -21,15 +21,15 @@ func TestJsonSamples(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - smaatoAdapter, _ := bidder.(*SmaatoAdapter) - assert.NotNil(t, smaatoAdapter.clock) - smaatoAdapter.clock = &mockTime{time: time.Date(2021, 6, 25, 10, 00, 0, 0, time.UTC)} + adapter, _ := bidder.(*adapter) + assert.NotNil(t, adapter.clock) + adapter.clock = &mockTime{time: time.Date(2021, 6, 25, 10, 00, 0, 0, time.UTC)} adapterstest.RunJSONBidderTest(t, "smaatotest", bidder) } func TestVideoWithCategoryAndDuration(t *testing.T) { - bidder := &SmaatoAdapter{} + bidder := &adapter{} mockedReq := &openrtb2.BidRequest{ Imp: []openrtb2.Imp{{ From 8b6a3bcb52b09340d2100d5212d00b8baf91170e Mon Sep 17 00:00:00 2001 From: Bernhard Pickenbrock Date: Wed, 14 Jul 2021 16:48:44 +0200 Subject: [PATCH 14/14] Smaato: Add tests and check for empty imps --- adapters/smaato/smaato.go | 8 + .../supplemental/banner-w-and-h.json | 173 ++++++++++++++++ .../outdated-expires-header-response.json | 193 ++++++++++++++++++ 3 files changed, 374 insertions(+) create mode 100644 adapters/smaato/smaatotest/supplemental/banner-w-and-h.json create mode 100644 adapters/smaato/smaatotest/supplemental/outdated-expires-header-response.json diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index f891c1d14b4..c50efffc994 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -305,6 +305,10 @@ func prepareIndividualRequest(request *openrtb2.BidRequest) error { } func preparePodRequest(request *openrtb2.BidRequest) error { + if len(request.Imp) < 1 { + return &errortypes.BadInput{Message: "No impressions in bid request."} + } + if err := setPublisherId(request, &request.Imp[0]); err != nil { return err } @@ -436,6 +440,10 @@ func setImpForAdspace(imp *openrtb2.Imp) error { } func setImpForAdBreak(imps []openrtb2.Imp) error { + if len(imps) < 1 { + return &errortypes.BadInput{Message: "No impressions in bid request."} + } + adBreakID, err := jsonparser.GetString(imps[0].Ext, "bidder", "adbreakId") if err != nil { return &errortypes.BadInput{Message: "Missing adbreakId parameter."} diff --git a/adapters/smaato/smaatotest/supplemental/banner-w-and-h.json b/adapters/smaato/smaatotest/supplemental/banner-w-and-h.json new file mode 100644 index 00000000000..9e57c380d27 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/banner-w-and-h.json @@ -0,0 +1,173 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "w": 320, + "h": 50 + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320 + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.3" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\",\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 320, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 320, + "h": 50, + "exp": 300 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/outdated-expires-header-response.json b/adapters/smaato/smaatotest/supplemental/outdated-expires-header-response.json new file mode 100644 index 00000000000..c65e0824338 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/outdated-expires-header-response.json @@ -0,0 +1,193 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.3" + } + } + }, + "mockResponse": { + "status": 200, + "headers": { + "X-Smt-Expires": ["1524618800000"] + }, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\",\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file