From 70de1905b375ab0431ebb15e6085919fb051e788 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Mon, 5 Feb 2024 17:54:37 +0000 Subject: [PATCH 01/73] New Adapter: ResetDigital --- adapters/resetdigital/resetdigital.go | 260 ++++++++++++++++++ adapters/resetdigital/resetdigital_test.go | 87 ++++++ .../examplary/simple-banner.json | 87 ++++++ openrtb_ext/bidders.go | 2 + openrtb_ext/imp_resetdigital.go | 7 + 5 files changed, 443 insertions(+) create mode 100644 adapters/resetdigital/resetdigital.go create mode 100644 adapters/resetdigital/resetdigital_test.go create mode 100644 adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json create mode 100644 openrtb_ext/imp_resetdigital.go diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go new file mode 100644 index 00000000000..7e44bfd8607 --- /dev/null +++ b/adapters/resetdigital/resetdigital.go @@ -0,0 +1,260 @@ +package resetdigital + +import ( + "encoding/json" + "fmt" + "net/http" + "strconv" + "text/template" + + "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v2/adapters" + "github.com/prebid/prebid-server/v2/config" + "github.com/prebid/prebid-server/v2/openrtb_ext" +) + +// MaximumBids is the maximum number of bids that can be returned by this adapter. +const ( + MaxBids = 1 +) + +type adapter struct { + endpoint *template.Template + endpointUri string +} + +type resetDigitalRequest struct { + Site resetDigitalRequestSite `json:"site"` + Imps []resetDigitalRequesImps `json:"imps"` +} + +type resetDigitalRequestSite struct { + Domain string `json:"domain"` + Referrer string `json:"referrer"` +} + +type resetDigitalRequesImps struct { + ZoneID struct { + PlacementID string `json:"placementId"` + } `json:"zone_id"` + BidID string `json:"bid_id"` + ImpID string `json:"imp_id"` + Ext struct { + Gpid string `json:"gpid"` + } `json:"ext"` + Sizes [][]int64 `json:"sizes"` + MediaTypes struct { + Banner struct { + Sizes [][]int64 `json:"sizes"` + } `json:"banner"` + Video struct { + Sizes [][]int64 `json:"sizes"` + } `json:"video"` + } `json:"media_types"` +} + +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + template, err := template.New("endpointTemplate").Parse(config.Endpoint) + if err != nil { + return nil, fmt.Errorf("unable to parse endpoint url template: %v", err) + } + + bidder := &adapter{ + endpoint: template, + } + + return bidder, nil +} +func getHeaders(request *openrtb2.BidRequest) http.Header { + headers := http.Header{} + + if request.Device != nil && request.Site != nil { + addNonEmptyHeaders(&headers, map[string]string{ + "Referer": request.Site.Page, + "Accept-Language": request.Device.Language, + "User-Agent": request.Device.UA, + "X-Forwarded-For": request.Device.IP, + "X-Real-Ip": request.Device.IP, + "Content-Type": "application/json;charset=utf-8", + "Accept": "application/json", + }) + } + + return headers +} +func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) { + for key, value := range headerValues { + if len(value) > 0 { + headers.Add(key, value) + } + } +} + +func getReferer(request *openrtb2.BidRequest) string { + if request.Site == nil { + return "" + } + + return request.Site.Domain +} + +func getCurrency(request *openrtb2.BidRequest) string { + if len(request.Cur) == 0 { + return "USD" + } + + return request.Cur[0] +} + +func (a *adapter) MakeRequests(requestData *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var ( + requests []*adapters.RequestData + errors []error + ) + + referer := getReferer(requestData) + currency := getCurrency(requestData) + + if referer == currency { + return nil, nil + } + + for i := range requestData.Imp { + imp := requestData.Imp[i] + bidType, err := getBidType(imp) + + if err != nil { + errors = append(errors, err) + continue + } + + splittedRequestData := processDataFromRequest(requestData, imp, bidType) + + requestBody, err := json.Marshal(splittedRequestData) + if err != nil { + errors = append(errors, err) + continue + } + + requests = append(requests, &adapters.RequestData{ + Method: "POST", + Uri: a.endpointUri, + Body: requestBody, + Headers: getHeaders(requestData), + }) + } + + return requests, errors +} + +func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, bidType openrtb_ext.BidType) resetDigitalRequest { + + var resetDigitalRequestData resetDigitalRequest + resetDigitalRequestData.Site.Domain = requestData.Site.Domain + resetDigitalRequestData.Site.Referrer = requestData.Site.Page + + resetDigitalRequestData.Imps = append(resetDigitalRequestData.Imps, resetDigitalRequesImps{}) + resetDigitalRequestData.Imps[0].BidID = requestData.ID + resetDigitalRequestData.Imps[0].ImpID = imp.ID + + if bidType == openrtb_ext.BidTypeBanner { + resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes = append(resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes, []int64{imp.Banner.Format[0].W, imp.Banner.Format[0].H}) + } + if bidType == openrtb_ext.BidTypeVideo { + resetDigitalRequestData.Imps[0].MediaTypes.Video.Sizes = append(resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes, []int64{*imp.Video.W, *imp.Video.H}) + } + + return resetDigitalRequestData + +} + +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if response.StatusCode == http.StatusNoContent { + return nil, nil + } + if response.StatusCode == http.StatusBadRequest { + return nil, []error{fmt.Errorf("bad request")} + } + if response.StatusCode != http.StatusOK { + return nil, []error{fmt.Errorf("unexpected status code: %d", response.StatusCode)} + } + + if err := json.Unmarshal(response.Body, &response); err != nil { + return nil, []error{err} + } + bidResponse := adapters.NewBidderResponseWithBidsCapacity(MaxBids) + //check no bids + jsonData := make(map[string]interface{}) + + json.Unmarshal([]byte(response.Body), &jsonData) + //Always one bid + bid := getBidFromResponse(jsonData) + + bidType, err := getBidType(internalRequest.Imp[0]) + if err != nil { + // handle error + return nil, []error{err} + } + bidResponse.Currency = getCurrency(internalRequest) + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: bid, + BidType: bidType, + }) + + return bidResponse, nil +} + +func getBidFromResponse(requestData map[string]interface{}) *openrtb2.Bid { + processData := requestData["bids"].([]interface{})[0].(map[string]interface{}) + fmt.Printf("jsonData: %v\n", processData) + + bid := &openrtb2.Bid{ + ID: processData["bid_id"].(string), + Price: getBidPrice(processData), + ImpID: processData["imp_id"].(string), + CrID: processData["crid"].(string), + } + //if HTML is filled on jsonData then fill ADM with it + if value, ok := processData["html"].(string); ok { + bid.AdM = value + } + //if Width and Height are filled on jsonData then fill W and H with it + if value, ok := processData["w"].(string); ok { + + i, _ := strconv.ParseInt(value, 10, 64) + if i > 0 { + bid.W = i + } + } + if value, ok := processData["h"].(string); ok { + i, _ := strconv.ParseInt(value, 10, 64) + if i > 0 { + bid.H = i + } + } + //if Bid Price is 0 then return nil + if bid.Price == 0 { + return nil + } + + return bid +} + +func getBidPrice(requestData map[string]interface{}) float64 { + if value, ok := requestData["cpm"].(float64); ok { + return value + } + return 0.0 // Default value if "cpm" doesn't exist or is not a float64 +} + +func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { + if imp.Banner != nil { + return openrtb_ext.BidTypeBanner, nil + } else if imp.Video != nil { + return openrtb_ext.BidTypeVideo, nil + } else if imp.Audio != nil { + return openrtb_ext.BidTypeAudio, nil + } + + return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID) +} diff --git a/adapters/resetdigital/resetdigital_test.go b/adapters/resetdigital/resetdigital_test.go new file mode 100644 index 00000000000..e3307e916cf --- /dev/null +++ b/adapters/resetdigital/resetdigital_test.go @@ -0,0 +1,87 @@ +package resetdigital + +import ( + "encoding/json" + "net/http" + "testing" + + "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v2/adapters" + "github.com/stretchr/testify/assert" +) + +func TestMakeRequests(t *testing.T) { + bidder := new(adapter) + + request := &openrtb2.BidRequest{ + ID: "12345", + + Imp: []openrtb2.Imp{{ + ID: "001", + + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ + {W: 300, H: 250}, + }, + }, + Ext: json.RawMessage(``), + }}, + Site: &openrtb2.Site{ + Domain: "https://test.com", + Page: "https://test.com/2016/06/12", + }, + Cur: []string{"USD"}, + Device: &openrtb2.Device{ + UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + IP: "127.0.0.1", + Language: "EN", + }, + } + + reqs, errs := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) + + assert.Empty(t, errs, "Got unexpected errors while building HTTP requests: %v", errs) + assert.Equal(t, 1, len(reqs), "Unexpected number of HTTP requests. Got %d. Expected %d", len(reqs), 1) +} + +func TestMakeBids(t *testing.T) { + request := &openrtb2.BidRequest{ + ID: "test-request-id", + Imp: []openrtb2.Imp{{ + ID: "test-imp-id", + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ + W: 320, + H: 250, + }}, + }, + Ext: json.RawMessage(`{"bidder": { + "accountId": 2763, + "siteId": 68780, + "zoneId": 327642 + }}`), + }}, + Ext: json.RawMessage(``), + } + + requestJson, _ := json.Marshal(request) + reqData := &adapters.RequestData{ + Method: "POST", + Uri: "test-uri", + Body: requestJson, + Headers: nil, + } + + httpResp := &adapters.ResponseData{ + StatusCode: http.StatusOK, + Body: []byte(`{"bids":[{"bid_id":"01","imp_id":"001","cpm":10.00,"cid":"1002088","crid":"1000763-1002088","adid":"1002088","w":"300","h":"250","seat":"resetdigital","html":""}]}`), + } + + bidder := new(adapter) + bidResponse, errs := bidder.MakeBids(request, reqData, httpResp) + + assert.Empty(t, errs, "Expected 0 errors. Got %d", len(errs)) + + assert.Equal(t, float64(10), bidResponse.Bids[0].Bid.Price, + "Expected Price 10. Got: %s", bidResponse.Bids[0].Bid.Price) +} diff --git a/adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json new file mode 100644 index 00000000000..4e21c27015a --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json @@ -0,0 +1,87 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [ + { + "id": "001", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "placement_id": "111" + } + } + } + ], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [ + { + "language": "en-US", + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + }, + "imps": [ + { + "zone_id": { + "placementId": "test" + }, + "bid_id": "01", + "imp_id": "001", + "ext": { + "gpid": "test" + }, + "sizes": [ + [ + 300, + 250 + ] + ], + "media_types": { + "banner": { + "sizes": [ + [ + 300, + 250 + ] + ] + } + } + } + ] + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + } + ] + } + ] +} \ No newline at end of file From ece8152439a05b6625e27b25e81e3ba9573f3647 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Thu, 29 Aug 2024 15:52:32 +0100 Subject: [PATCH 20/73] Update with help of Xandr Team --- adapters/resetdigital/resetdigital.go | 244 +++++++++--------- .../exemplary/simple-banner.json | 150 ++++++----- openrtb_ext/imp_resetdigital.go | 5 +- 3 files changed, 198 insertions(+), 201 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 5d44ac092d2..bca84364e8c 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -22,34 +22,49 @@ type adapter struct { } type resetDigitalRequest struct { - Site resetDigitalRequestSite `json:"site"` - Imps []resetDigitalRequestImps `json:"imps"` + Site resetDigitalSite `json:"site"` + Imps []resetDigitalImp `json:"imps"` } - -type resetDigitalRequestSite struct { +type resetDigitalSite struct { Domain string `json:"domain"` Referrer string `json:"referrer"` } +type resetDigitalImp struct { + ForceBid bool `json:"force_bid"` + ZoneID resetDigitalImpZone `json:"zone_id"` + BidID string `json:"bid_id"` + ImpID string `json:"imp_id"` + Ext resetDigitalImpExt `json:"ext"` + MediaTypes resetDigitalMediaTypes `json:"media_types"` +} +type resetDigitalImpZone struct { + PlacementID string `json:"placementId"` +} +type resetDigitalImpExt struct { + Gpid string `json:"gpid"` +} +type resetDigitalMediaTypes struct { + Banner resetDigitalMediaType `json:"banner"` + Video resetDigitalMediaType `json:"video"` +} +type resetDigitalMediaType struct { + Sizes [][]int64 `json:"sizes"` +} -type resetDigitalRequestImps struct { - ForceBid bool `json:"force_bid"` - ZoneID struct { - PlacementID string `json:"placementId"` - } `json:"zone_id"` - BidID string `json:"bid_id"` - ImpID string `json:"imp_id"` - Ext struct { - Gpid string `json:"gpid"` - } `json:"ext"` - Sizes [][]int64 `json:"sizes"` - MediaTypes struct { - Banner struct { - Sizes [][]int64 `json:"sizes"` - } `json:"banner"` - Video struct { - Sizes [][]int64 `json:"sizes"` - } `json:"video"` - } `json:"media_types"` +type resetDigitalBidResponse struct { + Bids []resetDigitalBid `json:"bids"` +} +type resetDigitalBid struct { + BidID string `json:"bid_id"` + ImpID string `json:"imp_id"` + CPM float64 `json:"cpm"` + CID string `json:"cid,omitempty"` + CrID string `json:"crid,omitempty"` + AdID string `json:"adid"` + W string `json:"w,omitempty"` + H string `json:"h,omitempty"` + Seat string `json:"seat"` + HTML string `json:"html"` } func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { @@ -57,17 +72,16 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co if err != nil { return nil, fmt.Errorf("unable to parse endpoint url template: %v", err) } - bidder := &adapter{ endpoint: template, } - return bidder, nil } + func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} - if request.Device != nil && request.Site != nil { + if request != nil && request.Device != nil && request.Site != nil { addNonEmptyHeaders(&headers, map[string]string{ "Referer": request.Site.Page, "Accept-Language": request.Device.Language, @@ -78,9 +92,9 @@ func getHeaders(request *openrtb2.BidRequest) http.Header { "Accept": "application/json", }) } - return headers } + func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) { for key, value := range headerValues { if len(value) > 0 { @@ -89,23 +103,13 @@ func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) { } } -func getCurrency(request *openrtb2.BidRequest) string { - if len(request.Cur) == 0 { - return "USD" - } - - return request.Cur[0] -} - func (a *adapter) MakeRequests(requestData *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var ( requests []*adapters.RequestData errors []error ) - for i := range requestData.Imp { - imp := requestData.Imp[i] - + for _, imp := range requestData.Imp { bidType, err := getBidType(imp) if err != nil { errors = append(errors, err) @@ -132,145 +136,133 @@ func (a *adapter) MakeRequests(requestData *openrtb2.BidRequest, requestInfo *ad ImpIDs: []string{imp.ID}, }) } - //clear requests.body return requests, errors } func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, bidType openrtb_ext.BidType) (resetDigitalRequest, error) { - var resetDigitalRequestData resetDigitalRequest + var reqData resetDigitalRequest - // Check if requestData.Site is not nil before accessing its fields if requestData.Site != nil { - resetDigitalRequestData.Site.Domain = requestData.Site.Domain - resetDigitalRequestData.Site.Referrer = requestData.Site.Page - + reqData.Site.Domain = requestData.Site.Domain + reqData.Site.Referrer = requestData.Site.Page } - resetDigitalRequestData.Imps = append(resetDigitalRequestData.Imps, resetDigitalRequestImps{ + reqData.Imps = append(reqData.Imps, resetDigitalImp{ BidID: requestData.ID, ImpID: imp.ID, }) - if bidType == openrtb_ext.BidTypeBanner { - if imp.Banner != nil { - var tempH int64 = *imp.Banner.H - var tempW int64 = *imp.Banner.W - - if tempH > 0 && tempW > 0 { - resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes = append( - resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes, - []int64{tempH, tempW}, - ) - } + if bidType == openrtb_ext.BidTypeBanner && imp.Banner != nil { + tempH := *imp.Banner.H + tempW := *imp.Banner.W + if tempH > 0 && tempW > 0 { + reqData.Imps[0].MediaTypes.Banner.Sizes = append( + reqData.Imps[0].MediaTypes.Banner.Sizes, + []int64{tempH, tempW}, + ) } } - - if bidType == openrtb_ext.BidTypeVideo { - if imp.Video != nil { - var tempH int64 = *imp.Video.H - var tempW int64 = *imp.Video.W - - if tempH > 0 && tempW > 0 { - resetDigitalRequestData.Imps[0].MediaTypes.Video.Sizes = append( - resetDigitalRequestData.Imps[0].MediaTypes.Video.Sizes, - []int64{tempH, tempW}, - ) - } + if bidType == openrtb_ext.BidTypeVideo && imp.Video != nil { + tempH := *imp.Video.H + tempW := *imp.Video.W + + if tempH > 0 && tempW > 0 { + reqData.Imps[0].MediaTypes.Video.Sizes = append( + reqData.Imps[0].MediaTypes.Video.Sizes, + []int64{tempH, tempW}, + ) } } - var extData = make(map[string]interface{}) - err := json.Unmarshal(imp.Ext, &extData) - if err != nil { + + var bidderExt adapters.ExtImpBidder + var resetDigitalExt openrtb_ext.ImpExtResetDigital + + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return resetDigitalRequest{}, err } + if err := json.Unmarshal(bidderExt.Bidder, &resetDigitalExt); err != nil { + return resetDigitalRequest{}, err + } + reqData.Imps[0].ZoneID.PlacementID = resetDigitalExt.PlacementID - resetDigitalRequestData.Imps[0].ZoneID.PlacementID = extData["bidder"].(map[string]interface{})["placement_id"].(string) - - return resetDigitalRequestData, nil + return reqData, nil } -func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if adapters.IsResponseStatusCodeNoContent(response) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } - if err := adapters.CheckResponseStatusCodeForErrors(response); err != nil { + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { return nil, []error{err} } - var bidResp map[string]interface{} - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + var response resetDigitalBidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } - bidResponse := adapters.NewBidderResponseWithBidsCapacity(maxBids) - jsonData := bidResp["bids"].([]interface{}) + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + + requestImps := make(map[string]openrtb2.Imp) + for _, imp := range request.Imp { + requestImps[imp.ID] = imp + } - for _, bidData := range jsonData { - bidMap := bidData.(map[string]interface{}) - bid := getBidFromResponse(bidMap) + for i := range response.Bids { + resetDigitalBid := &response.Bids[i] + + bid := getBidFromResponse(resetDigitalBid) if bid == nil { continue } - bidTypes, err := getBidTypes(internalRequest.Imp[0]) + bidType, err := GetMediaTypeForImp(requestImps, bid.ImpID) if err != nil { return nil, []error{err} } - for _, bidType := range bidTypes { - bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: bid, - BidType: bidType, - }) + b := &adapters.TypedBid{ + Bid: bid, + BidType: bidType, + Seat: openrtb_ext.BidderName(resetDigitalBid.Seat), } + bidResponse.Bids = append(bidResponse.Bids, b) + } + + if len(request.Cur) == 0 { + bidResponse.Currency = "USD" } - bidResponse.Currency = getCurrency(internalRequest) return bidResponse, nil } -func getBidFromResponse(requestData map[string]interface{}) *openrtb2.Bid { - processData := requestData["bid_id"].(string) - - bid := &openrtb2.Bid{ - ID: processData, - Price: getBidPrice(requestData), - ImpID: requestData["imp_id"].(string), - CrID: requestData["crid"].(string), - } - if value, ok := requestData["html"].(string); ok { - bid.AdM = value +func getBidFromResponse(bidResponse *resetDigitalBid) *openrtb2.Bid { + if bidResponse.CPM == 0 { + return nil } - if value, ok := requestData["w"].(string); ok { - if i, err := strconv.ParseInt(value, 10, 64); err == nil && i > 0 { - bid.W = i - } + bid := &openrtb2.Bid{ + ID: bidResponse.BidID, + Price: bidResponse.CPM, + ImpID: bidResponse.ImpID, + CID: bidResponse.CID, + CrID: bidResponse.CrID, + AdM: bidResponse.HTML, } - if value, ok := requestData["h"].(string); ok { - if i, err := strconv.ParseInt(value, 10, 64); err == nil && i > 0 { - bid.H = i - } + if i, err := strconv.ParseInt(bidResponse.W, 10, 64); err == nil && i > 0 { + bid.W = i } - - if bid.Price == 0 { - return nil + if i, err := strconv.ParseInt(bidResponse.H, 10, 64); err == nil && i > 0 { + bid.H = i } return bid } -func getBidPrice(requestData map[string]interface{}) float64 { - if value, ok := requestData["cpm"].(float64); ok { - return value - } - return 0.0 // Default value if "cpm" doesn't exist or is not a float64 -} - func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { if imp.Banner != nil { return openrtb_ext.BidTypeBanner, nil @@ -301,3 +293,15 @@ func getBidTypes(imp openrtb2.Imp) ([]openrtb_ext.BidType, error) { return bidTypes, nil } + +func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openrtb_ext.BidType, error) { + mediaType := openrtb_ext.BidTypeBanner + + if reqImp, ok := reqImps[bidImpID]; ok { + if reqImp.Banner == nil && reqImp.Video != nil { + mediaType = openrtb_ext.BidTypeVideo + } + return mediaType, nil + } + return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID) +} diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index 8d4e0adb1d0..f526cc86290 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -1,22 +1,20 @@ { "mockBidRequest": { "id": "12345", - "imp": [ - { - "id": "001", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "placement_id": "test" - } + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" } } - ], + }], "site": { - "domain": "test.com", + "domain": "https://test.com", "page": "https://test.com/2016/06/12" }, "cur": [ @@ -29,69 +27,47 @@ }, "tmax": 500 }, - "httpCalls": [ - { - "expectedRequest": { - "method": "POST", - "body": { - "id": "12345", - "imp": [ - { - "id": "001", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "placement_id": "test" - } - } - } - ], - "site": { - "domain": "test.com", - "page": "https://test.com/2016/06/12" - }, - "cur": [ - "USD" - ], - "device": { - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - "ip": "127.0.0.1", - "language": "EN" + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" }, - "tmax": 500 - }, - "impIDs": [ - "001" - ] - }, - "mockResponse": { - "status": 200, - "body": { - "bids": [ - { - "bid_id": "01", - "imp_id": "001", - "cpm": 1.00, - "cid": "1002088", - "crid": "1000763-1002088", - "adid": "1002088", - "w": "300", - "h": "250", - "seat": "resetdigital", - "html": "" + "force_bid": false, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 300, + 250 + ] + ] + }, + "video": { + "sizes": null } - ] + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" } - } - } - ], - "expectedBidResponses": [ - { - "bids": [ - { + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ "bid_id": "01", "imp_id": "001", "cpm": 1.00, @@ -101,9 +77,27 @@ "w": "300", "h": "250", "seat": "resetdigital", - "html": "" - } - ] + "html": "" + }] + } } - ] -} \ No newline at end of file + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 300, + "h": 250 + }, + "type": "banner", + "seat": "resetdigital" + }] + }] +} diff --git a/openrtb_ext/imp_resetdigital.go b/openrtb_ext/imp_resetdigital.go index b9e2ac8297b..6e3f800ab98 100644 --- a/openrtb_ext/imp_resetdigital.go +++ b/openrtb_ext/imp_resetdigital.go @@ -1,6 +1,5 @@ package openrtb_ext -type ExtResetDigital struct { - BidID string `json:"bid_id"` - ImpID string `json:"imp_id"` +type ImpExtResetDigital struct { + PlacementID string `json:"placement_id"` } From baa553c3646faf043d7db5e693b59fafc427b150 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Thu, 29 Aug 2024 16:09:40 +0100 Subject: [PATCH 21/73] Simplify Tests --- adapters/resetdigital/resetdigital_test.go | 86 ---------------------- 1 file changed, 86 deletions(-) diff --git a/adapters/resetdigital/resetdigital_test.go b/adapters/resetdigital/resetdigital_test.go index 12f2dc09e17..d160e9a23fe 100644 --- a/adapters/resetdigital/resetdigital_test.go +++ b/adapters/resetdigital/resetdigital_test.go @@ -1,16 +1,11 @@ package resetdigital import ( - "encoding/json" - "net/http" "testing" - "github.com/prebid/openrtb/v20/openrtb2" - "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/adapters/adapterstest" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" - "github.com/stretchr/testify/assert" ) func TestJsonSamples(t *testing.T) { @@ -24,84 +19,3 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "resetdigitaltest", bidder) } - -func TestMakeRequests(t *testing.T) { - bidder := new(adapter) - - request := &openrtb2.BidRequest{ - ID: "12345", - - Imp: []openrtb2.Imp{{ - ID: "001", - Banner: &openrtb2.Banner{ - Format: []openrtb2.Format{ - {W: 300, H: 250}, - }, - }, - - Ext: json.RawMessage(`{"bidder": {"placement_id": "test"}}`), //Placement_id test is used to get the force bid true - }}, - Site: &openrtb2.Site{ - Domain: "https://test.com", - Page: "https://test.com/2016/06/12", - }, - Cur: []string{"USD"}, - Device: &openrtb2.Device{ - UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - IP: "127.0.0.1", - Language: "EN", - }, - } - - reqs, errs := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) - - assert.Empty(t, errs, "Got unexpected errors while building HTTP requests: %v", errs) - assert.Equal(t, 1, len(reqs), "Unexpected number of HTTP requests. Got %d. Expected %d", len(reqs), 1) -} - -func TestMakeBids(t *testing.T) { - request := &openrtb2.BidRequest{ - ID: "12345", - - Imp: []openrtb2.Imp{{ - ID: "001", - Banner: &openrtb2.Banner{ - Format: []openrtb2.Format{ - {W: 300, H: 250}, - }, - }, - - Ext: json.RawMessage(`{"bidder": {"placement_id": "test"}}`), //Placement_id test is used to get the force bid true - }}, - Site: &openrtb2.Site{ - Domain: "https://test.com", - Page: "https://test.com/2016/06/12", - }, - Cur: []string{"USD"}, - Device: &openrtb2.Device{ - UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - IP: "127.0.0.1", - Language: "EN", - }, - } - - requestJson, _ := json.Marshal(request) - reqData := &adapters.RequestData{ - Method: "POST", - Uri: "test-uri", - Body: requestJson, - } - - httpResp := &adapters.ResponseData{ - StatusCode: http.StatusOK, - Body: []byte(`{"bids":[{"bid_id":"01","imp_id":"001","cpm":10.00,"cid":"1002088","crid":"1000763-1002088","adid":"1002088","w":"300","h":"250","seat":"resetdigital","html":""}]}`), - } - - bidder := new(adapter) - bidResponse, errs := bidder.MakeBids(request, reqData, httpResp) - - assert.Empty(t, errs, "Expected 0 errors. Got %d", len(errs)) - - assert.Equal(t, float64(10), bidResponse.Bids[0].Bid.Price, - "Expected Price 10. Got: %s", bidResponse.Bids[0].Bid.Price) -} From ecc90bb8773699cc10e71495d3c527b80bd3af6d Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Tue, 10 Sep 2024 11:18:03 +0100 Subject: [PATCH 22/73] PR of functioning version --- adapters/resetdigital/resetdigital.go | 72 +++++++++---------- .../exemplary/simple-banner.json | 5 +- static/bidder-info/resetdigital.yaml | 35 +++++---- static/bidder-params/resetdigital.json | 12 +++- 4 files changed, 60 insertions(+), 64 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index bca84364e8c..70b73c5ac6d 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -13,9 +13,6 @@ import ( "github.com/prebid/prebid-server/v2/openrtb_ext" ) -// MaximumBids is the maximum number of bids that can be returned by this adapter. -const maxBids = 1 - type adapter struct { endpoint *template.Template endpointUri string @@ -30,7 +27,6 @@ type resetDigitalSite struct { Referrer string `json:"referrer"` } type resetDigitalImp struct { - ForceBid bool `json:"force_bid"` ZoneID resetDigitalImpZone `json:"zone_id"` BidID string `json:"bid_id"` ImpID string `json:"imp_id"` @@ -81,7 +77,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} - if request != nil && request.Device != nil && request.Site != nil { + if request != nil && request.Device != nil && request.Site != nil { // what about request.App? Do we need to do something different with Referrer in the app case assuming we care about app? addNonEmptyHeaders(&headers, map[string]string{ "Referer": request.Site.Page, "Accept-Language": request.Device.Language, @@ -154,24 +150,32 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, }) if bidType == openrtb_ext.BidTypeBanner && imp.Banner != nil { - tempH := *imp.Banner.H - tempW := *imp.Banner.W - + var tempH, tempW int64 + if imp.Banner.H != nil { + tempH = *imp.Banner.H + } + if imp.Banner.W != nil { + tempW = *imp.Banner.W + } if tempH > 0 && tempW > 0 { reqData.Imps[0].MediaTypes.Banner.Sizes = append( reqData.Imps[0].MediaTypes.Banner.Sizes, - []int64{tempH, tempW}, + []int64{tempW, tempH}, ) } } if bidType == openrtb_ext.BidTypeVideo && imp.Video != nil { - tempH := *imp.Video.H - tempW := *imp.Video.W - + var tempH, tempW int64 + if imp.Video.H != nil { + tempH = *imp.Video.H + } + if imp.Video.W != nil { + tempW = *imp.Video.W + } if tempH > 0 && tempW > 0 { reqData.Imps[0].MediaTypes.Video.Sizes = append( reqData.Imps[0].MediaTypes.Video.Sizes, - []int64{tempH, tempW}, + []int64{tempW, tempH}, ) } } @@ -206,6 +210,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + var errs []error requestImps := make(map[string]openrtb2.Imp) for _, imp := range request.Imp { requestImps[imp.ID] = imp @@ -214,8 +219,10 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R for i := range response.Bids { resetDigitalBid := &response.Bids[i] - bid := getBidFromResponse(resetDigitalBid) + bid, err := getBidFromResponse(resetDigitalBid) + // handle the error if bid == nil { + // it would be better to return an error here continue } @@ -236,12 +243,13 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse.Currency = "USD" } - return bidResponse, nil + return bidResponse, errs } -func getBidFromResponse(bidResponse *resetDigitalBid) *openrtb2.Bid { +func getBidFromResponse(bidResponse *resetDigitalBid) (*openrtb2.Bid, error) { if bidResponse.CPM == 0 { - return nil + // brian to check how to report this + return nil, nil } bid := &openrtb2.Bid{ @@ -255,12 +263,17 @@ func getBidFromResponse(bidResponse *resetDigitalBid) *openrtb2.Bid { if i, err := strconv.ParseInt(bidResponse.W, 10, 64); err == nil && i > 0 { bid.W = i - } + } else if err != nil { + return nil, err + } // the error should be returned here if ParseInt fails + if i, err := strconv.ParseInt(bidResponse.H, 10, 64); err == nil && i > 0 { bid.H = i - } + } else if err != nil { + return nil, err + } // the error should be returned here if ParseInt fails - return bid + return bid, nil } func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { @@ -275,25 +288,6 @@ func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID) } -func getBidTypes(imp openrtb2.Imp) ([]openrtb_ext.BidType, error) { - var bidTypes []openrtb_ext.BidType - - if imp.Banner != nil { - bidTypes = append(bidTypes, openrtb_ext.BidTypeBanner) - } - if imp.Video != nil { - bidTypes = append(bidTypes, openrtb_ext.BidTypeVideo) - } - if imp.Audio != nil { - bidTypes = append(bidTypes, openrtb_ext.BidTypeAudio) - } - if len(bidTypes) == 0 { - return nil, fmt.Errorf("failed to find matching imp for bid %s", imp.ID) - } - - return bidTypes, nil -} - func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index f526cc86290..bf22010c6fd 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -36,14 +36,13 @@ "ext": { "gpid": "" }, - "force_bid": false, "imp_id": "001", "media_types": { "banner": { "sizes": [ [ - 300, - 250 + 250, + 300 ] ] }, diff --git a/static/bidder-info/resetdigital.yaml b/static/bidder-info/resetdigital.yaml index 99c22378318..3c4a206389a 100644 --- a/static/bidder-info/resetdigital.yaml +++ b/static/bidder-info/resetdigital.yaml @@ -1,19 +1,16 @@ - endpoint: http://b-us-east14.resetdigital.co:9001 - meta-info: - maintainer-email: biddersupport@resetdigital.co - app-media-types: - - banner - - video - - audio - site-media-types: - - banner - - video - - audio - supported-vendors: - vendor-id: 1162 - usersync: - cookie-family-name: resetdigital - redirect: - url: https://sync.resetdigital.co/csync?pid=rubicon&redir={{redirect_url}} - support-cors: false - uid-macro: '$USER_ID' +endpoint: http://b-us-east14.resetdigital.co:9001 +maintainer: + email: biddersupport@resetdigital.co +capabilities: + site: + mediaTypes: + - banner + - video + - audio +gvlVendorID: 1162 +userSync: + key: resetdigital + supportCors: false + redirect: + url: https://sync.resetdigital.co/csync?pid=rubicon&redir={{redirect_url}} + userMacro: '$USER_ID' diff --git a/static/bidder-params/resetdigital.json b/static/bidder-params/resetdigital.json index d2bcfb6bb5f..4d0538893f7 100644 --- a/static/bidder-params/resetdigital.json +++ b/static/bidder-params/resetdigital.json @@ -1,7 +1,13 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Relevant Digital Adapter Params", - "description": "A schema which validates params accepted by the Relevant Digital adapter", + "title": "Reset Digital Adapter Params", + "description": "A schema which validates params accepted by the Reset Digital adapter", "type": "object", - "properties": {} + "properties": { + "placement_id": { + "type": "string", + "minLength": 1, + "description": "Placement ID for the Reset Digital ad unit. This is the identifier for the ad unit on the Reset Digital platform, and its optional" + } + } } From 0d54a8d13f7a652fc10815bd7efcc8bfa3ce36d2 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Sun, 29 Sep 2024 20:07:47 +0100 Subject: [PATCH 23/73] Added Video and removed unwanted data --- .../examplary/test-missing-cur.json | 86 ------------- .../examplary/test-missing-site.json | 64 ---------- .../examplary/test-multi-format.json | 119 ------------------ .../examplary/test-request-error.json | 74 ----------- .../exemplary/simple-video.json | 106 ++++++++++++++++ 5 files changed, 106 insertions(+), 343 deletions(-) delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-missing-site.json delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-multi-format.json delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-request-error.json create mode 100644 adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json diff --git a/adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json b/adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json deleted file mode 100644 index 5b997219cc6..00000000000 --- a/adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "mockBidRequest": { - "id": "12345", - "imp": [ - { - "id": "001", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "placement_id": "test" - } - } - } - ], - "site": { - "domain": "https://test.com", - "page": "https://test.com/2016/06/12" - }, - "cur": [], - "device": { - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - "ip": "127.0.0.1", - "language": "EN" - }, - "tmax": 500 - }, - "httpCalls": [ - { - "language": "en-US", - "site": { - "domain": "https://test.com", - "referrer": "https://test.com/2016/06/12" - }, - "imps": [ - { - "force_bid": 1, - "zone_id": { - "placementId": "test" - }, - "bid_id": "01", - "imp_id": "001", - "ext": { - "gpid": "test" - }, - "sizes": [ - [ - 300, - 250 - ] - ], - "media_types": { - "banner": { - "sizes": [ - [ - 300, - 250 - ] - ] - } - } - } - ] - } - ], - "expectedBidResponses": [ - { - "bids": [ - { - "bid_id": "01", - "imp_id": "001", - "cpm": 1.0, - "cid": "1002088", - "crid": "1000763-1002088", - "adid": "1002088", - "w": "300", - "h": "250", - "seat": "resetdigital", - "html": "" + }] + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 900, + "h": 250 + }, + "type": "video", + "seat": "resetdigital" + }] + }] +} From 660dba7dc71bd46177807ed4ae5e88405c480cbf Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 25 Oct 2024 12:12:54 +0100 Subject: [PATCH 24/73] created mock test --- adapters/resetdigital/resetdigital.go | 23 ++-- .../exemplary/invalid_video_dim.json | 74 ++++++++++++ .../supplemental/fake_test.json | 69 +++++++++++ .../supplemental/invalid-device.json | 74 ++++++++++++ .../supplemental/invalid_cur.json | 76 ++++++++++++ .../supplemental/invalid_media_def.json | 35 ++++++ .../supplemental/invalid_placement_id.json | 43 +++++++ .../supplemental/multi_format.json | 108 ++++++++++++++++++ .../supplemental/unknown_media.json | 68 +++++++++++ 9 files changed, 559 insertions(+), 11 deletions(-) create mode 100644 adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 70b73c5ac6d..6ea7faf566f 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -223,12 +223,14 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R // handle the error if bid == nil { // it would be better to return an error here + errs = append(errs, err) continue } bidType, err := GetMediaTypeForImp(requestImps, bid.ImpID) if err != nil { - return nil, []error{err} + errs = append(errs, err) + continue } b := &adapters.TypedBid{ @@ -261,18 +263,17 @@ func getBidFromResponse(bidResponse *resetDigitalBid) (*openrtb2.Bid, error) { AdM: bidResponse.HTML, } - if i, err := strconv.ParseInt(bidResponse.W, 10, 64); err == nil && i > 0 { - bid.W = i - } else if err != nil { + w, err := strconv.ParseInt(bidResponse.W, 10, 64) + if err != nil { return nil, err - } // the error should be returned here if ParseInt fails + } + bid.W = w - if i, err := strconv.ParseInt(bidResponse.H, 10, 64); err == nil && i > 0 { - bid.H = i - } else if err != nil { + h, err := strconv.ParseInt(bidResponse.H, 10, 64) + if err != nil { return nil, err - } // the error should be returned here if ParseInt fails - + } + bid.H = h return bid, nil } @@ -298,4 +299,4 @@ func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openr return mediaType, nil } return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID) -} +} \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json b/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json new file mode 100644 index 00000000000..6cbc6cf2be8 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json @@ -0,0 +1,74 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "video": { + "w": 0, + "h": 480, + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500, + "debug": 1 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": null + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 204, + "body": { + "error": "Unexpected status code: 204. Run with request.debug = 1 for more info" + } + } + }], + "expectedBidResponses": [] + } diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json b/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json new file mode 100644 index 00000000000..7cb52868e6c --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json @@ -0,0 +1,69 @@ +{ + "mockBidRequest": { + "id": "test_nil_invalid_impid", + "imp": [ + { + "id": null, + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-7" + } + } + } + ], + "site": { + "domain": "https://example.com", + "page": "https://example.com/page" + }, + "cur": ["USD"], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", + "ip": "192.168.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [ + { + "expectedRequest": { + "method": "POST", + "body": { + "imps": [ + { + "bid_id": "test_nil_invalid_impid", + "imp_id": null, + "media_types": { + "banner": { + "sizes": [[300, 250]] + } + }, + "zone_id": { + "placementId": "placement-id-7" + } + } + ], + "site": { + "domain": "https://example.com", + "referrer": "https://example.com/page" + } + }, + "impIDs": ["006", null, "unknown_imp_id"] + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "bid is nil or imp ID is missing", + "comparison": "literal" + }, + { + "value": "unknown media type for bid imp ID unknown_imp_id", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json new file mode 100644 index 00000000000..6865ffc355c --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json @@ -0,0 +1,74 @@ +{ + "mockBidRequest": { + "id": "test-invalid-device", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ] + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-invalid-device", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 400, + "body": { + "error": "Unexpected status code: 400. Run with request.debug = 1 for more info" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json new file mode 100644 index 00000000000..d148516b1c2 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json @@ -0,0 +1,76 @@ +{ + "mockBidRequest": { + "id": "test-invalid-cur", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + } + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-invalid-cur", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 400, + "body": { + "error": "Unexpected status code: 400. Run with request.debug = 1 for more info" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json new file mode 100644 index 00000000000..0c24e666b9f --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json @@ -0,0 +1,35 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500, + "debug": 1 + }, + "httpCalls": [], + "expectedMakeRequestsErrors": [ + { + "value": "failed to find matching imp for bid 001", + "comparison": "literal" + } + ], + "expectedBidResponses": [] + } \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json new file mode 100644 index 00000000000..14959b36d14 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json @@ -0,0 +1,43 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "video": { + "w": 900, + "h": 250, + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "ext": { + "bidder": { + "placement_id": 1 + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500, + "debug": 1 + }, + "httpCalls": [], + "expectedMakeRequestsErrors": [ + { + "value": "json: cannot unmarshal number into Go struct field ImpExtResetDigital.placement_id of type string", + "comparison": "literal" + } + ], + "expectedBidResponses": [] + } diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json new file mode 100644 index 00000000000..f17e0d149ab --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json @@ -0,0 +1,108 @@ +{ + "mockBidRequest": { + "id": "test-multi-format", + "imp": [{ + "id": "001", + "banner": { + "w": 300, + "h": 600 + }, + "video": { + "w": 900, + "h": 250, + "mimes": ["video/mp4"] + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-multi-format", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 300, + 600 + ] + ] + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + }] + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 300, + "h": 250 + }, + "type": "banner", + "seat": "resetdigital" + }] + }] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json new file mode 100644 index 00000000000..08cd3f22944 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json @@ -0,0 +1,68 @@ +{ + "mockBidRequest": { + "id": "test-unknown-media-type", + "imp": [{ + "id": "001", + "audio": { + "mimes": ["audio/mpeg"] + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ] + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-unknown-media-type", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": null + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 400, + "body": { + "error": "unknown media type for bid imp ID 003" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] + } + \ No newline at end of file From 5f70f11ed1138b1a2e658b0b7e3ce8f2a2f26787 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Thu, 31 Oct 2024 15:35:08 +0100 Subject: [PATCH 25/73] delete fake_test.json --- .../supplemental/fake_test.json | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json b/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json deleted file mode 100644 index 7cb52868e6c..00000000000 --- a/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "mockBidRequest": { - "id": "test_nil_invalid_impid", - "imp": [ - { - "id": null, - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "placement_id": "placement-id-7" - } - } - } - ], - "site": { - "domain": "https://example.com", - "page": "https://example.com/page" - }, - "cur": ["USD"], - "device": { - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", - "ip": "192.168.0.1", - "language": "EN" - }, - "tmax": 500 - }, - "httpCalls": [ - { - "expectedRequest": { - "method": "POST", - "body": { - "imps": [ - { - "bid_id": "test_nil_invalid_impid", - "imp_id": null, - "media_types": { - "banner": { - "sizes": [[300, 250]] - } - }, - "zone_id": { - "placementId": "placement-id-7" - } - } - ], - "site": { - "domain": "https://example.com", - "referrer": "https://example.com/page" - } - }, - "impIDs": ["006", null, "unknown_imp_id"] - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "bid is nil or imp ID is missing", - "comparison": "literal" - }, - { - "value": "unknown media type for bid imp ID unknown_imp_id", - "comparison": "literal" - } - ] - } - \ No newline at end of file From a083c0326961917b7c52a9e0fdc4a0f7b9d6e0a5 Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Sun, 3 Nov 2024 15:26:36 -0800 Subject: [PATCH 26/73] Adding support for audio media type and a corresponding simple-audio.json test case. --- -vv | 78 ++++++++ adapters/resetdigital/resetdigital.go | 17 +- .../exemplary/simple-audio.json | 183 ++++++++++++++++++ .../exemplary/simple-banner.json | 6 + .../exemplary/simple-video.json | 170 +++++++++------- .../supplemental/invalid-device.json | 6 + .../supplemental/invalid_cur.json | 6 + .../invalid_video_dim.json | 11 +- .../supplemental/multi_format.json | 6 + .../supplemental/unknown_media.json | 8 +- 10 files changed, 412 insertions(+), 79 deletions(-) create mode 100644 -vv create mode 100644 adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json rename adapters/resetdigital/resetdigitaltest/{exemplary => supplemental}/invalid_video_dim.json (86%) diff --git a/-vv b/-vv new file mode 100644 index 00000000000..28f4857db7b --- /dev/null +++ b/-vv @@ -0,0 +1,78 @@ +mode: set +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:67.119,69.16 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:69.16,71.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:72.2,75.20 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:78.59,81.68 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:81.68,91.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:92.2,92.16 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:95.79,96.39 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:96.39,97.21 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:97.21,99.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:103.141,109.38 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:109.38,111.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:111.17,113.12 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:116.3,117.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:117.17,119.12 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:122.3,123.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:123.17,125.12 2 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:128.3,134.5 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:137.2,137.25 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:140.139,143.29 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:143.29,146.3 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:148.2,153.63 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:153.63,155.26 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:155.26,157.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:158.3,158.26 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:158.26,160.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:161.3,161.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:161.29,166.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:168.2,168.61 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:168.61,170.25 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:170.25,172.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:173.3,173.25 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:173.25,175.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:176.3,176.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:176.29,181.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:183.2,183.61 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:183.62,197.3 0 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:199.2,202.60 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:202.60,204.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:205.2,205.75 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:205.75,207.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:208.2,210.21 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:213.166,214.58 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:214.58,216.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:218.2,218.80 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:218.80,220.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:222.2,223.69 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:223.69,225.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:227.2,231.34 4 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:231.34,233.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:235.2,235.31 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:235.31,240.17 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:240.17,243.12 2 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:246.3,247.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:247.17,249.12 2 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:252.3,257.49 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:260.2,260.27 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:260.27,262.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:264.2,264.26 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:267.78,268.26 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:268.26,271.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:273.2,283.16 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:283.16,285.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:286.2,289.16 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:289.16,291.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:292.2,293.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:296.64,297.23 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:297.23,299.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:299.8,299.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:299.29,301.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:301.8,301.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:301.29,303.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:305.2,305.73 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:308.104,311.41 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:311.41,312.50 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:312.50,316.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:317.3,317.24 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:319.2,319.73 1 0 diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 6ea7faf566f..5f3f4b1b333 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -42,11 +42,12 @@ type resetDigitalImpExt struct { type resetDigitalMediaTypes struct { Banner resetDigitalMediaType `json:"banner"` Video resetDigitalMediaType `json:"video"` + Audio resetDigitalMediaType `json:"audio"` } type resetDigitalMediaType struct { Sizes [][]int64 `json:"sizes"` + Mimes []string `json:"mimes"` } - type resetDigitalBidResponse struct { Bids []resetDigitalBid `json:"bids"` } @@ -178,6 +179,16 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, []int64{tempW, tempH}, ) } + if imp.Video.MIMEs != nil{ + reqData.Imps[0].MediaTypes.Video.Mimes = append( + imp.Video.MIMEs, + ) + } + } + if bidType == openrtb_ext.BidTypeAudio && imp.Audio != nil && imp.Audio.MIMEs != nil{ + reqData.Imps[0].MediaTypes.Audio.Mimes = append( + imp.Audio.MIMEs, + ) } var bidderExt adapters.ExtImpBidder @@ -295,8 +306,10 @@ func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openr if reqImp, ok := reqImps[bidImpID]; ok { if reqImp.Banner == nil && reqImp.Video != nil { mediaType = openrtb_ext.BidTypeVideo + } else if reqImp.Audio != nil { + mediaType = openrtb_ext.BidTypeAudio } return mediaType, nil } return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID) -} \ No newline at end of file +} diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json new file mode 100644 index 00000000000..80ae00517f6 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json @@ -0,0 +1,183 @@ +{ + "mockBidRequest": { + "id": "12345", + "at": 1, + "bcat": [ + "IAB24", + "IAB25", + "IAB26" + ], + "cur": [ + "USD" + ], + "source": { + "fd": 0, + "tid": "00000FBCE10DE8FA", + "schain": { + "complete": 1, + "ver": "1.0", + "nodes": [ + { + "asi": "resetdigital.co", + "sid": "176", + "hp": 1 + } + ] + } + }, + "device": { + "ip": "35.146.176.97", + "js": 1, + "language": "en", + "ua": "PostmanRuntime/7.42.0" + }, + "user": { + "id": "000011200BA1065C", + "buyeruid": "000011200BA1065C" + }, + "app": { + "id": "test.com", + "bundle": "test.com", + "name": "test.com", + "content": { + "livestream": 1, + "genre": "F%C3%BAtbol", + "cat": [ + "" + ], + "language": "es" + }, + "publisher": { + "id": "176" + }, + "keywords": "" + }, + "imp": [ + { + "id": "001", + "bidfloor": 1.429, + "tagid": "667", + "secure": 1, + "audio": { + "protocols": [ + 2, + 3, + 5, + 6 + ], + "mimes": [ + "audio/mp4", + "audio/mp3" + ], + "api": [], + "minduration": 15, + "maxduration": 60, + "startdelay": -1 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + } + ], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 400 + }, + "httpCalls": [ + { + "expectedRequest": { + "method": "POST", + "body": { + "imps": [ + { + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": null, + "mimes": null + }, + "video": { + "sizes": null, + "mimes": null + }, + "audio": { + "sizes": null, + "mimes": [ + "audio/mp4", + "audio/mp3" + ] + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + } + ], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 9.11, + "dealid": "RD-1000164", + "cid": "1000048-1002918", + "crid": "1003893", + "adid": "1003893", + "language": "en", + "w": "0", + "h": "0", + "seat": "resetdigital", + "html": "" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "cid": "1000048-1002918", + "crid": "1003893", + "id": "01", + "impid": "001", + "price": 9.11 + }, + "type": "audio", + "seat": "resetdigital" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index bf22010c6fd..2e4a54c8a57 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -39,6 +39,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 250, @@ -47,6 +48,11 @@ ] }, "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json index 260217be957..0310ed18c46 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json @@ -1,9 +1,10 @@ { "mockBidRequest": { "id": "12345", - "imp": [{ - "id": "001", - "video": { + "imp": [ + { + "id": "001", + "video": { "w": 900, "h": 250, "mimes": [ @@ -11,12 +12,13 @@ "video/mp4" ] }, - "ext": { - "bidder": { - "placement_id": "placement-id-1" + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } } } - }], + ], "site": { "domain": "https://test.com", "page": "https://test.com/2016/06/12" @@ -31,76 +33,94 @@ }, "tmax": 500 }, - "httpCalls": [{ - "expectedRequest": { - "method": "POST", - "body": { - "imps": [{ - "bid_id": "12345", - "ext": { - "gpid": "" - }, - "imp_id": "001", - "media_types": { - "banner": { - "sizes": null - }, - "video": { - "sizes": [ - [ - 900, - 250 - ] - ] + "httpCalls": [ + { + "expectedRequest": { + "method": "POST", + "body": { + "imps": [ + { + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "mimes": null, + "sizes": null + }, + "video": { + "sizes": [ + [ + 900, + 250 + ] + ], + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "audio": { + "mimes": null, + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } } - }, - "zone_id": { - "placementId": "placement-id-1" + ], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" } - }], - "site": { - "domain": "https://test.com", - "referrer": "https://test.com/2016/06/12" - } + }, + "impIDs": [ + "001" + ] }, - "impIDs": [ - "001" - ] - }, - "mockResponse": { - "status": 200, - "body": { - "bids": [{ - "bid_id": "01", - "imp_id": "001", - "cpm": 1.00, - "cid": "1002088", - "crid": "1000763-1002088", - "adid": "1002088", - "w": "900", - "h": "250", - "seat": "resetdigital", - "html": "" - }] + "mockResponse": { + "status": 200, + "body": { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "900", + "h": "250", + "seat": "resetdigital", + "html": "" + } + ] + } } } - }], - - "expectedBidResponses": [{ - "currency": "USD", - "bids": [{ - "bid": { - "adm": "", - "cid": "1002088", - "crid": "1000763-1002088", - "id": "01", - "impid": "001", - "price": 1.00, - "w": 900, - "h": 250 - }, - "type": "video", - "seat": "resetdigital" - }] - }] -} + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 900, + "h": 250 + }, + "type": "video", + "seat": "resetdigital" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json index 6865ffc355c..fca85c84d4a 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json @@ -33,6 +33,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 250, @@ -41,6 +42,11 @@ ] }, "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json index d148516b1c2..878d9c07289 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json @@ -35,6 +35,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 250, @@ -43,6 +44,11 @@ ] }, "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json similarity index 86% rename from adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json rename to adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json index 6cbc6cf2be8..9a955ccb6a2 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json @@ -44,9 +44,18 @@ "imp_id": "001", "media_types": { "banner": { - "sizes": null + "mimes": null, + "sizes": null }, "video": { + "sizes": null, + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json index f17e0d149ab..66a441f6506 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json @@ -44,6 +44,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 300, @@ -52,6 +53,11 @@ ] }, "video": { + "sizes": null, + "mimes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json index 08cd3f22944..2d42bf5ddd4 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json @@ -32,10 +32,16 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": null }, "video": { - "sizes": null + "mimes": null, + "sizes": null + }, + "audio": { + "sizes": null, + "mimes": ["audio/mpeg"] } }, "zone_id": { From bc7caaf5bff37777d83bc7d1f93893f58d521061 Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Mon, 4 Nov 2024 12:10:03 -0800 Subject: [PATCH 27/73] Fix slice append syntax. --- adapters/resetdigital/resetdigital.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 5f3f4b1b333..69f0fdd2375 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -46,7 +46,7 @@ type resetDigitalMediaTypes struct { } type resetDigitalMediaType struct { Sizes [][]int64 `json:"sizes"` - Mimes []string `json:"mimes"` + Mimes []string `json:"mimes"` } type resetDigitalBidResponse struct { Bids []resetDigitalBid `json:"bids"` @@ -179,15 +179,18 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, []int64{tempW, tempH}, ) } - if imp.Video.MIMEs != nil{ + if imp.Video.MIMEs != nil { + // reqData.Imps[0].MediaTypes.Video.Mimes = imp.Video.MIMEs reqData.Imps[0].MediaTypes.Video.Mimes = append( - imp.Video.MIMEs, + reqData.Imps[0].MediaTypes.Video.Mimes, + imp.Video.MIMEs..., ) } } - if bidType == openrtb_ext.BidTypeAudio && imp.Audio != nil && imp.Audio.MIMEs != nil{ + if bidType == openrtb_ext.BidTypeAudio && imp.Audio != nil && imp.Audio.MIMEs != nil { reqData.Imps[0].MediaTypes.Audio.Mimes = append( - imp.Audio.MIMEs, + reqData.Imps[0].MediaTypes.Audio.Mimes, + imp.Audio.MIMEs..., ) } From 4569e97ee89e98cc34184d299fd7f701d3edf040 Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Mon, 4 Nov 2024 12:26:23 -0800 Subject: [PATCH 28/73] Removed zero check for bid response and moved HTTP headers into separate conditionals as requested by Brian Sardo. --- adapters/resetdigital/resetdigital.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 69f0fdd2375..3e56ed460bd 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -78,17 +78,25 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} - if request != nil && request.Device != nil && request.Site != nil { // what about request.App? Do we need to do something different with Referrer in the app case assuming we care about app? + addNonEmptyHeaders(&headers, map[string]string{ + "Content-Type": "application/json;charset=utf-8", + "Accept": "application/json", + }) + + if request != nil && request.Device != nil { addNonEmptyHeaders(&headers, map[string]string{ - "Referer": request.Site.Page, "Accept-Language": request.Device.Language, "User-Agent": request.Device.UA, "X-Forwarded-For": request.Device.IP, "X-Real-Ip": request.Device.IP, - "Content-Type": "application/json;charset=utf-8", - "Accept": "application/json", }) } + if request != nil && request.Site != nil { + addNonEmptyHeaders(&headers, map[string]string{ + "Referer": request.Site.Page, + }) + } + return headers } @@ -263,10 +271,6 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } func getBidFromResponse(bidResponse *resetDigitalBid) (*openrtb2.Bid, error) { - if bidResponse.CPM == 0 { - // brian to check how to report this - return nil, nil - } bid := &openrtb2.Bid{ ID: bidResponse.BidID, From 0bc2aeb4b95964e9bed8d36f49dab11c2ab43458 Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Mon, 4 Nov 2024 12:47:00 -0800 Subject: [PATCH 29/73] Adding test case for missing currency to improve test coverage percentage. --- .../supplemental/missing-currency.json | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json b/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json new file mode 100644 index 00000000000..35bf5f7165e --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json @@ -0,0 +1,105 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "mimes": null, + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + }] + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 300, + "h": 250 + }, + "type": "banner", + "seat": "resetdigital" + }] + }] +} From cff2442bed7f75aee6edb1c7119cb547b783f023 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Mon, 5 Feb 2024 17:54:37 +0000 Subject: [PATCH 30/73] New Adapter: ResetDigital --- adapters/resetdigital/resetdigital.go | 260 ++++++++++++++++++ adapters/resetdigital/resetdigital_test.go | 87 ++++++ .../examplary/simple-banner.json | 87 ++++++ openrtb_ext/bidders.go | 2 + openrtb_ext/imp_resetdigital.go | 7 + 5 files changed, 443 insertions(+) create mode 100644 adapters/resetdigital/resetdigital.go create mode 100644 adapters/resetdigital/resetdigital_test.go create mode 100644 adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json create mode 100644 openrtb_ext/imp_resetdigital.go diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go new file mode 100644 index 00000000000..7e44bfd8607 --- /dev/null +++ b/adapters/resetdigital/resetdigital.go @@ -0,0 +1,260 @@ +package resetdigital + +import ( + "encoding/json" + "fmt" + "net/http" + "strconv" + "text/template" + + "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v2/adapters" + "github.com/prebid/prebid-server/v2/config" + "github.com/prebid/prebid-server/v2/openrtb_ext" +) + +// MaximumBids is the maximum number of bids that can be returned by this adapter. +const ( + MaxBids = 1 +) + +type adapter struct { + endpoint *template.Template + endpointUri string +} + +type resetDigitalRequest struct { + Site resetDigitalRequestSite `json:"site"` + Imps []resetDigitalRequesImps `json:"imps"` +} + +type resetDigitalRequestSite struct { + Domain string `json:"domain"` + Referrer string `json:"referrer"` +} + +type resetDigitalRequesImps struct { + ZoneID struct { + PlacementID string `json:"placementId"` + } `json:"zone_id"` + BidID string `json:"bid_id"` + ImpID string `json:"imp_id"` + Ext struct { + Gpid string `json:"gpid"` + } `json:"ext"` + Sizes [][]int64 `json:"sizes"` + MediaTypes struct { + Banner struct { + Sizes [][]int64 `json:"sizes"` + } `json:"banner"` + Video struct { + Sizes [][]int64 `json:"sizes"` + } `json:"video"` + } `json:"media_types"` +} + +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + template, err := template.New("endpointTemplate").Parse(config.Endpoint) + if err != nil { + return nil, fmt.Errorf("unable to parse endpoint url template: %v", err) + } + + bidder := &adapter{ + endpoint: template, + } + + return bidder, nil +} +func getHeaders(request *openrtb2.BidRequest) http.Header { + headers := http.Header{} + + if request.Device != nil && request.Site != nil { + addNonEmptyHeaders(&headers, map[string]string{ + "Referer": request.Site.Page, + "Accept-Language": request.Device.Language, + "User-Agent": request.Device.UA, + "X-Forwarded-For": request.Device.IP, + "X-Real-Ip": request.Device.IP, + "Content-Type": "application/json;charset=utf-8", + "Accept": "application/json", + }) + } + + return headers +} +func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) { + for key, value := range headerValues { + if len(value) > 0 { + headers.Add(key, value) + } + } +} + +func getReferer(request *openrtb2.BidRequest) string { + if request.Site == nil { + return "" + } + + return request.Site.Domain +} + +func getCurrency(request *openrtb2.BidRequest) string { + if len(request.Cur) == 0 { + return "USD" + } + + return request.Cur[0] +} + +func (a *adapter) MakeRequests(requestData *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var ( + requests []*adapters.RequestData + errors []error + ) + + referer := getReferer(requestData) + currency := getCurrency(requestData) + + if referer == currency { + return nil, nil + } + + for i := range requestData.Imp { + imp := requestData.Imp[i] + bidType, err := getBidType(imp) + + if err != nil { + errors = append(errors, err) + continue + } + + splittedRequestData := processDataFromRequest(requestData, imp, bidType) + + requestBody, err := json.Marshal(splittedRequestData) + if err != nil { + errors = append(errors, err) + continue + } + + requests = append(requests, &adapters.RequestData{ + Method: "POST", + Uri: a.endpointUri, + Body: requestBody, + Headers: getHeaders(requestData), + }) + } + + return requests, errors +} + +func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, bidType openrtb_ext.BidType) resetDigitalRequest { + + var resetDigitalRequestData resetDigitalRequest + resetDigitalRequestData.Site.Domain = requestData.Site.Domain + resetDigitalRequestData.Site.Referrer = requestData.Site.Page + + resetDigitalRequestData.Imps = append(resetDigitalRequestData.Imps, resetDigitalRequesImps{}) + resetDigitalRequestData.Imps[0].BidID = requestData.ID + resetDigitalRequestData.Imps[0].ImpID = imp.ID + + if bidType == openrtb_ext.BidTypeBanner { + resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes = append(resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes, []int64{imp.Banner.Format[0].W, imp.Banner.Format[0].H}) + } + if bidType == openrtb_ext.BidTypeVideo { + resetDigitalRequestData.Imps[0].MediaTypes.Video.Sizes = append(resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes, []int64{*imp.Video.W, *imp.Video.H}) + } + + return resetDigitalRequestData + +} + +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if response.StatusCode == http.StatusNoContent { + return nil, nil + } + if response.StatusCode == http.StatusBadRequest { + return nil, []error{fmt.Errorf("bad request")} + } + if response.StatusCode != http.StatusOK { + return nil, []error{fmt.Errorf("unexpected status code: %d", response.StatusCode)} + } + + if err := json.Unmarshal(response.Body, &response); err != nil { + return nil, []error{err} + } + bidResponse := adapters.NewBidderResponseWithBidsCapacity(MaxBids) + //check no bids + jsonData := make(map[string]interface{}) + + json.Unmarshal([]byte(response.Body), &jsonData) + //Always one bid + bid := getBidFromResponse(jsonData) + + bidType, err := getBidType(internalRequest.Imp[0]) + if err != nil { + // handle error + return nil, []error{err} + } + bidResponse.Currency = getCurrency(internalRequest) + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: bid, + BidType: bidType, + }) + + return bidResponse, nil +} + +func getBidFromResponse(requestData map[string]interface{}) *openrtb2.Bid { + processData := requestData["bids"].([]interface{})[0].(map[string]interface{}) + fmt.Printf("jsonData: %v\n", processData) + + bid := &openrtb2.Bid{ + ID: processData["bid_id"].(string), + Price: getBidPrice(processData), + ImpID: processData["imp_id"].(string), + CrID: processData["crid"].(string), + } + //if HTML is filled on jsonData then fill ADM with it + if value, ok := processData["html"].(string); ok { + bid.AdM = value + } + //if Width and Height are filled on jsonData then fill W and H with it + if value, ok := processData["w"].(string); ok { + + i, _ := strconv.ParseInt(value, 10, 64) + if i > 0 { + bid.W = i + } + } + if value, ok := processData["h"].(string); ok { + i, _ := strconv.ParseInt(value, 10, 64) + if i > 0 { + bid.H = i + } + } + //if Bid Price is 0 then return nil + if bid.Price == 0 { + return nil + } + + return bid +} + +func getBidPrice(requestData map[string]interface{}) float64 { + if value, ok := requestData["cpm"].(float64); ok { + return value + } + return 0.0 // Default value if "cpm" doesn't exist or is not a float64 +} + +func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { + if imp.Banner != nil { + return openrtb_ext.BidTypeBanner, nil + } else if imp.Video != nil { + return openrtb_ext.BidTypeVideo, nil + } else if imp.Audio != nil { + return openrtb_ext.BidTypeAudio, nil + } + + return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID) +} diff --git a/adapters/resetdigital/resetdigital_test.go b/adapters/resetdigital/resetdigital_test.go new file mode 100644 index 00000000000..e3307e916cf --- /dev/null +++ b/adapters/resetdigital/resetdigital_test.go @@ -0,0 +1,87 @@ +package resetdigital + +import ( + "encoding/json" + "net/http" + "testing" + + "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v2/adapters" + "github.com/stretchr/testify/assert" +) + +func TestMakeRequests(t *testing.T) { + bidder := new(adapter) + + request := &openrtb2.BidRequest{ + ID: "12345", + + Imp: []openrtb2.Imp{{ + ID: "001", + + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ + {W: 300, H: 250}, + }, + }, + Ext: json.RawMessage(``), + }}, + Site: &openrtb2.Site{ + Domain: "https://test.com", + Page: "https://test.com/2016/06/12", + }, + Cur: []string{"USD"}, + Device: &openrtb2.Device{ + UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + IP: "127.0.0.1", + Language: "EN", + }, + } + + reqs, errs := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) + + assert.Empty(t, errs, "Got unexpected errors while building HTTP requests: %v", errs) + assert.Equal(t, 1, len(reqs), "Unexpected number of HTTP requests. Got %d. Expected %d", len(reqs), 1) +} + +func TestMakeBids(t *testing.T) { + request := &openrtb2.BidRequest{ + ID: "test-request-id", + Imp: []openrtb2.Imp{{ + ID: "test-imp-id", + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ + W: 320, + H: 250, + }}, + }, + Ext: json.RawMessage(`{"bidder": { + "accountId": 2763, + "siteId": 68780, + "zoneId": 327642 + }}`), + }}, + Ext: json.RawMessage(``), + } + + requestJson, _ := json.Marshal(request) + reqData := &adapters.RequestData{ + Method: "POST", + Uri: "test-uri", + Body: requestJson, + Headers: nil, + } + + httpResp := &adapters.ResponseData{ + StatusCode: http.StatusOK, + Body: []byte(`{"bids":[{"bid_id":"01","imp_id":"001","cpm":10.00,"cid":"1002088","crid":"1000763-1002088","adid":"1002088","w":"300","h":"250","seat":"resetdigital","html":""}]}`), + } + + bidder := new(adapter) + bidResponse, errs := bidder.MakeBids(request, reqData, httpResp) + + assert.Empty(t, errs, "Expected 0 errors. Got %d", len(errs)) + + assert.Equal(t, float64(10), bidResponse.Bids[0].Bid.Price, + "Expected Price 10. Got: %s", bidResponse.Bids[0].Bid.Price) +} diff --git a/adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json new file mode 100644 index 00000000000..4e21c27015a --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/examplary/simple-banner.json @@ -0,0 +1,87 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [ + { + "id": "001", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "placement_id": "111" + } + } + } + ], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [ + { + "language": "en-US", + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + }, + "imps": [ + { + "zone_id": { + "placementId": "test" + }, + "bid_id": "01", + "imp_id": "001", + "ext": { + "gpid": "test" + }, + "sizes": [ + [ + 300, + 250 + ] + ], + "media_types": { + "banner": { + "sizes": [ + [ + 300, + 250 + ] + ] + } + } + } + ] + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + } + ] + } + ] +} \ No newline at end of file From 5ab55177427088ffd8ef420e24398d9e37c5f94a Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Thu, 29 Aug 2024 15:52:32 +0100 Subject: [PATCH 49/73] Update with help of Xandr Team --- adapters/resetdigital/resetdigital.go | 244 +++++++++--------- .../exemplary/simple-banner.json | 150 ++++++----- openrtb_ext/imp_resetdigital.go | 5 +- 3 files changed, 198 insertions(+), 201 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 5d44ac092d2..bca84364e8c 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -22,34 +22,49 @@ type adapter struct { } type resetDigitalRequest struct { - Site resetDigitalRequestSite `json:"site"` - Imps []resetDigitalRequestImps `json:"imps"` + Site resetDigitalSite `json:"site"` + Imps []resetDigitalImp `json:"imps"` } - -type resetDigitalRequestSite struct { +type resetDigitalSite struct { Domain string `json:"domain"` Referrer string `json:"referrer"` } +type resetDigitalImp struct { + ForceBid bool `json:"force_bid"` + ZoneID resetDigitalImpZone `json:"zone_id"` + BidID string `json:"bid_id"` + ImpID string `json:"imp_id"` + Ext resetDigitalImpExt `json:"ext"` + MediaTypes resetDigitalMediaTypes `json:"media_types"` +} +type resetDigitalImpZone struct { + PlacementID string `json:"placementId"` +} +type resetDigitalImpExt struct { + Gpid string `json:"gpid"` +} +type resetDigitalMediaTypes struct { + Banner resetDigitalMediaType `json:"banner"` + Video resetDigitalMediaType `json:"video"` +} +type resetDigitalMediaType struct { + Sizes [][]int64 `json:"sizes"` +} -type resetDigitalRequestImps struct { - ForceBid bool `json:"force_bid"` - ZoneID struct { - PlacementID string `json:"placementId"` - } `json:"zone_id"` - BidID string `json:"bid_id"` - ImpID string `json:"imp_id"` - Ext struct { - Gpid string `json:"gpid"` - } `json:"ext"` - Sizes [][]int64 `json:"sizes"` - MediaTypes struct { - Banner struct { - Sizes [][]int64 `json:"sizes"` - } `json:"banner"` - Video struct { - Sizes [][]int64 `json:"sizes"` - } `json:"video"` - } `json:"media_types"` +type resetDigitalBidResponse struct { + Bids []resetDigitalBid `json:"bids"` +} +type resetDigitalBid struct { + BidID string `json:"bid_id"` + ImpID string `json:"imp_id"` + CPM float64 `json:"cpm"` + CID string `json:"cid,omitempty"` + CrID string `json:"crid,omitempty"` + AdID string `json:"adid"` + W string `json:"w,omitempty"` + H string `json:"h,omitempty"` + Seat string `json:"seat"` + HTML string `json:"html"` } func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { @@ -57,17 +72,16 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co if err != nil { return nil, fmt.Errorf("unable to parse endpoint url template: %v", err) } - bidder := &adapter{ endpoint: template, } - return bidder, nil } + func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} - if request.Device != nil && request.Site != nil { + if request != nil && request.Device != nil && request.Site != nil { addNonEmptyHeaders(&headers, map[string]string{ "Referer": request.Site.Page, "Accept-Language": request.Device.Language, @@ -78,9 +92,9 @@ func getHeaders(request *openrtb2.BidRequest) http.Header { "Accept": "application/json", }) } - return headers } + func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) { for key, value := range headerValues { if len(value) > 0 { @@ -89,23 +103,13 @@ func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) { } } -func getCurrency(request *openrtb2.BidRequest) string { - if len(request.Cur) == 0 { - return "USD" - } - - return request.Cur[0] -} - func (a *adapter) MakeRequests(requestData *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var ( requests []*adapters.RequestData errors []error ) - for i := range requestData.Imp { - imp := requestData.Imp[i] - + for _, imp := range requestData.Imp { bidType, err := getBidType(imp) if err != nil { errors = append(errors, err) @@ -132,145 +136,133 @@ func (a *adapter) MakeRequests(requestData *openrtb2.BidRequest, requestInfo *ad ImpIDs: []string{imp.ID}, }) } - //clear requests.body return requests, errors } func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, bidType openrtb_ext.BidType) (resetDigitalRequest, error) { - var resetDigitalRequestData resetDigitalRequest + var reqData resetDigitalRequest - // Check if requestData.Site is not nil before accessing its fields if requestData.Site != nil { - resetDigitalRequestData.Site.Domain = requestData.Site.Domain - resetDigitalRequestData.Site.Referrer = requestData.Site.Page - + reqData.Site.Domain = requestData.Site.Domain + reqData.Site.Referrer = requestData.Site.Page } - resetDigitalRequestData.Imps = append(resetDigitalRequestData.Imps, resetDigitalRequestImps{ + reqData.Imps = append(reqData.Imps, resetDigitalImp{ BidID: requestData.ID, ImpID: imp.ID, }) - if bidType == openrtb_ext.BidTypeBanner { - if imp.Banner != nil { - var tempH int64 = *imp.Banner.H - var tempW int64 = *imp.Banner.W - - if tempH > 0 && tempW > 0 { - resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes = append( - resetDigitalRequestData.Imps[0].MediaTypes.Banner.Sizes, - []int64{tempH, tempW}, - ) - } + if bidType == openrtb_ext.BidTypeBanner && imp.Banner != nil { + tempH := *imp.Banner.H + tempW := *imp.Banner.W + if tempH > 0 && tempW > 0 { + reqData.Imps[0].MediaTypes.Banner.Sizes = append( + reqData.Imps[0].MediaTypes.Banner.Sizes, + []int64{tempH, tempW}, + ) } } - - if bidType == openrtb_ext.BidTypeVideo { - if imp.Video != nil { - var tempH int64 = *imp.Video.H - var tempW int64 = *imp.Video.W - - if tempH > 0 && tempW > 0 { - resetDigitalRequestData.Imps[0].MediaTypes.Video.Sizes = append( - resetDigitalRequestData.Imps[0].MediaTypes.Video.Sizes, - []int64{tempH, tempW}, - ) - } + if bidType == openrtb_ext.BidTypeVideo && imp.Video != nil { + tempH := *imp.Video.H + tempW := *imp.Video.W + + if tempH > 0 && tempW > 0 { + reqData.Imps[0].MediaTypes.Video.Sizes = append( + reqData.Imps[0].MediaTypes.Video.Sizes, + []int64{tempH, tempW}, + ) } } - var extData = make(map[string]interface{}) - err := json.Unmarshal(imp.Ext, &extData) - if err != nil { + + var bidderExt adapters.ExtImpBidder + var resetDigitalExt openrtb_ext.ImpExtResetDigital + + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return resetDigitalRequest{}, err } + if err := json.Unmarshal(bidderExt.Bidder, &resetDigitalExt); err != nil { + return resetDigitalRequest{}, err + } + reqData.Imps[0].ZoneID.PlacementID = resetDigitalExt.PlacementID - resetDigitalRequestData.Imps[0].ZoneID.PlacementID = extData["bidder"].(map[string]interface{})["placement_id"].(string) - - return resetDigitalRequestData, nil + return reqData, nil } -func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if adapters.IsResponseStatusCodeNoContent(response) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } - if err := adapters.CheckResponseStatusCodeForErrors(response); err != nil { + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { return nil, []error{err} } - var bidResp map[string]interface{} - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + var response resetDigitalBidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } - bidResponse := adapters.NewBidderResponseWithBidsCapacity(maxBids) - jsonData := bidResp["bids"].([]interface{}) + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + + requestImps := make(map[string]openrtb2.Imp) + for _, imp := range request.Imp { + requestImps[imp.ID] = imp + } - for _, bidData := range jsonData { - bidMap := bidData.(map[string]interface{}) - bid := getBidFromResponse(bidMap) + for i := range response.Bids { + resetDigitalBid := &response.Bids[i] + + bid := getBidFromResponse(resetDigitalBid) if bid == nil { continue } - bidTypes, err := getBidTypes(internalRequest.Imp[0]) + bidType, err := GetMediaTypeForImp(requestImps, bid.ImpID) if err != nil { return nil, []error{err} } - for _, bidType := range bidTypes { - bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: bid, - BidType: bidType, - }) + b := &adapters.TypedBid{ + Bid: bid, + BidType: bidType, + Seat: openrtb_ext.BidderName(resetDigitalBid.Seat), } + bidResponse.Bids = append(bidResponse.Bids, b) + } + + if len(request.Cur) == 0 { + bidResponse.Currency = "USD" } - bidResponse.Currency = getCurrency(internalRequest) return bidResponse, nil } -func getBidFromResponse(requestData map[string]interface{}) *openrtb2.Bid { - processData := requestData["bid_id"].(string) - - bid := &openrtb2.Bid{ - ID: processData, - Price: getBidPrice(requestData), - ImpID: requestData["imp_id"].(string), - CrID: requestData["crid"].(string), - } - if value, ok := requestData["html"].(string); ok { - bid.AdM = value +func getBidFromResponse(bidResponse *resetDigitalBid) *openrtb2.Bid { + if bidResponse.CPM == 0 { + return nil } - if value, ok := requestData["w"].(string); ok { - if i, err := strconv.ParseInt(value, 10, 64); err == nil && i > 0 { - bid.W = i - } + bid := &openrtb2.Bid{ + ID: bidResponse.BidID, + Price: bidResponse.CPM, + ImpID: bidResponse.ImpID, + CID: bidResponse.CID, + CrID: bidResponse.CrID, + AdM: bidResponse.HTML, } - if value, ok := requestData["h"].(string); ok { - if i, err := strconv.ParseInt(value, 10, 64); err == nil && i > 0 { - bid.H = i - } + if i, err := strconv.ParseInt(bidResponse.W, 10, 64); err == nil && i > 0 { + bid.W = i } - - if bid.Price == 0 { - return nil + if i, err := strconv.ParseInt(bidResponse.H, 10, 64); err == nil && i > 0 { + bid.H = i } return bid } -func getBidPrice(requestData map[string]interface{}) float64 { - if value, ok := requestData["cpm"].(float64); ok { - return value - } - return 0.0 // Default value if "cpm" doesn't exist or is not a float64 -} - func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { if imp.Banner != nil { return openrtb_ext.BidTypeBanner, nil @@ -301,3 +293,15 @@ func getBidTypes(imp openrtb2.Imp) ([]openrtb_ext.BidType, error) { return bidTypes, nil } + +func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openrtb_ext.BidType, error) { + mediaType := openrtb_ext.BidTypeBanner + + if reqImp, ok := reqImps[bidImpID]; ok { + if reqImp.Banner == nil && reqImp.Video != nil { + mediaType = openrtb_ext.BidTypeVideo + } + return mediaType, nil + } + return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID) +} diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index 8d4e0adb1d0..f526cc86290 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -1,22 +1,20 @@ { "mockBidRequest": { "id": "12345", - "imp": [ - { - "id": "001", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "placement_id": "test" - } + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" } } - ], + }], "site": { - "domain": "test.com", + "domain": "https://test.com", "page": "https://test.com/2016/06/12" }, "cur": [ @@ -29,69 +27,47 @@ }, "tmax": 500 }, - "httpCalls": [ - { - "expectedRequest": { - "method": "POST", - "body": { - "id": "12345", - "imp": [ - { - "id": "001", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "placement_id": "test" - } - } - } - ], - "site": { - "domain": "test.com", - "page": "https://test.com/2016/06/12" - }, - "cur": [ - "USD" - ], - "device": { - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - "ip": "127.0.0.1", - "language": "EN" + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" }, - "tmax": 500 - }, - "impIDs": [ - "001" - ] - }, - "mockResponse": { - "status": 200, - "body": { - "bids": [ - { - "bid_id": "01", - "imp_id": "001", - "cpm": 1.00, - "cid": "1002088", - "crid": "1000763-1002088", - "adid": "1002088", - "w": "300", - "h": "250", - "seat": "resetdigital", - "html": "" + "force_bid": false, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 300, + 250 + ] + ] + }, + "video": { + "sizes": null } - ] + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" } - } - } - ], - "expectedBidResponses": [ - { - "bids": [ - { + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ "bid_id": "01", "imp_id": "001", "cpm": 1.00, @@ -101,9 +77,27 @@ "w": "300", "h": "250", "seat": "resetdigital", - "html": "" - } - ] + "html": "" + }] + } } - ] -} \ No newline at end of file + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 300, + "h": 250 + }, + "type": "banner", + "seat": "resetdigital" + }] + }] +} diff --git a/openrtb_ext/imp_resetdigital.go b/openrtb_ext/imp_resetdigital.go index b9e2ac8297b..6e3f800ab98 100644 --- a/openrtb_ext/imp_resetdigital.go +++ b/openrtb_ext/imp_resetdigital.go @@ -1,6 +1,5 @@ package openrtb_ext -type ExtResetDigital struct { - BidID string `json:"bid_id"` - ImpID string `json:"imp_id"` +type ImpExtResetDigital struct { + PlacementID string `json:"placement_id"` } From d3df8f2244c69023ce48ee2ef07976891699f846 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Thu, 29 Aug 2024 16:09:40 +0100 Subject: [PATCH 50/73] Simplify Tests --- adapters/resetdigital/resetdigital_test.go | 86 ---------------------- 1 file changed, 86 deletions(-) diff --git a/adapters/resetdigital/resetdigital_test.go b/adapters/resetdigital/resetdigital_test.go index 12f2dc09e17..d160e9a23fe 100644 --- a/adapters/resetdigital/resetdigital_test.go +++ b/adapters/resetdigital/resetdigital_test.go @@ -1,16 +1,11 @@ package resetdigital import ( - "encoding/json" - "net/http" "testing" - "github.com/prebid/openrtb/v20/openrtb2" - "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/adapters/adapterstest" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/openrtb_ext" - "github.com/stretchr/testify/assert" ) func TestJsonSamples(t *testing.T) { @@ -24,84 +19,3 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "resetdigitaltest", bidder) } - -func TestMakeRequests(t *testing.T) { - bidder := new(adapter) - - request := &openrtb2.BidRequest{ - ID: "12345", - - Imp: []openrtb2.Imp{{ - ID: "001", - Banner: &openrtb2.Banner{ - Format: []openrtb2.Format{ - {W: 300, H: 250}, - }, - }, - - Ext: json.RawMessage(`{"bidder": {"placement_id": "test"}}`), //Placement_id test is used to get the force bid true - }}, - Site: &openrtb2.Site{ - Domain: "https://test.com", - Page: "https://test.com/2016/06/12", - }, - Cur: []string{"USD"}, - Device: &openrtb2.Device{ - UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - IP: "127.0.0.1", - Language: "EN", - }, - } - - reqs, errs := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) - - assert.Empty(t, errs, "Got unexpected errors while building HTTP requests: %v", errs) - assert.Equal(t, 1, len(reqs), "Unexpected number of HTTP requests. Got %d. Expected %d", len(reqs), 1) -} - -func TestMakeBids(t *testing.T) { - request := &openrtb2.BidRequest{ - ID: "12345", - - Imp: []openrtb2.Imp{{ - ID: "001", - Banner: &openrtb2.Banner{ - Format: []openrtb2.Format{ - {W: 300, H: 250}, - }, - }, - - Ext: json.RawMessage(`{"bidder": {"placement_id": "test"}}`), //Placement_id test is used to get the force bid true - }}, - Site: &openrtb2.Site{ - Domain: "https://test.com", - Page: "https://test.com/2016/06/12", - }, - Cur: []string{"USD"}, - Device: &openrtb2.Device{ - UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - IP: "127.0.0.1", - Language: "EN", - }, - } - - requestJson, _ := json.Marshal(request) - reqData := &adapters.RequestData{ - Method: "POST", - Uri: "test-uri", - Body: requestJson, - } - - httpResp := &adapters.ResponseData{ - StatusCode: http.StatusOK, - Body: []byte(`{"bids":[{"bid_id":"01","imp_id":"001","cpm":10.00,"cid":"1002088","crid":"1000763-1002088","adid":"1002088","w":"300","h":"250","seat":"resetdigital","html":""}]}`), - } - - bidder := new(adapter) - bidResponse, errs := bidder.MakeBids(request, reqData, httpResp) - - assert.Empty(t, errs, "Expected 0 errors. Got %d", len(errs)) - - assert.Equal(t, float64(10), bidResponse.Bids[0].Bid.Price, - "Expected Price 10. Got: %s", bidResponse.Bids[0].Bid.Price) -} From c1795b8bbd6aedc7bbd2321bd1a5bf1fce8df8d0 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Tue, 10 Sep 2024 11:18:03 +0100 Subject: [PATCH 51/73] PR of functioning version --- adapters/resetdigital/resetdigital.go | 72 +++++++++---------- .../exemplary/simple-banner.json | 5 +- static/bidder-info/resetdigital.yaml | 35 +++++---- static/bidder-params/resetdigital.json | 12 +++- 4 files changed, 60 insertions(+), 64 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index bca84364e8c..70b73c5ac6d 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -13,9 +13,6 @@ import ( "github.com/prebid/prebid-server/v2/openrtb_ext" ) -// MaximumBids is the maximum number of bids that can be returned by this adapter. -const maxBids = 1 - type adapter struct { endpoint *template.Template endpointUri string @@ -30,7 +27,6 @@ type resetDigitalSite struct { Referrer string `json:"referrer"` } type resetDigitalImp struct { - ForceBid bool `json:"force_bid"` ZoneID resetDigitalImpZone `json:"zone_id"` BidID string `json:"bid_id"` ImpID string `json:"imp_id"` @@ -81,7 +77,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} - if request != nil && request.Device != nil && request.Site != nil { + if request != nil && request.Device != nil && request.Site != nil { // what about request.App? Do we need to do something different with Referrer in the app case assuming we care about app? addNonEmptyHeaders(&headers, map[string]string{ "Referer": request.Site.Page, "Accept-Language": request.Device.Language, @@ -154,24 +150,32 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, }) if bidType == openrtb_ext.BidTypeBanner && imp.Banner != nil { - tempH := *imp.Banner.H - tempW := *imp.Banner.W - + var tempH, tempW int64 + if imp.Banner.H != nil { + tempH = *imp.Banner.H + } + if imp.Banner.W != nil { + tempW = *imp.Banner.W + } if tempH > 0 && tempW > 0 { reqData.Imps[0].MediaTypes.Banner.Sizes = append( reqData.Imps[0].MediaTypes.Banner.Sizes, - []int64{tempH, tempW}, + []int64{tempW, tempH}, ) } } if bidType == openrtb_ext.BidTypeVideo && imp.Video != nil { - tempH := *imp.Video.H - tempW := *imp.Video.W - + var tempH, tempW int64 + if imp.Video.H != nil { + tempH = *imp.Video.H + } + if imp.Video.W != nil { + tempW = *imp.Video.W + } if tempH > 0 && tempW > 0 { reqData.Imps[0].MediaTypes.Video.Sizes = append( reqData.Imps[0].MediaTypes.Video.Sizes, - []int64{tempH, tempW}, + []int64{tempW, tempH}, ) } } @@ -206,6 +210,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + var errs []error requestImps := make(map[string]openrtb2.Imp) for _, imp := range request.Imp { requestImps[imp.ID] = imp @@ -214,8 +219,10 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R for i := range response.Bids { resetDigitalBid := &response.Bids[i] - bid := getBidFromResponse(resetDigitalBid) + bid, err := getBidFromResponse(resetDigitalBid) + // handle the error if bid == nil { + // it would be better to return an error here continue } @@ -236,12 +243,13 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse.Currency = "USD" } - return bidResponse, nil + return bidResponse, errs } -func getBidFromResponse(bidResponse *resetDigitalBid) *openrtb2.Bid { +func getBidFromResponse(bidResponse *resetDigitalBid) (*openrtb2.Bid, error) { if bidResponse.CPM == 0 { - return nil + // brian to check how to report this + return nil, nil } bid := &openrtb2.Bid{ @@ -255,12 +263,17 @@ func getBidFromResponse(bidResponse *resetDigitalBid) *openrtb2.Bid { if i, err := strconv.ParseInt(bidResponse.W, 10, 64); err == nil && i > 0 { bid.W = i - } + } else if err != nil { + return nil, err + } // the error should be returned here if ParseInt fails + if i, err := strconv.ParseInt(bidResponse.H, 10, 64); err == nil && i > 0 { bid.H = i - } + } else if err != nil { + return nil, err + } // the error should be returned here if ParseInt fails - return bid + return bid, nil } func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { @@ -275,25 +288,6 @@ func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID) } -func getBidTypes(imp openrtb2.Imp) ([]openrtb_ext.BidType, error) { - var bidTypes []openrtb_ext.BidType - - if imp.Banner != nil { - bidTypes = append(bidTypes, openrtb_ext.BidTypeBanner) - } - if imp.Video != nil { - bidTypes = append(bidTypes, openrtb_ext.BidTypeVideo) - } - if imp.Audio != nil { - bidTypes = append(bidTypes, openrtb_ext.BidTypeAudio) - } - if len(bidTypes) == 0 { - return nil, fmt.Errorf("failed to find matching imp for bid %s", imp.ID) - } - - return bidTypes, nil -} - func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index f526cc86290..bf22010c6fd 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -36,14 +36,13 @@ "ext": { "gpid": "" }, - "force_bid": false, "imp_id": "001", "media_types": { "banner": { "sizes": [ [ - 300, - 250 + 250, + 300 ] ] }, diff --git a/static/bidder-info/resetdigital.yaml b/static/bidder-info/resetdigital.yaml index 99c22378318..3c4a206389a 100644 --- a/static/bidder-info/resetdigital.yaml +++ b/static/bidder-info/resetdigital.yaml @@ -1,19 +1,16 @@ - endpoint: http://b-us-east14.resetdigital.co:9001 - meta-info: - maintainer-email: biddersupport@resetdigital.co - app-media-types: - - banner - - video - - audio - site-media-types: - - banner - - video - - audio - supported-vendors: - vendor-id: 1162 - usersync: - cookie-family-name: resetdigital - redirect: - url: https://sync.resetdigital.co/csync?pid=rubicon&redir={{redirect_url}} - support-cors: false - uid-macro: '$USER_ID' +endpoint: http://b-us-east14.resetdigital.co:9001 +maintainer: + email: biddersupport@resetdigital.co +capabilities: + site: + mediaTypes: + - banner + - video + - audio +gvlVendorID: 1162 +userSync: + key: resetdigital + supportCors: false + redirect: + url: https://sync.resetdigital.co/csync?pid=rubicon&redir={{redirect_url}} + userMacro: '$USER_ID' diff --git a/static/bidder-params/resetdigital.json b/static/bidder-params/resetdigital.json index d2bcfb6bb5f..4d0538893f7 100644 --- a/static/bidder-params/resetdigital.json +++ b/static/bidder-params/resetdigital.json @@ -1,7 +1,13 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Relevant Digital Adapter Params", - "description": "A schema which validates params accepted by the Relevant Digital adapter", + "title": "Reset Digital Adapter Params", + "description": "A schema which validates params accepted by the Reset Digital adapter", "type": "object", - "properties": {} + "properties": { + "placement_id": { + "type": "string", + "minLength": 1, + "description": "Placement ID for the Reset Digital ad unit. This is the identifier for the ad unit on the Reset Digital platform, and its optional" + } + } } From 1665bc9a1b533e3bbe7ec084d09fd475b1b8f839 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Sun, 29 Sep 2024 20:07:47 +0100 Subject: [PATCH 52/73] Added Video and removed unwanted data --- .../examplary/test-missing-cur.json | 86 ------------- .../examplary/test-missing-site.json | 64 ---------- .../examplary/test-multi-format.json | 119 ------------------ .../examplary/test-request-error.json | 74 ----------- .../exemplary/simple-video.json | 106 ++++++++++++++++ 5 files changed, 106 insertions(+), 343 deletions(-) delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-missing-site.json delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-multi-format.json delete mode 100644 adapters/resetdigital/resetdigitaltest/examplary/test-request-error.json create mode 100644 adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json diff --git a/adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json b/adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json deleted file mode 100644 index 5b997219cc6..00000000000 --- a/adapters/resetdigital/resetdigitaltest/examplary/test-missing-cur.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "mockBidRequest": { - "id": "12345", - "imp": [ - { - "id": "001", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "placement_id": "test" - } - } - } - ], - "site": { - "domain": "https://test.com", - "page": "https://test.com/2016/06/12" - }, - "cur": [], - "device": { - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - "ip": "127.0.0.1", - "language": "EN" - }, - "tmax": 500 - }, - "httpCalls": [ - { - "language": "en-US", - "site": { - "domain": "https://test.com", - "referrer": "https://test.com/2016/06/12" - }, - "imps": [ - { - "force_bid": 1, - "zone_id": { - "placementId": "test" - }, - "bid_id": "01", - "imp_id": "001", - "ext": { - "gpid": "test" - }, - "sizes": [ - [ - 300, - 250 - ] - ], - "media_types": { - "banner": { - "sizes": [ - [ - 300, - 250 - ] - ] - } - } - } - ] - } - ], - "expectedBidResponses": [ - { - "bids": [ - { - "bid_id": "01", - "imp_id": "001", - "cpm": 1.0, - "cid": "1002088", - "crid": "1000763-1002088", - "adid": "1002088", - "w": "300", - "h": "250", - "seat": "resetdigital", - "html": "" + }] + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 900, + "h": 250 + }, + "type": "video", + "seat": "resetdigital" + }] + }] +} From 0f6f5b1ef64d59dab640980f514c5e4a5016c214 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 25 Oct 2024 12:12:54 +0100 Subject: [PATCH 53/73] created mock test --- adapters/resetdigital/resetdigital.go | 23 ++-- .../exemplary/invalid_video_dim.json | 74 ++++++++++++ .../supplemental/fake_test.json | 69 +++++++++++ .../supplemental/invalid-device.json | 74 ++++++++++++ .../supplemental/invalid_cur.json | 76 ++++++++++++ .../supplemental/invalid_media_def.json | 35 ++++++ .../supplemental/invalid_placement_id.json | 43 +++++++ .../supplemental/multi_format.json | 108 ++++++++++++++++++ .../supplemental/unknown_media.json | 68 +++++++++++ 9 files changed, 559 insertions(+), 11 deletions(-) create mode 100644 adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 70b73c5ac6d..6ea7faf566f 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -223,12 +223,14 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R // handle the error if bid == nil { // it would be better to return an error here + errs = append(errs, err) continue } bidType, err := GetMediaTypeForImp(requestImps, bid.ImpID) if err != nil { - return nil, []error{err} + errs = append(errs, err) + continue } b := &adapters.TypedBid{ @@ -261,18 +263,17 @@ func getBidFromResponse(bidResponse *resetDigitalBid) (*openrtb2.Bid, error) { AdM: bidResponse.HTML, } - if i, err := strconv.ParseInt(bidResponse.W, 10, 64); err == nil && i > 0 { - bid.W = i - } else if err != nil { + w, err := strconv.ParseInt(bidResponse.W, 10, 64) + if err != nil { return nil, err - } // the error should be returned here if ParseInt fails + } + bid.W = w - if i, err := strconv.ParseInt(bidResponse.H, 10, 64); err == nil && i > 0 { - bid.H = i - } else if err != nil { + h, err := strconv.ParseInt(bidResponse.H, 10, 64) + if err != nil { return nil, err - } // the error should be returned here if ParseInt fails - + } + bid.H = h return bid, nil } @@ -298,4 +299,4 @@ func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openr return mediaType, nil } return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID) -} +} \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json b/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json new file mode 100644 index 00000000000..6cbc6cf2be8 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json @@ -0,0 +1,74 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "video": { + "w": 0, + "h": 480, + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500, + "debug": 1 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": null + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 204, + "body": { + "error": "Unexpected status code: 204. Run with request.debug = 1 for more info" + } + } + }], + "expectedBidResponses": [] + } diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json b/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json new file mode 100644 index 00000000000..7cb52868e6c --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json @@ -0,0 +1,69 @@ +{ + "mockBidRequest": { + "id": "test_nil_invalid_impid", + "imp": [ + { + "id": null, + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-7" + } + } + } + ], + "site": { + "domain": "https://example.com", + "page": "https://example.com/page" + }, + "cur": ["USD"], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", + "ip": "192.168.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [ + { + "expectedRequest": { + "method": "POST", + "body": { + "imps": [ + { + "bid_id": "test_nil_invalid_impid", + "imp_id": null, + "media_types": { + "banner": { + "sizes": [[300, 250]] + } + }, + "zone_id": { + "placementId": "placement-id-7" + } + } + ], + "site": { + "domain": "https://example.com", + "referrer": "https://example.com/page" + } + }, + "impIDs": ["006", null, "unknown_imp_id"] + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "bid is nil or imp ID is missing", + "comparison": "literal" + }, + { + "value": "unknown media type for bid imp ID unknown_imp_id", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json new file mode 100644 index 00000000000..6865ffc355c --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json @@ -0,0 +1,74 @@ +{ + "mockBidRequest": { + "id": "test-invalid-device", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ] + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-invalid-device", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 400, + "body": { + "error": "Unexpected status code: 400. Run with request.debug = 1 for more info" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json new file mode 100644 index 00000000000..d148516b1c2 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json @@ -0,0 +1,76 @@ +{ + "mockBidRequest": { + "id": "test-invalid-cur", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + } + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-invalid-cur", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 400, + "body": { + "error": "Unexpected status code: 400. Run with request.debug = 1 for more info" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json new file mode 100644 index 00000000000..0c24e666b9f --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json @@ -0,0 +1,35 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500, + "debug": 1 + }, + "httpCalls": [], + "expectedMakeRequestsErrors": [ + { + "value": "failed to find matching imp for bid 001", + "comparison": "literal" + } + ], + "expectedBidResponses": [] + } \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json new file mode 100644 index 00000000000..14959b36d14 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json @@ -0,0 +1,43 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "video": { + "w": 900, + "h": 250, + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "ext": { + "bidder": { + "placement_id": 1 + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500, + "debug": 1 + }, + "httpCalls": [], + "expectedMakeRequestsErrors": [ + { + "value": "json: cannot unmarshal number into Go struct field ImpExtResetDigital.placement_id of type string", + "comparison": "literal" + } + ], + "expectedBidResponses": [] + } diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json new file mode 100644 index 00000000000..f17e0d149ab --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json @@ -0,0 +1,108 @@ +{ + "mockBidRequest": { + "id": "test-multi-format", + "imp": [{ + "id": "001", + "banner": { + "w": 300, + "h": 600 + }, + "video": { + "w": 900, + "h": 250, + "mimes": ["video/mp4"] + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-multi-format", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 300, + 600 + ] + ] + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + }] + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 300, + "h": 250 + }, + "type": "banner", + "seat": "resetdigital" + }] + }] + } + \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json new file mode 100644 index 00000000000..08cd3f22944 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json @@ -0,0 +1,68 @@ +{ + "mockBidRequest": { + "id": "test-unknown-media-type", + "imp": [{ + "id": "001", + "audio": { + "mimes": ["audio/mpeg"] + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ] + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "test-unknown-media-type", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": null + }, + "video": { + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 400, + "body": { + "error": "unknown media type for bid imp ID 003" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] + } + \ No newline at end of file From 27863dbd75d38d51a2fefda54a0b57104a7d1fc9 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Thu, 31 Oct 2024 15:35:08 +0100 Subject: [PATCH 54/73] delete fake_test.json --- .../supplemental/fake_test.json | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json b/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json deleted file mode 100644 index 7cb52868e6c..00000000000 --- a/adapters/resetdigital/resetdigitaltest/supplemental/fake_test.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "mockBidRequest": { - "id": "test_nil_invalid_impid", - "imp": [ - { - "id": null, - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "placement_id": "placement-id-7" - } - } - } - ], - "site": { - "domain": "https://example.com", - "page": "https://example.com/page" - }, - "cur": ["USD"], - "device": { - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", - "ip": "192.168.0.1", - "language": "EN" - }, - "tmax": 500 - }, - "httpCalls": [ - { - "expectedRequest": { - "method": "POST", - "body": { - "imps": [ - { - "bid_id": "test_nil_invalid_impid", - "imp_id": null, - "media_types": { - "banner": { - "sizes": [[300, 250]] - } - }, - "zone_id": { - "placementId": "placement-id-7" - } - } - ], - "site": { - "domain": "https://example.com", - "referrer": "https://example.com/page" - } - }, - "impIDs": ["006", null, "unknown_imp_id"] - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "bid is nil or imp ID is missing", - "comparison": "literal" - }, - { - "value": "unknown media type for bid imp ID unknown_imp_id", - "comparison": "literal" - } - ] - } - \ No newline at end of file From f0da5d754ab2a9417f6f0ae30de5f4e6a471b756 Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Sun, 3 Nov 2024 15:26:36 -0800 Subject: [PATCH 55/73] Adding support for audio media type and a corresponding simple-audio.json test case. --- -vv | 78 ++++++++ adapters/resetdigital/resetdigital.go | 17 +- .../exemplary/simple-audio.json | 183 ++++++++++++++++++ .../exemplary/simple-banner.json | 6 + .../exemplary/simple-video.json | 170 +++++++++------- .../supplemental/invalid-device.json | 6 + .../supplemental/invalid_cur.json | 6 + .../invalid_video_dim.json | 11 +- .../supplemental/multi_format.json | 6 + .../supplemental/unknown_media.json | 8 +- 10 files changed, 412 insertions(+), 79 deletions(-) create mode 100644 -vv create mode 100644 adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json rename adapters/resetdigital/resetdigitaltest/{exemplary => supplemental}/invalid_video_dim.json (86%) diff --git a/-vv b/-vv new file mode 100644 index 00000000000..28f4857db7b --- /dev/null +++ b/-vv @@ -0,0 +1,78 @@ +mode: set +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:67.119,69.16 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:69.16,71.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:72.2,75.20 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:78.59,81.68 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:81.68,91.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:92.2,92.16 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:95.79,96.39 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:96.39,97.21 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:97.21,99.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:103.141,109.38 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:109.38,111.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:111.17,113.12 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:116.3,117.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:117.17,119.12 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:122.3,123.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:123.17,125.12 2 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:128.3,134.5 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:137.2,137.25 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:140.139,143.29 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:143.29,146.3 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:148.2,153.63 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:153.63,155.26 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:155.26,157.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:158.3,158.26 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:158.26,160.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:161.3,161.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:161.29,166.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:168.2,168.61 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:168.61,170.25 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:170.25,172.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:173.3,173.25 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:173.25,175.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:176.3,176.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:176.29,181.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:183.2,183.61 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:183.62,197.3 0 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:199.2,202.60 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:202.60,204.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:205.2,205.75 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:205.75,207.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:208.2,210.21 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:213.166,214.58 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:214.58,216.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:218.2,218.80 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:218.80,220.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:222.2,223.69 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:223.69,225.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:227.2,231.34 4 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:231.34,233.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:235.2,235.31 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:235.31,240.17 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:240.17,243.12 2 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:246.3,247.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:247.17,249.12 2 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:252.3,257.49 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:260.2,260.27 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:260.27,262.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:264.2,264.26 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:267.78,268.26 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:268.26,271.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:273.2,283.16 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:283.16,285.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:286.2,289.16 3 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:289.16,291.3 1 0 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:292.2,293.17 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:296.64,297.23 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:297.23,299.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:299.8,299.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:299.29,301.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:301.8,301.29 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:301.29,303.3 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:305.2,305.73 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:308.104,311.41 2 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:311.41,312.50 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:312.50,316.4 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:317.3,317.24 1 1 +github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:319.2,319.73 1 0 diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 6ea7faf566f..5f3f4b1b333 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -42,11 +42,12 @@ type resetDigitalImpExt struct { type resetDigitalMediaTypes struct { Banner resetDigitalMediaType `json:"banner"` Video resetDigitalMediaType `json:"video"` + Audio resetDigitalMediaType `json:"audio"` } type resetDigitalMediaType struct { Sizes [][]int64 `json:"sizes"` + Mimes []string `json:"mimes"` } - type resetDigitalBidResponse struct { Bids []resetDigitalBid `json:"bids"` } @@ -178,6 +179,16 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, []int64{tempW, tempH}, ) } + if imp.Video.MIMEs != nil{ + reqData.Imps[0].MediaTypes.Video.Mimes = append( + imp.Video.MIMEs, + ) + } + } + if bidType == openrtb_ext.BidTypeAudio && imp.Audio != nil && imp.Audio.MIMEs != nil{ + reqData.Imps[0].MediaTypes.Audio.Mimes = append( + imp.Audio.MIMEs, + ) } var bidderExt adapters.ExtImpBidder @@ -295,8 +306,10 @@ func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openr if reqImp, ok := reqImps[bidImpID]; ok { if reqImp.Banner == nil && reqImp.Video != nil { mediaType = openrtb_ext.BidTypeVideo + } else if reqImp.Audio != nil { + mediaType = openrtb_ext.BidTypeAudio } return mediaType, nil } return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID) -} \ No newline at end of file +} diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json new file mode 100644 index 00000000000..80ae00517f6 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json @@ -0,0 +1,183 @@ +{ + "mockBidRequest": { + "id": "12345", + "at": 1, + "bcat": [ + "IAB24", + "IAB25", + "IAB26" + ], + "cur": [ + "USD" + ], + "source": { + "fd": 0, + "tid": "00000FBCE10DE8FA", + "schain": { + "complete": 1, + "ver": "1.0", + "nodes": [ + { + "asi": "resetdigital.co", + "sid": "176", + "hp": 1 + } + ] + } + }, + "device": { + "ip": "35.146.176.97", + "js": 1, + "language": "en", + "ua": "PostmanRuntime/7.42.0" + }, + "user": { + "id": "000011200BA1065C", + "buyeruid": "000011200BA1065C" + }, + "app": { + "id": "test.com", + "bundle": "test.com", + "name": "test.com", + "content": { + "livestream": 1, + "genre": "F%C3%BAtbol", + "cat": [ + "" + ], + "language": "es" + }, + "publisher": { + "id": "176" + }, + "keywords": "" + }, + "imp": [ + { + "id": "001", + "bidfloor": 1.429, + "tagid": "667", + "secure": 1, + "audio": { + "protocols": [ + 2, + 3, + 5, + 6 + ], + "mimes": [ + "audio/mp4", + "audio/mp3" + ], + "api": [], + "minduration": 15, + "maxduration": 60, + "startdelay": -1 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + } + ], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 400 + }, + "httpCalls": [ + { + "expectedRequest": { + "method": "POST", + "body": { + "imps": [ + { + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": null, + "mimes": null + }, + "video": { + "sizes": null, + "mimes": null + }, + "audio": { + "sizes": null, + "mimes": [ + "audio/mp4", + "audio/mp3" + ] + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + } + ], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 9.11, + "dealid": "RD-1000164", + "cid": "1000048-1002918", + "crid": "1003893", + "adid": "1003893", + "language": "en", + "w": "0", + "h": "0", + "seat": "resetdigital", + "html": "" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "cid": "1000048-1002918", + "crid": "1003893", + "id": "01", + "impid": "001", + "price": 9.11 + }, + "type": "audio", + "seat": "resetdigital" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index bf22010c6fd..2e4a54c8a57 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -39,6 +39,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 250, @@ -47,6 +48,11 @@ ] }, "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json index 260217be957..0310ed18c46 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json @@ -1,9 +1,10 @@ { "mockBidRequest": { "id": "12345", - "imp": [{ - "id": "001", - "video": { + "imp": [ + { + "id": "001", + "video": { "w": 900, "h": 250, "mimes": [ @@ -11,12 +12,13 @@ "video/mp4" ] }, - "ext": { - "bidder": { - "placement_id": "placement-id-1" + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } } } - }], + ], "site": { "domain": "https://test.com", "page": "https://test.com/2016/06/12" @@ -31,76 +33,94 @@ }, "tmax": 500 }, - "httpCalls": [{ - "expectedRequest": { - "method": "POST", - "body": { - "imps": [{ - "bid_id": "12345", - "ext": { - "gpid": "" - }, - "imp_id": "001", - "media_types": { - "banner": { - "sizes": null - }, - "video": { - "sizes": [ - [ - 900, - 250 - ] - ] + "httpCalls": [ + { + "expectedRequest": { + "method": "POST", + "body": { + "imps": [ + { + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "mimes": null, + "sizes": null + }, + "video": { + "sizes": [ + [ + 900, + 250 + ] + ], + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "audio": { + "mimes": null, + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } } - }, - "zone_id": { - "placementId": "placement-id-1" + ], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" } - }], - "site": { - "domain": "https://test.com", - "referrer": "https://test.com/2016/06/12" - } + }, + "impIDs": [ + "001" + ] }, - "impIDs": [ - "001" - ] - }, - "mockResponse": { - "status": 200, - "body": { - "bids": [{ - "bid_id": "01", - "imp_id": "001", - "cpm": 1.00, - "cid": "1002088", - "crid": "1000763-1002088", - "adid": "1002088", - "w": "900", - "h": "250", - "seat": "resetdigital", - "html": "" - }] + "mockResponse": { + "status": 200, + "body": { + "bids": [ + { + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "900", + "h": "250", + "seat": "resetdigital", + "html": "" + } + ] + } } } - }], - - "expectedBidResponses": [{ - "currency": "USD", - "bids": [{ - "bid": { - "adm": "", - "cid": "1002088", - "crid": "1000763-1002088", - "id": "01", - "impid": "001", - "price": 1.00, - "w": 900, - "h": 250 - }, - "type": "video", - "seat": "resetdigital" - }] - }] -} + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 900, + "h": 250 + }, + "type": "video", + "seat": "resetdigital" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json index 6865ffc355c..fca85c84d4a 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json @@ -33,6 +33,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 250, @@ -41,6 +42,11 @@ ] }, "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json index d148516b1c2..878d9c07289 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json @@ -35,6 +35,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 250, @@ -43,6 +44,11 @@ ] }, "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json similarity index 86% rename from adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json rename to adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json index 6cbc6cf2be8..9a955ccb6a2 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/invalid_video_dim.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json @@ -44,9 +44,18 @@ "imp_id": "001", "media_types": { "banner": { - "sizes": null + "mimes": null, + "sizes": null }, "video": { + "sizes": null, + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json index f17e0d149ab..66a441f6506 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json @@ -44,6 +44,7 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": [ [ 300, @@ -52,6 +53,11 @@ ] }, "video": { + "sizes": null, + "mimes": null + }, + "audio": { + "mimes": null, "sizes": null } }, diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json index 08cd3f22944..2d42bf5ddd4 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json @@ -32,10 +32,16 @@ "imp_id": "001", "media_types": { "banner": { + "mimes": null, "sizes": null }, "video": { - "sizes": null + "mimes": null, + "sizes": null + }, + "audio": { + "sizes": null, + "mimes": ["audio/mpeg"] } }, "zone_id": { From 6c745fbefa9cb78c4a481a3d710979624cef5ebe Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Mon, 4 Nov 2024 12:10:03 -0800 Subject: [PATCH 56/73] Fix slice append syntax. --- adapters/resetdigital/resetdigital.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 5f3f4b1b333..69f0fdd2375 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -46,7 +46,7 @@ type resetDigitalMediaTypes struct { } type resetDigitalMediaType struct { Sizes [][]int64 `json:"sizes"` - Mimes []string `json:"mimes"` + Mimes []string `json:"mimes"` } type resetDigitalBidResponse struct { Bids []resetDigitalBid `json:"bids"` @@ -179,15 +179,18 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, []int64{tempW, tempH}, ) } - if imp.Video.MIMEs != nil{ + if imp.Video.MIMEs != nil { + // reqData.Imps[0].MediaTypes.Video.Mimes = imp.Video.MIMEs reqData.Imps[0].MediaTypes.Video.Mimes = append( - imp.Video.MIMEs, + reqData.Imps[0].MediaTypes.Video.Mimes, + imp.Video.MIMEs..., ) } } - if bidType == openrtb_ext.BidTypeAudio && imp.Audio != nil && imp.Audio.MIMEs != nil{ + if bidType == openrtb_ext.BidTypeAudio && imp.Audio != nil && imp.Audio.MIMEs != nil { reqData.Imps[0].MediaTypes.Audio.Mimes = append( - imp.Audio.MIMEs, + reqData.Imps[0].MediaTypes.Audio.Mimes, + imp.Audio.MIMEs..., ) } From 56b03f123d12d3c4679a5f949f566ed600016694 Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Mon, 4 Nov 2024 12:26:23 -0800 Subject: [PATCH 57/73] Removed zero check for bid response and moved HTTP headers into separate conditionals as requested by Brian Sardo. --- adapters/resetdigital/resetdigital.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 69f0fdd2375..3e56ed460bd 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -78,17 +78,25 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} - if request != nil && request.Device != nil && request.Site != nil { // what about request.App? Do we need to do something different with Referrer in the app case assuming we care about app? + addNonEmptyHeaders(&headers, map[string]string{ + "Content-Type": "application/json;charset=utf-8", + "Accept": "application/json", + }) + + if request != nil && request.Device != nil { addNonEmptyHeaders(&headers, map[string]string{ - "Referer": request.Site.Page, "Accept-Language": request.Device.Language, "User-Agent": request.Device.UA, "X-Forwarded-For": request.Device.IP, "X-Real-Ip": request.Device.IP, - "Content-Type": "application/json;charset=utf-8", - "Accept": "application/json", }) } + if request != nil && request.Site != nil { + addNonEmptyHeaders(&headers, map[string]string{ + "Referer": request.Site.Page, + }) + } + return headers } @@ -263,10 +271,6 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } func getBidFromResponse(bidResponse *resetDigitalBid) (*openrtb2.Bid, error) { - if bidResponse.CPM == 0 { - // brian to check how to report this - return nil, nil - } bid := &openrtb2.Bid{ ID: bidResponse.BidID, From 21eecddcf00a3c1eddca416567e3929eb6025b12 Mon Sep 17 00:00:00 2001 From: Dirk Merkel Date: Mon, 4 Nov 2024 12:47:00 -0800 Subject: [PATCH 58/73] Adding test case for missing currency to improve test coverage percentage. --- .../supplemental/missing-currency.json | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json b/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json new file mode 100644 index 00000000000..35bf5f7165e --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json @@ -0,0 +1,105 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "mimes": null, + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": { + "mimes": null, + "sizes": null + }, + "audio": { + "mimes": null, + "sizes": null + } + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "" + }] + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 300, + "h": 250 + }, + "type": "banner", + "seat": "resetdigital" + }] + }] +} From 2584c6bac38e3613ffc5cccfcd82bbc6a0d40f90 Mon Sep 17 00:00:00 2001 From: Bruno Jacinto Date: Mon, 4 Nov 2024 22:20:19 +0000 Subject: [PATCH 59/73] Changing the version to V3 Making the last version of the objects to the V3 of openRTB --- adapters/resetdigital/resetdigital.go | 6 +++--- adapters/resetdigital/resetdigital_test.go | 6 +++--- exchange/adapter_builders.go | 2 +- go.mod | 1 + go.sum | 2 ++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 3e56ed460bd..3aace820035 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -8,9 +8,9 @@ import ( "text/template" "github.com/prebid/openrtb/v20/openrtb2" - "github.com/prebid/prebid-server/v2/adapters" - "github.com/prebid/prebid-server/v2/config" - "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v3/adapters" + "github.com/prebid/prebid-server/v3/config" + "github.com/prebid/prebid-server/v3/openrtb_ext" ) type adapter struct { diff --git a/adapters/resetdigital/resetdigital_test.go b/adapters/resetdigital/resetdigital_test.go index d160e9a23fe..9efba33f301 100644 --- a/adapters/resetdigital/resetdigital_test.go +++ b/adapters/resetdigital/resetdigital_test.go @@ -3,9 +3,9 @@ package resetdigital import ( "testing" - "github.com/prebid/prebid-server/v2/adapters/adapterstest" - "github.com/prebid/prebid-server/v2/config" - "github.com/prebid/prebid-server/v2/openrtb_ext" + "github.com/prebid/prebid-server/v3/adapters/adapterstest" + "github.com/prebid/prebid-server/v3/config" + "github.com/prebid/prebid-server/v3/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index fc76b715be9..aad457beef0 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -164,6 +164,7 @@ import ( "github.com/prebid/prebid-server/v3/adapters/qt" "github.com/prebid/prebid-server/v3/adapters/readpeak" "github.com/prebid/prebid-server/v3/adapters/relevantdigital" + "github.com/prebid/prebid-server/v3/adapters/resetdigital" "github.com/prebid/prebid-server/v3/adapters/revcontent" "github.com/prebid/prebid-server/v3/adapters/richaudience" "github.com/prebid/prebid-server/v3/adapters/rise" @@ -224,7 +225,6 @@ import ( "github.com/prebid/prebid-server/v3/adapters/zeta_global_ssp" "github.com/prebid/prebid-server/v3/adapters/zmaticoo" "github.com/prebid/prebid-server/v3/openrtb_ext" - "github.com/prebid/prebid-server/v2/adapters/resetdigital" ) // Adapter registration is kept in this separate file for ease of use and to aid diff --git a/go.mod b/go.mod index e844fe5bf25..c199310739b 100644 --- a/go.mod +++ b/go.mod @@ -61,6 +61,7 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prebid/prebid-server/v2 v2.32.0 github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/sergi/go-diff v1.2.0 // indirect diff --git a/go.sum b/go.sum index a6a6226c616..00f42ae8bbe 100644 --- a/go.sum +++ b/go.sum @@ -410,6 +410,8 @@ github.com/prebid/go-gpp v0.2.0 h1:41Ssxd4Zxr50WgwG1q/1+6awGU3pFnwV7FR4XCLQSuM= github.com/prebid/go-gpp v0.2.0/go.mod h1:b0TLoVln+HXFD9L9xeimxIH3FN8WDKPJ42auslxEkow= github.com/prebid/openrtb/v20 v20.1.0 h1:Rb+Z3H3UxiqqnjgJK3R9Wt73ibrh7HPzG7ikBckQNqc= github.com/prebid/openrtb/v20 v20.1.0/go.mod h1:hLBrA/APkSrxs5MaW639l+y/EAHivDfRagO2TX/wbSc= +github.com/prebid/prebid-server/v2 v2.32.0 h1:E+zX1CGtWjkUTPQzMKHMEsn26yGDnZI6znG1rgxosQo= +github.com/prebid/prebid-server/v2 v2.32.0/go.mod h1:wyuZeJWIWtt+D5YWN/CL+t9IklM/Gof5YBs+Urt1tHM= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= From 123cb134141497fcbb1943a4d2715412572bde29 Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Wed, 20 Nov 2024 21:34:26 -0800 Subject: [PATCH 60/73] Renaming test JSON files --- .../supplemental/{invalid_cur.json => invalid-cur.json} | 0 .../{invalid_media_def.json => invalid-media-def.json} | 0 .../{invalid_placement_id.json => invalid-placement-id.json} | 0 .../{invalid_video_dim.json => invalid-video-dim.json} | 0 .../supplemental/{multi_format.json => multi-format.json} | 0 .../supplemental/{unknown_media.json => unknown-media.json} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename adapters/resetdigital/resetdigitaltest/supplemental/{invalid_cur.json => invalid-cur.json} (100%) rename adapters/resetdigital/resetdigitaltest/supplemental/{invalid_media_def.json => invalid-media-def.json} (100%) rename adapters/resetdigital/resetdigitaltest/supplemental/{invalid_placement_id.json => invalid-placement-id.json} (100%) rename adapters/resetdigital/resetdigitaltest/supplemental/{invalid_video_dim.json => invalid-video-dim.json} (100%) rename adapters/resetdigital/resetdigitaltest/supplemental/{multi_format.json => multi-format.json} (100%) rename adapters/resetdigital/resetdigitaltest/supplemental/{unknown_media.json => unknown-media.json} (100%) diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-cur.json similarity index 100% rename from adapters/resetdigital/resetdigitaltest/supplemental/invalid_cur.json rename to adapters/resetdigital/resetdigitaltest/supplemental/invalid-cur.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-media-def.json similarity index 100% rename from adapters/resetdigital/resetdigitaltest/supplemental/invalid_media_def.json rename to adapters/resetdigital/resetdigitaltest/supplemental/invalid-media-def.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-placement-id.json similarity index 100% rename from adapters/resetdigital/resetdigitaltest/supplemental/invalid_placement_id.json rename to adapters/resetdigital/resetdigitaltest/supplemental/invalid-placement-id.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-video-dim.json similarity index 100% rename from adapters/resetdigital/resetdigitaltest/supplemental/invalid_video_dim.json rename to adapters/resetdigital/resetdigitaltest/supplemental/invalid-video-dim.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json b/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json similarity index 100% rename from adapters/resetdigital/resetdigitaltest/supplemental/multi_format.json rename to adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json b/adapters/resetdigital/resetdigitaltest/supplemental/unknown-media.json similarity index 100% rename from adapters/resetdigital/resetdigitaltest/supplemental/unknown_media.json rename to adapters/resetdigital/resetdigitaltest/supplemental/unknown-media.json From 4950da13c1bbac6aff78c82b45b96fc45dd7c78c Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Wed, 20 Nov 2024 21:34:59 -0800 Subject: [PATCH 61/73] Deleting errant -vv file --- -vv | 78 ------------------------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 -vv diff --git a/-vv b/-vv deleted file mode 100644 index 28f4857db7b..00000000000 --- a/-vv +++ /dev/null @@ -1,78 +0,0 @@ -mode: set -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:67.119,69.16 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:69.16,71.3 1 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:72.2,75.20 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:78.59,81.68 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:81.68,91.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:92.2,92.16 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:95.79,96.39 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:96.39,97.21 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:97.21,99.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:103.141,109.38 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:109.38,111.17 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:111.17,113.12 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:116.3,117.17 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:117.17,119.12 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:122.3,123.17 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:123.17,125.12 2 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:128.3,134.5 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:137.2,137.25 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:140.139,143.29 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:143.29,146.3 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:148.2,153.63 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:153.63,155.26 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:155.26,157.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:158.3,158.26 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:158.26,160.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:161.3,161.29 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:161.29,166.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:168.2,168.61 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:168.61,170.25 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:170.25,172.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:173.3,173.25 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:173.25,175.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:176.3,176.29 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:176.29,181.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:183.2,183.61 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:183.62,197.3 0 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:199.2,202.60 3 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:202.60,204.3 1 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:205.2,205.75 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:205.75,207.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:208.2,210.21 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:213.166,214.58 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:214.58,216.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:218.2,218.80 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:218.80,220.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:222.2,223.69 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:223.69,225.3 1 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:227.2,231.34 4 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:231.34,233.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:235.2,235.31 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:235.31,240.17 3 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:240.17,243.12 2 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:246.3,247.17 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:247.17,249.12 2 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:252.3,257.49 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:260.2,260.27 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:260.27,262.3 1 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:264.2,264.26 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:267.78,268.26 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:268.26,271.3 1 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:273.2,283.16 3 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:283.16,285.3 1 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:286.2,289.16 3 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:289.16,291.3 1 0 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:292.2,293.17 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:296.64,297.23 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:297.23,299.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:299.8,299.29 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:299.29,301.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:301.8,301.29 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:301.29,303.3 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:305.2,305.73 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:308.104,311.41 2 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:311.41,312.50 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:312.50,316.4 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:317.3,317.24 1 1 -github.com/prebid/prebid-server/v2/adapters/resetdigital/resetdigital.go:319.2,319.73 1 0 From cc06d05d7feed197f1e035e58ccf5a2f6a2b0a4d Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Thu, 21 Nov 2024 08:28:33 -0800 Subject: [PATCH 62/73] Simplying HTML test markup. --- .../resetdigital/resetdigitaltest/exemplary/simple-audio.json | 4 ++-- .../resetdigitaltest/exemplary/simple-banner.json | 4 ++-- .../resetdigital/resetdigitaltest/exemplary/simple-video.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json index 80ae00517f6..d848bf29b29 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json @@ -154,7 +154,7 @@ "w": "0", "h": "0", "seat": "resetdigital", - "html": "" + "html": "test markup" } ] } @@ -167,7 +167,7 @@ "bids": [ { "bid": { - "adm": "", + "adm": "test markup", "cid": "1000048-1002918", "crid": "1003893", "id": "01", diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index 2e4a54c8a57..8e46be18e3a 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -82,7 +82,7 @@ "w": "300", "h": "250", "seat": "resetdigital", - "html": "" + "html": "test markup" }] } } @@ -92,7 +92,7 @@ "currency": "USD", "bids": [{ "bid": { - "adm": "", + "adm": "test markup", "cid": "1002088", "crid": "1000763-1002088", "id": "01", diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json index 0310ed18c46..d4d9520f483 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json @@ -95,7 +95,7 @@ "w": "900", "h": "250", "seat": "resetdigital", - "html": "" + "html": "test markup" } ] } @@ -108,7 +108,7 @@ "bids": [ { "bid": { - "adm": "", + "adm": "test markup", "cid": "1002088", "crid": "1000763-1002088", "id": "01", From 330d84f030947dc1448af1e8f7db61820e34e135 Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 24 Nov 2024 17:48:58 -0800 Subject: [PATCH 63/73] Reverting unnecessary changes. --- go.mod | 1 - go.sum | 2 -- 2 files changed, 3 deletions(-) diff --git a/go.mod b/go.mod index c199310739b..e844fe5bf25 100644 --- a/go.mod +++ b/go.mod @@ -61,7 +61,6 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prebid/prebid-server/v2 v2.32.0 github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/sergi/go-diff v1.2.0 // indirect diff --git a/go.sum b/go.sum index 00f42ae8bbe..a6a6226c616 100644 --- a/go.sum +++ b/go.sum @@ -410,8 +410,6 @@ github.com/prebid/go-gpp v0.2.0 h1:41Ssxd4Zxr50WgwG1q/1+6awGU3pFnwV7FR4XCLQSuM= github.com/prebid/go-gpp v0.2.0/go.mod h1:b0TLoVln+HXFD9L9xeimxIH3FN8WDKPJ42auslxEkow= github.com/prebid/openrtb/v20 v20.1.0 h1:Rb+Z3H3UxiqqnjgJK3R9Wt73ibrh7HPzG7ikBckQNqc= github.com/prebid/openrtb/v20 v20.1.0/go.mod h1:hLBrA/APkSrxs5MaW639l+y/EAHivDfRagO2TX/wbSc= -github.com/prebid/prebid-server/v2 v2.32.0 h1:E+zX1CGtWjkUTPQzMKHMEsn26yGDnZI6znG1rgxosQo= -github.com/prebid/prebid-server/v2 v2.32.0/go.mod h1:wyuZeJWIWtt+D5YWN/CL+t9IklM/Gof5YBs+Urt1tHM= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= From 17cf6c81445fcb2f418a72cd4cfc423cbe6851af Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 1 Dec 2024 14:18:46 -0800 Subject: [PATCH 64/73] Adding test cases via JSON to increase coverage. --- .../supplemental/invalid-bid-height.json | 91 ++++++++++++++++ .../supplemental/invalid-bid-media-type.json | 102 ++++++++++++++++++ .../supplemental/invalid-bid-width.json | 91 ++++++++++++++++ 3 files changed, 284 insertions(+) create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-height.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json create mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-width.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-height.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-height.json new file mode 100644 index 00000000000..c197f9cb7da --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-height.json @@ -0,0 +1,91 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": {}, + "audio": {} + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "123456789012345678901234567890123456789012345678901234567890", + "seat": "resetdigital", + "html": "test markup" + }] + } + } + }], + + "expectedMakeBidsErrors": [ + { + "value": "strconv.ParseInt: parsing \"123456789012345678901234567890123456789012345678901234567890\": value out of range", + "comparison": "literal" + } + ], + "expectedBidResponses": [{}] +} diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json new file mode 100644 index 00000000000..913350860b9 --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json @@ -0,0 +1,102 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": {}, + "audio": {} + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "300", + "h": "250", + "seat": "resetdigital", + "html": "test markup", + "mtype": "native" + }] + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "test markup", + "cid": "1002088", + "crid": "1000763-1002088", + "id": "01", + "impid": "001", + "price": 1.00, + "w": 300, + "h": 250 + }, + "type": "banner", + "seat": "resetdigital" + }] + }] +} diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-width.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-width.json new file mode 100644 index 00000000000..bba60c6bdac --- /dev/null +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-width.json @@ -0,0 +1,91 @@ +{ + "mockBidRequest": { + "id": "12345", + "imp": [{ + "id": "001", + "banner": { + "h": 300, + "w": 250 + }, + "ext": { + "bidder": { + "placement_id": "placement-id-1" + } + } + }], + "site": { + "domain": "https://test.com", + "page": "https://test.com/2016/06/12" + }, + "cur": [ + "USD" + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + "ip": "127.0.0.1", + "language": "EN" + }, + "tmax": 500 + }, + "httpCalls": [{ + "expectedRequest": { + "method": "POST", + "body": { + "imps": [{ + "bid_id": "12345", + "ext": { + "gpid": "" + }, + "imp_id": "001", + "media_types": { + "banner": { + "sizes": [ + [ + 250, + 300 + ] + ] + }, + "video": {}, + "audio": {} + }, + "zone_id": { + "placementId": "placement-id-1" + } + }], + "site": { + "domain": "https://test.com", + "referrer": "https://test.com/2016/06/12" + } + }, + "impIDs": [ + "001" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "bids": [{ + "bid_id": "01", + "imp_id": "001", + "cpm": 1.00, + "cid": "1002088", + "crid": "1000763-1002088", + "adid": "1002088", + "w": "123456789012345678901234567890123456789012345678901234567890", + "h": "250", + "seat": "resetdigital", + "html": "test markup" + }] + } + } + }], + + "expectedMakeBidsErrors": [ + { + "value": "strconv.ParseInt: parsing \"123456789012345678901234567890123456789012345678901234567890\": value out of range", + "comparison": "literal" + } + ], + "expectedBidResponses": [{}] +} From 5b4428048a9f725bd025ae036f173b517760286a Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 1 Dec 2024 14:21:53 -0800 Subject: [PATCH 65/73] Removing keys with null values. --- .../resetdigitaltest/exemplary/simple-audio.json | 11 ++--------- .../resetdigitaltest/exemplary/simple-banner.json | 11 ++--------- .../resetdigitaltest/exemplary/simple-video.json | 10 ++-------- .../supplemental/invalid-cur.json | 11 ++--------- .../supplemental/invalid-device.json | 11 ++--------- .../supplemental/invalid-video-dim.json | 11 ++--------- .../supplemental/missing-currency.json | 15 ++++----------- .../supplemental/multi-format.json | 11 ++--------- .../supplemental/unknown-media.json | 11 ++--------- 9 files changed, 20 insertions(+), 82 deletions(-) diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json index d848bf29b29..d032b4c6f37 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-audio.json @@ -108,16 +108,9 @@ }, "imp_id": "001", "media_types": { - "banner": { - "sizes": null, - "mimes": null - }, - "video": { - "sizes": null, - "mimes": null - }, + "banner": {}, + "video": {}, "audio": { - "sizes": null, "mimes": [ "audio/mp4", "audio/mp3" diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json index 8e46be18e3a..2a0fcacd558 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-banner.json @@ -39,7 +39,6 @@ "imp_id": "001", "media_types": { "banner": { - "mimes": null, "sizes": [ [ 250, @@ -47,14 +46,8 @@ ] ] }, - "video": { - "mimes": null, - "sizes": null - }, - "audio": { - "mimes": null, - "sizes": null - } + "audio": {}, + "video": {} }, "zone_id": { "placementId": "placement-id-1" diff --git a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json index d4d9520f483..ce4e1916fd1 100644 --- a/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json +++ b/adapters/resetdigital/resetdigitaltest/exemplary/simple-video.json @@ -46,10 +46,7 @@ }, "imp_id": "001", "media_types": { - "banner": { - "mimes": null, - "sizes": null - }, + "banner": {}, "video": { "sizes": [ [ @@ -62,10 +59,7 @@ "video/mp4" ] }, - "audio": { - "mimes": null, - "sizes": null - } + "audio": {} }, "zone_id": { "placementId": "placement-id-1" diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-cur.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-cur.json index 878d9c07289..3dcf7a76566 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-cur.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-cur.json @@ -35,7 +35,6 @@ "imp_id": "001", "media_types": { "banner": { - "mimes": null, "sizes": [ [ 250, @@ -43,14 +42,8 @@ ] ] }, - "video": { - "mimes": null, - "sizes": null - }, - "audio": { - "mimes": null, - "sizes": null - } + "video": {}, + "audio": {} }, "zone_id": { "placementId": "placement-id-1" diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json index fca85c84d4a..7b0fc8c2645 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-device.json @@ -33,7 +33,6 @@ "imp_id": "001", "media_types": { "banner": { - "mimes": null, "sizes": [ [ 250, @@ -41,14 +40,8 @@ ] ] }, - "video": { - "mimes": null, - "sizes": null - }, - "audio": { - "mimes": null, - "sizes": null - } + "video": {}, + "audio": {} }, "zone_id": { "placementId": "placement-id-1" diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-video-dim.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-video-dim.json index 9a955ccb6a2..4e1f43d13fb 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-video-dim.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-video-dim.json @@ -43,21 +43,14 @@ }, "imp_id": "001", "media_types": { - "banner": { - "mimes": null, - "sizes": null - }, + "banner": {}, "video": { - "sizes": null, "mimes": [ "video/x-flv", "video/mp4" ] }, - "audio": { - "mimes": null, - "sizes": null - } + "audio": {} }, "zone_id": { "placementId": "placement-id-1" diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json b/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json index 35bf5f7165e..bd438f78574 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/missing-currency.json @@ -36,7 +36,6 @@ "imp_id": "001", "media_types": { "banner": { - "mimes": null, "sizes": [ [ 250, @@ -44,14 +43,8 @@ ] ] }, - "video": { - "mimes": null, - "sizes": null - }, - "audio": { - "mimes": null, - "sizes": null - } + "video": {}, + "audio": {} }, "zone_id": { "placementId": "placement-id-1" @@ -79,7 +72,7 @@ "w": "300", "h": "250", "seat": "resetdigital", - "html": "" + "html": "test markup" }] } } @@ -89,7 +82,7 @@ "currency": "USD", "bids": [{ "bid": { - "adm": "", + "adm": "test markup", "cid": "1002088", "crid": "1000763-1002088", "id": "01", diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json b/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json index 66a441f6506..d2a4f1c5ed0 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json @@ -44,7 +44,6 @@ "imp_id": "001", "media_types": { "banner": { - "mimes": null, "sizes": [ [ 300, @@ -52,14 +51,8 @@ ] ] }, - "video": { - "sizes": null, - "mimes": null - }, - "audio": { - "mimes": null, - "sizes": null - } + "video": {}, + "audio": {} }, "zone_id": { "placementId": "placement-id-1" diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/unknown-media.json b/adapters/resetdigital/resetdigitaltest/supplemental/unknown-media.json index 2d42bf5ddd4..5d9fb57363d 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/unknown-media.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/unknown-media.json @@ -31,16 +31,9 @@ }, "imp_id": "001", "media_types": { - "banner": { - "mimes": null, - "sizes": null - }, - "video": { - "mimes": null, - "sizes": null - }, + "banner": {}, + "video": {}, "audio": { - "sizes": null, "mimes": ["audio/mpeg"] } }, From ee3546c351baca145f101b0489263ccc41edeb91 Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 1 Dec 2024 14:22:28 -0800 Subject: [PATCH 66/73] Removing unnecessary keys and fixing redirect URL. --- static/bidder-info/resetdigital.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/static/bidder-info/resetdigital.yaml b/static/bidder-info/resetdigital.yaml index 3c4a206389a..db4e70ae768 100644 --- a/static/bidder-info/resetdigital.yaml +++ b/static/bidder-info/resetdigital.yaml @@ -9,8 +9,6 @@ capabilities: - audio gvlVendorID: 1162 userSync: - key: resetdigital - supportCors: false redirect: - url: https://sync.resetdigital.co/csync?pid=rubicon&redir={{redirect_url}} + url: https://sync.resetdigital.co/csync?redir={{.RedirectURL}} userMacro: '$USER_ID' From 2ecc9a8d54d341fc5b03d4c0d780c8cff2215d9b Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 1 Dec 2024 14:28:14 -0800 Subject: [PATCH 67/73] Ignore test coverage output. --- adapters/resetdigital/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 adapters/resetdigital/.gitignore diff --git a/adapters/resetdigital/.gitignore b/adapters/resetdigital/.gitignore new file mode 100644 index 00000000000..36331304238 --- /dev/null +++ b/adapters/resetdigital/.gitignore @@ -0,0 +1,2 @@ +# Ignore test coverage output +cover.out From 0a4d9bc65b4385fd6424b450885b3f9651fd21af Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 1 Dec 2024 15:29:21 -0800 Subject: [PATCH 68/73] Remove unnecessary test case. --- .../supplemental/invalid-bid-media-type.json | 102 ------------------ .../supplemental/multi-format.json | 2 +- 2 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json b/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json deleted file mode 100644 index 913350860b9..00000000000 --- a/adapters/resetdigital/resetdigitaltest/supplemental/invalid-bid-media-type.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "mockBidRequest": { - "id": "12345", - "imp": [{ - "id": "001", - "banner": { - "h": 300, - "w": 250 - }, - "ext": { - "bidder": { - "placement_id": "placement-id-1" - } - } - }], - "site": { - "domain": "https://test.com", - "page": "https://test.com/2016/06/12" - }, - "cur": [ - "USD" - ], - "device": { - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", - "ip": "127.0.0.1", - "language": "EN" - }, - "tmax": 500 - }, - "httpCalls": [{ - "expectedRequest": { - "method": "POST", - "body": { - "imps": [{ - "bid_id": "12345", - "ext": { - "gpid": "" - }, - "imp_id": "001", - "media_types": { - "banner": { - "sizes": [ - [ - 250, - 300 - ] - ] - }, - "video": {}, - "audio": {} - }, - "zone_id": { - "placementId": "placement-id-1" - } - }], - "site": { - "domain": "https://test.com", - "referrer": "https://test.com/2016/06/12" - } - }, - "impIDs": [ - "001" - ] - }, - "mockResponse": { - "status": 200, - "body": { - "bids": [{ - "bid_id": "01", - "imp_id": "001", - "cpm": 1.00, - "cid": "1002088", - "crid": "1000763-1002088", - "adid": "1002088", - "w": "300", - "h": "250", - "seat": "resetdigital", - "html": "test markup", - "mtype": "native" - }] - } - } - }], - - "expectedBidResponses": [{ - "currency": "USD", - "bids": [{ - "bid": { - "adm": "test markup", - "cid": "1002088", - "crid": "1000763-1002088", - "id": "01", - "impid": "001", - "price": 1.00, - "w": 300, - "h": 250 - }, - "type": "banner", - "seat": "resetdigital" - }] - }] -} diff --git a/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json b/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json index d2a4f1c5ed0..4de554752ff 100644 --- a/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json +++ b/adapters/resetdigital/resetdigitaltest/supplemental/multi-format.json @@ -99,7 +99,7 @@ "w": 300, "h": 250 }, - "type": "banner", + "type": "video", "seat": "resetdigital" }] }] From b93dca3827522834864cd8d02a87eda4e153fe1a Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 1 Dec 2024 15:30:39 -0800 Subject: [PATCH 69/73] Formattting; removed comments; simplified GetMediaTypeForImp. --- adapters/resetdigital/resetdigital.go | 61 ++++++++++----------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index 3aace820035..fec83a1e0ec 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -40,13 +40,13 @@ type resetDigitalImpExt struct { Gpid string `json:"gpid"` } type resetDigitalMediaTypes struct { - Banner resetDigitalMediaType `json:"banner"` - Video resetDigitalMediaType `json:"video"` - Audio resetDigitalMediaType `json:"audio"` + Banner resetDigitalMediaType `json:"banner,omitempty"` + Video resetDigitalMediaType `json:"video,omitempty"` + Audio resetDigitalMediaType `json:"audio,omitempty"` } type resetDigitalMediaType struct { - Sizes [][]int64 `json:"sizes"` - Mimes []string `json:"mimes"` + Sizes [][]int64 `json:"sizes,omitempty"` + Mimes []string `json:"mimes,omitempty"` } type resetDigitalBidResponse struct { Bids []resetDigitalBid `json:"bids"` @@ -128,6 +128,7 @@ func (a *adapter) MakeRequests(requestData *openrtb2.BidRequest, requestInfo *ad } requestBody, err := json.Marshal(splittedRequestData) + if err != nil { errors = append(errors, err) continue @@ -153,10 +154,10 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, reqData.Site.Referrer = requestData.Site.Page } - reqData.Imps = append(reqData.Imps, resetDigitalImp{ + rdImp := resetDigitalImp{ BidID: requestData.ID, ImpID: imp.ID, - }) + } if bidType == openrtb_ext.BidTypeBanner && imp.Banner != nil { var tempH, tempW int64 @@ -167,10 +168,7 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, tempW = *imp.Banner.W } if tempH > 0 && tempW > 0 { - reqData.Imps[0].MediaTypes.Banner.Sizes = append( - reqData.Imps[0].MediaTypes.Banner.Sizes, - []int64{tempW, tempH}, - ) + rdImp.MediaTypes.Banner.Sizes = append(rdImp.MediaTypes.Banner.Sizes, []int64{tempW, tempH}) } } if bidType == openrtb_ext.BidTypeVideo && imp.Video != nil { @@ -182,24 +180,14 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, tempW = *imp.Video.W } if tempH > 0 && tempW > 0 { - reqData.Imps[0].MediaTypes.Video.Sizes = append( - reqData.Imps[0].MediaTypes.Video.Sizes, - []int64{tempW, tempH}, - ) + rdImp.MediaTypes.Video.Sizes = append(rdImp.MediaTypes.Video.Sizes, []int64{tempW, tempH}) } if imp.Video.MIMEs != nil { - // reqData.Imps[0].MediaTypes.Video.Mimes = imp.Video.MIMEs - reqData.Imps[0].MediaTypes.Video.Mimes = append( - reqData.Imps[0].MediaTypes.Video.Mimes, - imp.Video.MIMEs..., - ) + rdImp.MediaTypes.Video.Mimes = append(rdImp.MediaTypes.Video.Mimes, imp.Video.MIMEs...) } } if bidType == openrtb_ext.BidTypeAudio && imp.Audio != nil && imp.Audio.MIMEs != nil { - reqData.Imps[0].MediaTypes.Audio.Mimes = append( - reqData.Imps[0].MediaTypes.Audio.Mimes, - imp.Audio.MIMEs..., - ) + rdImp.MediaTypes.Audio.Mimes = append(rdImp.MediaTypes.Audio.Mimes, imp.Audio.MIMEs...) } var bidderExt adapters.ExtImpBidder @@ -211,7 +199,9 @@ func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, if err := json.Unmarshal(bidderExt.Bidder, &resetDigitalExt); err != nil { return resetDigitalRequest{}, err } - reqData.Imps[0].ZoneID.PlacementID = resetDigitalExt.PlacementID + rdImp.ZoneID.PlacementID = resetDigitalExt.PlacementID + + reqData.Imps = append(reqData.Imps, rdImp) return reqData, nil } @@ -242,14 +232,12 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R resetDigitalBid := &response.Bids[i] bid, err := getBidFromResponse(resetDigitalBid) - // handle the error if bid == nil { - // it would be better to return an error here errs = append(errs, err) continue } - bidType, err := GetMediaTypeForImp(requestImps, bid.ImpID) + bidType, err := GetMediaTypeForImp(requestImps[bid.ImpID]) if err != nil { errs = append(errs, err) continue @@ -307,16 +295,13 @@ func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID) } -func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openrtb_ext.BidType, error) { - mediaType := openrtb_ext.BidTypeBanner +func GetMediaTypeForImp(reqImp openrtb2.Imp) (openrtb_ext.BidType, error) { - if reqImp, ok := reqImps[bidImpID]; ok { - if reqImp.Banner == nil && reqImp.Video != nil { - mediaType = openrtb_ext.BidTypeVideo - } else if reqImp.Audio != nil { - mediaType = openrtb_ext.BidTypeAudio - } - return mediaType, nil + if reqImp.Video != nil { + return openrtb_ext.BidTypeVideo, nil + } + if reqImp.Audio != nil { + return openrtb_ext.BidTypeAudio, nil } - return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID) + return openrtb_ext.BidTypeBanner, nil } From 62f74c1de03edaa4cd6f195e5274f75244a49e36 Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sat, 21 Dec 2024 16:44:43 -0800 Subject: [PATCH 70/73] Move line to restore alpha order. --- exchange/adapter_builders.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index aad457beef0..d200aadaeb7 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -397,8 +397,8 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderQT: qt.Builder, openrtb_ext.BidderReadpeak: readpeak.Builder, openrtb_ext.BidderRelevantDigital: relevantdigital.Builder, - openrtb_ext.BidderRevcontent: revcontent.Builder, openrtb_ext.BidderResetDigital: resetdigital.Builder, + openrtb_ext.BidderRevcontent: revcontent.Builder, openrtb_ext.BidderRichaudience: richaudience.Builder, openrtb_ext.BidderRise: rise.Builder, openrtb_ext.BidderRoulax: roulax.Builder, From 4a0ec3f2b790237ec152484a721d16d060768679 Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sat, 21 Dec 2024 16:56:05 -0800 Subject: [PATCH 71/73] Removing error return value that is no longer used. --- adapters/resetdigital/resetdigital.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/adapters/resetdigital/resetdigital.go b/adapters/resetdigital/resetdigital.go index fec83a1e0ec..e3d7b7419cb 100644 --- a/adapters/resetdigital/resetdigital.go +++ b/adapters/resetdigital/resetdigital.go @@ -237,11 +237,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R continue } - bidType, err := GetMediaTypeForImp(requestImps[bid.ImpID]) - if err != nil { - errs = append(errs, err) - continue - } + bidType := GetMediaTypeForImp(requestImps[bid.ImpID]) b := &adapters.TypedBid{ Bid: bid, @@ -295,13 +291,13 @@ func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) { return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID) } -func GetMediaTypeForImp(reqImp openrtb2.Imp) (openrtb_ext.BidType, error) { +func GetMediaTypeForImp(reqImp openrtb2.Imp) openrtb_ext.BidType { if reqImp.Video != nil { - return openrtb_ext.BidTypeVideo, nil + return openrtb_ext.BidTypeVideo } if reqImp.Audio != nil { - return openrtb_ext.BidTypeAudio, nil + return openrtb_ext.BidTypeAudio } - return openrtb_ext.BidTypeBanner, nil + return openrtb_ext.BidTypeBanner } From 11c824f4d9c2851273ec3944351a99dcb745a14c Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sat, 21 Dec 2024 16:56:50 -0800 Subject: [PATCH 72/73] Removing .gitignore file. --- adapters/resetdigital/.gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 adapters/resetdigital/.gitignore diff --git a/adapters/resetdigital/.gitignore b/adapters/resetdigital/.gitignore deleted file mode 100644 index 36331304238..00000000000 --- a/adapters/resetdigital/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore test coverage output -cover.out From 905485dfb2710a3bfc0e2d6d645a48e9a0fca547 Mon Sep 17 00:00:00 2001 From: dirk-rd Date: Sun, 22 Dec 2024 07:28:27 -0800 Subject: [PATCH 73/73] Adding required file paras_test.go to test for (in)valid parameters. --- adapters/resetdigital/params_test.go | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 adapters/resetdigital/params_test.go diff --git a/adapters/resetdigital/params_test.go b/adapters/resetdigital/params_test.go new file mode 100644 index 00000000000..4098b444934 --- /dev/null +++ b/adapters/resetdigital/params_test.go @@ -0,0 +1,58 @@ +package resetdigital + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v3/openrtb_ext" +) + +// TestValidParams tests valid parameter(s) declared in openrtb_ext/imp_resetdigital.go +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, validParam := range validParams { + if err := validator.Validate(openrtb_ext.BidderResetDigital, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected ResetDigital params: %s \n Error: %s", validParam, err) + } + } +} + +// TestValidParams tests invalid parameter(s) declared in openrtb_ext/imp_resetdigital.go +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, invalidParam := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderResetDigital, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected ResetDigital params: %s", invalidParam) + } + } +} + +// list of valid parameter(s) test cases +var validParams = []string{ + `{"placement_id":"1000"}`, + `{"placement_id":"0"}`, + `{"placement_id":"abc"}`, + `{"placement_id":"123abc"}`, + `{}`, + `{"cp":"1000"}`, +} + +// list of invalid parameter(s) test cases +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{"placement_id":}`, + `{"placement_id":""}`, +}