From 858b0afae99ece7c90c879c8e69b40651877c4d0 Mon Sep 17 00:00:00 2001 From: Zdravko Kosanovic Date: Tue, 23 Apr 2024 14:08:26 +0200 Subject: [PATCH 1/5] OpenWeb: Fix adapter --- adapters/openweb/openweb.go | 192 ++++++------------ adapters/openweb/openweb_test.go | 2 +- .../exemplary/multiple-imps-same-aid.json | 175 ---------------- .../openwebtest/exemplary/simple-banner.json | 133 ++++-------- .../openwebtest/exemplary/simple-video.json | 21 +- ...ession-mapping.json => missing-mtype.json} | 38 ++-- .../{no-valid-imps.json => missing-org.json} | 5 +- .../openwebtest/supplemental/status-204.json | 56 ----- .../openwebtest/supplemental/status-400.json | 66 ------ .../openwebtest/supplemental/status-500.json | 66 ------ openrtb_ext/imp_openweb.go | 6 +- static/bidder-info/openweb.yaml | 10 +- 12 files changed, 154 insertions(+), 616 deletions(-) delete mode 100644 adapters/openweb/openwebtest/exemplary/multiple-imps-same-aid.json rename adapters/openweb/openwebtest/supplemental/{wrong-impression-mapping.json => missing-mtype.json} (62%) rename adapters/openweb/openwebtest/supplemental/{no-valid-imps.json => missing-org.json} (78%) delete mode 100644 adapters/openweb/openwebtest/supplemental/status-204.json delete mode 100644 adapters/openweb/openwebtest/supplemental/status-400.json delete mode 100644 adapters/openweb/openwebtest/supplemental/status-500.json diff --git a/adapters/openweb/openweb.go b/adapters/openweb/openweb.go index b74e97dfc3f..b763ca04b5b 100644 --- a/adapters/openweb/openweb.go +++ b/adapters/openweb/openweb.go @@ -2,10 +2,13 @@ package openweb import ( "encoding/json" + "errors" "fmt" "net/http" + "strings" "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/errortypes" @@ -16,175 +19,104 @@ type adapter struct { endpoint string } -type openwebImpExt struct { - OpenWeb openrtb_ext.ExtImpOpenWeb `json:"openweb"` -} - -func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - totalImps := len(request.Imp) - errors := make([]error, 0, totalImps) - sourceIdToImpIds := make(map[int][]int) - var sourceIds []int - - for i := 0; i < totalImps; i++ { - - sourceId, err := validateImpression(&request.Imp[i]) - - if err != nil { - errors = append(errors, err) - continue - } - - if _, ok := sourceIdToImpIds[sourceId]; !ok { - sourceIdToImpIds[sourceId] = make([]int, 0, totalImps-i) - sourceIds = append(sourceIds, sourceId) - } - - sourceIdToImpIds[sourceId] = append(sourceIdToImpIds[sourceId], i) - +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) { + org, err := extractOrg(request) + if err != nil { + errs = append(errs, fmt.Errorf("extractOrg: %w", err)) + return nil, errs } - totalReqs := len(sourceIdToImpIds) - if totalReqs == 0 { - return nil, errors + requestJSON, err := json.Marshal(request) + if err != nil { + errs = append(errs, fmt.Errorf("marshal bidRequest: %w", err)) + return nil, errs } headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") - headers.Add("Accept", "application/json") - - reqs := make([]*adapters.RequestData, 0, totalReqs) - imps := request.Imp - reqCopy := *request - reqCopy.Imp = make([]openrtb2.Imp, totalImps) - for _, sourceId := range sourceIds { - impIds := sourceIdToImpIds[sourceId] - reqCopy.Imp = reqCopy.Imp[:0] + return append(requestsToBidder, &adapters.RequestData{ + Method: http.MethodPost, + Uri: a.endpoint + "?publisher_id=" + org, + Body: requestJSON, + Headers: headers, + ImpIDs: openrtb_ext.GetImpIDs(request.Imp), + }), nil +} - for i := 0; i < len(impIds); i++ { - reqCopy.Imp = append(reqCopy.Imp, imps[impIds[i]]) +func extractOrg(request *openrtb2.BidRequest) (string, error) { + var err error + for _, imp := range request.Imp { + var bidderExt adapters.ExtImpBidder + if err = json.Unmarshal(imp.Ext, &bidderExt); err != nil { + return "", fmt.Errorf("unmarshal bidderExt: %w", err) } - body, err := json.Marshal(reqCopy) - if err != nil { - errors = append(errors, fmt.Errorf("error while encoding bidRequest, err: %s", err)) - return nil, errors + var impExt openrtb_ext.ExtImpOpenWeb + if err = json.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + return "", fmt.Errorf("unmarshal ExtImpOpenWeb: %w", err) } - reqs = append(reqs, &adapters.RequestData{ - Method: "POST", - Uri: a.endpoint + fmt.Sprintf("?aid=%d", sourceId), - Body: body, - Headers: headers, - ImpIDs: openrtb_ext.GetImpIDs(reqCopy.Imp), - }) + if impExt.Org != "" { + return strings.TrimSpace(impExt.Org), nil + } } - return reqs, errors - + return "", errors.New("no org supplied") } -func (a *adapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.RequestData, httpRes *adapters.ResponseData) (*adapters.BidderResponse, []error) { - - if httpRes.StatusCode == http.StatusNoContent { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } - if httpRes.StatusCode != http.StatusOK { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Remote server error: %s", httpRes.Body), - }} - } - var bidResp openrtb2.BidResponse - if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("error while decoding response, err: %s", err), - }} + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { + return nil, []error{err} } - bidResponse := adapters.NewBidderResponse() - var errors []error + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } - for _, sb := range bidResp.SeatBid { - for i := 0; i < len(sb.Bid); i++ { + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur - bid := sb.Bid[i] + var errs []error - mediaType, impOK := getBidType(bidReq.Imp, bid.ImpID) - if !impOK { - errors = append(errors, &errortypes.BadServerResponse{ - Message: fmt.Sprintf("ignoring bid id=%s, request doesn't contain any impression with id=%s", bid.ID, bid.ImpID), - }) + for _, seatBid := range response.SeatBid { + for i, bid := range seatBid.Bid { + bidType, err := getMediaTypeForBid(bid) + if err != nil { + errs = append(errs, err) continue } bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &bid, - BidType: mediaType, + Bid: &seatBid.Bid[i], + BidType: bidType, }) } } - return bidResponse, errors -} - -func getBidType(imps []openrtb2.Imp, impId string) (mediaType openrtb_ext.BidType, ok bool) { - mediaType = openrtb_ext.BidTypeBanner - for _, imp := range imps { - if imp.ID == impId { - ok = true - - if imp.Video != nil { - mediaType = openrtb_ext.BidTypeVideo - } - - break - } - } - - return + return bidResponse, errs } -func validateImpression(imp *openrtb2.Imp) (int, error) { - var bidderExt adapters.ExtImpBidder - - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { - return 0, &errortypes.BadInput{ - Message: fmt.Sprintf("ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.ID, err), +func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { + switch bid.MType { + case openrtb2.MarkupBanner: + return openrtb_ext.BidTypeBanner, nil + case openrtb2.MarkupVideo: + return openrtb_ext.BidTypeVideo, nil + default: + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("unsupported MType %d", bid.MType), } } - - impExt := openrtb_ext.ExtImpOpenWeb{} - err := json.Unmarshal(bidderExt.Bidder, &impExt) - if err != nil { - return 0, &errortypes.BadInput{ - Message: fmt.Sprintf("ignoring imp id=%s, error while decoding impExt, err: %s", imp.ID, err), - } - } - - var impExtBuffer []byte - - impExtBuffer, err = json.Marshal(&openwebImpExt{ - OpenWeb: impExt, - }) - if err != nil { - return 0, &errortypes.BadInput{ - Message: fmt.Sprintf("ignoring imp id=%s, error while encoding impExt, err: %s", imp.ID, err), - } - } - - if impExt.BidFloor > 0 { - imp.BidFloor = impExt.BidFloor - } - - imp.Ext = impExtBuffer - - return impExt.SourceID, nil } // Builder builds a new instance of the OpenWeb adapter for the given bidder with the given config. -func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { +func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { bidder := &adapter{ endpoint: config.Endpoint, } diff --git a/adapters/openweb/openweb_test.go b/adapters/openweb/openweb_test.go index a63dafd06c2..2a135acb1f0 100644 --- a/adapters/openweb/openweb_test.go +++ b/adapters/openweb/openweb_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderOpenWeb, config.Adapter{ - Endpoint: "http://ghb.spotim.market/pbs/ortb"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + Endpoint: "https://pbs.openwebmp.com/pbs"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) diff --git a/adapters/openweb/openwebtest/exemplary/multiple-imps-same-aid.json b/adapters/openweb/openwebtest/exemplary/multiple-imps-same-aid.json deleted file mode 100644 index 2fd7c195b3e..00000000000 --- a/adapters/openweb/openwebtest/exemplary/multiple-imps-same-aid.json +++ /dev/null @@ -1,175 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "bidfloor": 30, - "ext": { - "bidder": { - "aid": 1000, - "siteId": 1234, - "bidFloor": 20 - } - } - }, - { - "id": "test-imp-id-2", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "bidfloor": 30, - "ext": { - "bidder": { - "aid": 1000, - "siteId": 4321, - "bidFloor": 20 - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=1000", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "bidfloor": 20, - "ext": { - "openweb": { - "aid": 1000, - "siteId": 1234, - "bidFloor": 20 - } - } - }, - { - "id": "test-imp-id-2", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "bidfloor": 20, - "ext": { - "openweb": { - "aid": 1000, - "siteId": 4321, - "bidFloor": 20 - } - } - } - ] - }, - "impIDs":["test-imp-id","test-imp-id-2"] - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "test-seat", - "bid": [ - { - "id": "test-bid-id", - "impid": "test-imp-id", - "price": 30, - "adm": "some-test-ad", - "crid": "crid_10", - "h": 250, - "w": 300 - }, - { - "id": "test-bid-id-2", - "impid": "test-imp-id-2", - "price": 30, - "adm": "some-test-ad", - "crid": "crid_10", - "h": 250, - "w": 300 - } - ] - } - ], - "cur": "USD" - } - } - } - ], - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "test-imp-id", - "price": 30, - "adm": "some-test-ad", - "crid": "crid_10", - "w": 300, - "h": 250 - }, - "type": "banner" - }, - { - "bid": { - "id": "test-bid-id-2", - "impid": "test-imp-id-2", - "price": 30, - "adm": "some-test-ad", - "crid": "crid_10", - "w": 300, - "h": 250 - }, - "type": "banner" - } - ] - } - ] -} diff --git a/adapters/openweb/openwebtest/exemplary/simple-banner.json b/adapters/openweb/openwebtest/exemplary/simple-banner.json index b742fa50eb9..236a9e2acfb 100644 --- a/adapters/openweb/openwebtest/exemplary/simple-banner.json +++ b/adapters/openweb/openwebtest/exemplary/simple-banner.json @@ -16,12 +16,9 @@ } ] }, - "bidfloor": 30, "ext": { "bidder": { - "aid": 1000, - "siteId": 1234, - "bidFloor": 20 + "org": "777" } } }, @@ -39,94 +36,67 @@ } ] }, - "bidfloor": 30, "ext": { "bidder": { - "aid": 2000, - "siteId": 4321, - "bidFloor": 20 + "org": "777" } } } ] }, - "httpCalls": [ { "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=1000", + "uri": "https://pbs.openwebmp.com/pbs?publisher_id=777", "body": { "id": "test-request-id", "imp": [ { - "id":"test-imp-id", + "id": "test-imp-id", "banner": { "format": [ - {"w":300,"h":250}, - {"w":300,"h":600} + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } ] }, - "bidfloor": 20, "ext": { - "openweb": { - "aid": 1000, - "siteId": 1234, - "bidFloor": 20 + "bidder": { + "org": "777" } } - } - ] - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "test-seat", - "bid": [{ - "id": "test-bid-id", - "impid": "test-imp-id", - "price": 30, - "adm": "some-test-ad", - "crid": "crid_10", - "h": 250, - "w": 300 - }] - } - ], - "cur": "USD" - } - } - }, - { - "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=2000", - "body": { - "id": "test-request-id", - "imp": [ + }, { - "id":"test-imp-id-2", + "id": "test-imp-id-2", "banner": { "format": [ - {"w":300,"h":250}, - {"w":300,"h":600} + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } ] }, - "bidfloor": 20, "ext": { - "openweb": { - "aid": 2000, - "siteId": 4321, - "bidFloor": 20 + "bidder": { + "org": "777" } } } ] }, - "impIDs":["test-imp-id-2"] + "impIDs": [ + "test-imp-id", + "test-imp-id-2" + ] }, "mockResponse": { "status": 200, @@ -134,16 +104,19 @@ "id": "test-request-id", "seatbid": [ { - "seat": "test-seat-2", - "bid": [{ - "id": "test-bid-id-2", - "impid": "test-imp-id-2", - "price": 30, - "adm": "some-test-ad", - "crid": "crid_10", - "h": 250, - "w": 300 - }] + "seat": "test-seat", + "bid": [ + { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 30, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 250, + "w": 300, + "mtype": 1 + } + ] } ], "cur": "USD" @@ -163,24 +136,8 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 300, - "h": 250 - }, - "type": "banner" - } - ] - }, - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id-2", - "impid": "test-imp-id-2", - "price": 30, - "adm": "some-test-ad", - "crid": "crid_10", - "w": 300, - "h": 250 + "h": 250, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/openweb/openwebtest/exemplary/simple-video.json b/adapters/openweb/openwebtest/exemplary/simple-video.json index e8052e7ebf2..7cc0e650714 100644 --- a/adapters/openweb/openwebtest/exemplary/simple-video.json +++ b/adapters/openweb/openwebtest/exemplary/simple-video.json @@ -14,22 +14,21 @@ }, "ext": { "bidder": { - "aid": 1000 + "org": "777" } } } ] }, - "httpCalls": [ { "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=1000", + "uri": "https://pbs.openwebmp.com/pbs?publisher_id=777", "body": { "id": "test-request-id", "imp": [ { - "id":"test-imp-id", + "id": "test-imp-id", "video": { "w": 900, "h": 250, @@ -39,14 +38,16 @@ ] }, "ext": { - "openweb": { - "aid": 1000 + "bidder": { + "org": "777" } } } ] }, - "impIDs":["test-imp-id"] + "impIDs": [ + "test-imp-id" + ] }, "mockResponse": { "status": 200, @@ -60,7 +61,8 @@ "impid": "test-imp-id", "price": 3.5, "w": 900, - "h": 250 + "h": 250, + "mtype": 2 } ] } @@ -79,7 +81,8 @@ "impid": "test-imp-id", "price": 3.5, "w": 900, - "h": 250 + "h": 250, + "mtype": 2 }, "type": "video" } diff --git a/adapters/openweb/openwebtest/supplemental/wrong-impression-mapping.json b/adapters/openweb/openwebtest/supplemental/missing-mtype.json similarity index 62% rename from adapters/openweb/openwebtest/supplemental/wrong-impression-mapping.json rename to adapters/openweb/openwebtest/supplemental/missing-mtype.json index f83ec46da6f..4132c74cd16 100644 --- a/adapters/openweb/openwebtest/supplemental/wrong-impression-mapping.json +++ b/adapters/openweb/openwebtest/supplemental/missing-mtype.json @@ -14,22 +14,21 @@ }, "ext": { "bidder": { - "aid": 1000 + "org": "777" } } } ] }, - "httpCalls": [ { "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=1000", + "uri": "https://pbs.openwebmp.com/pbs?publisher_id=777", "body": { "id": "test-request-id", "imp": [ { - "id":"test-imp-id", + "id": "test-imp-id", "video": { "w": 900, "h": 250, @@ -39,28 +38,36 @@ ] }, "ext": { - "openweb": { - "aid": 1000 + "bidder": { + "org": "777" } } } ] }, - "impIDs":["test-imp-id"] + "impIDs": [ + "test-imp-id" + ] }, "mockResponse": { "status": 200, "body": { "id": "test-request-id", + "cur": "USD", "seatbid": [ { + "seat": "958", "bid": [ { - "id": "test-bid-id", - "impid": "SOME-WRONG-IMP-ID", - "price": 3.5, + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, "w": 900, - "h": 250 + "h": 250, + "mimes": [ + "video/x-flv", + "video/mp4" + ] } ] } @@ -69,11 +76,16 @@ } } ], - "expectedBidResponses": [{"currency":"USD","bids":[]}], "expectedMakeBidsErrors": [ { - "value": "ignoring bid id=test-bid-id, request doesn't contain any impression with id=SOME-WRONG-IMP-ID", + "value": "unsupported MType 0", "comparison": "literal" } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [] + } ] } diff --git a/adapters/openweb/openwebtest/supplemental/no-valid-imps.json b/adapters/openweb/openwebtest/supplemental/missing-org.json similarity index 78% rename from adapters/openweb/openwebtest/supplemental/no-valid-imps.json rename to adapters/openweb/openwebtest/supplemental/missing-org.json index 3335639d59f..cbc12b2d3eb 100644 --- a/adapters/openweb/openwebtest/supplemental/no-valid-imps.json +++ b/adapters/openweb/openwebtest/supplemental/missing-org.json @@ -14,16 +14,15 @@ }, "ext": { "bidder": { - "aid": "not valid value" + "org": "" } } } ] }, - "expectedMakeRequestsErrors": [ { - "value": "^ignoring imp id=test-imp-id, error while decoding impExt", + "value": "no org supplied", "comparison": "regex" } ] diff --git a/adapters/openweb/openwebtest/supplemental/status-204.json b/adapters/openweb/openwebtest/supplemental/status-204.json deleted file mode 100644 index 637c2113fc5..00000000000 --- a/adapters/openweb/openwebtest/supplemental/status-204.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "w": 900, - "h": 250, - "mimes": [ - "video/x-flv", - "video/mp4" - ] - }, - "ext": { - "bidder": { - "aid": 1000 - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=1000", - "body": { - "id": "test-request-id", - "imp": [ - { - "id":"test-imp-id", - "video": { - "w": 900, - "h": 250, - "mimes": [ - "video/x-flv", - "video/mp4" - ] - }, - "ext": { - "openweb": { - "aid": 1000 - } - } - } - ] - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 204 - } - } - ] -} diff --git a/adapters/openweb/openwebtest/supplemental/status-400.json b/adapters/openweb/openwebtest/supplemental/status-400.json deleted file mode 100644 index 20500de2b4a..00000000000 --- a/adapters/openweb/openwebtest/supplemental/status-400.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "w": 900, - "h": 250, - "mimes": [ - "video/x-flv", - "video/mp4" - ] - }, - "ext": { - "bidder": { - "aid": 1000 - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=1000", - "body": { - "id": "test-request-id", - "imp": [ - { - "id":"test-imp-id", - "video": { - "w": 900, - "h": 250, - "mimes": [ - "video/x-flv", - "video/mp4" - ] - }, - "ext": { - "openweb": { - "aid": 1000 - } - } - } - ] - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 400, - "body": "Bad request" - } - } - ], - - "expectedMakeBidsErrors": [ - { - "value": "Remote server error: \"Bad request\"", - "comparison": "literal" - } - ], - - "expectedBidResponses": [] -} diff --git a/adapters/openweb/openwebtest/supplemental/status-500.json b/adapters/openweb/openwebtest/supplemental/status-500.json deleted file mode 100644 index 48cfab3b7fa..00000000000 --- a/adapters/openweb/openwebtest/supplemental/status-500.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "w": 900, - "h": 250, - "mimes": [ - "video/x-flv", - "video/mp4" - ] - }, - "ext": { - "bidder": { - "aid": 1000 - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://ghb.spotim.market/pbs/ortb?aid=1000", - "body": { - "id": "test-request-id", - "imp": [ - { - "id":"test-imp-id", - "video": { - "w": 900, - "h": 250, - "mimes": [ - "video/x-flv", - "video/mp4" - ] - }, - "ext": { - "openweb": { - "aid": 1000 - } - } - } - ] - }, - "impIDs":["test-imp-id"] - }, - "mockResponse": { - "status": 500, - "body": "Internal error" - } - } - ], - - "expectedMakeBidsErrors": [ - { - "value": "Remote server error: \"Internal error\"", - "comparison": "literal" - } - ], - - "expectedBidResponses": [] -} diff --git a/openrtb_ext/imp_openweb.go b/openrtb_ext/imp_openweb.go index fc3cbdacdd0..9a2b3fd9ef0 100644 --- a/openrtb_ext/imp_openweb.go +++ b/openrtb_ext/imp_openweb.go @@ -2,8 +2,6 @@ package openrtb_ext // ExtImpOpenWeb defines the contract for bidrequest.imp[i].ext.prebid.bidder.openweb type ExtImpOpenWeb struct { - SourceID int `json:"aid"` - PlacementID int `json:"placementId,omitempty"` - SiteID int `json:"siteId,omitempty"` - BidFloor float64 `json:"bidFloor,omitempty"` + Org string `json:"org"` + PlacementID string `json:"placementId,omitempty"` } diff --git a/static/bidder-info/openweb.yaml b/static/bidder-info/openweb.yaml index 9272719cf19..cde54acfb25 100644 --- a/static/bidder-info/openweb.yaml +++ b/static/bidder-info/openweb.yaml @@ -1,7 +1,8 @@ -endpoint: "http://ghb.spotim.market/pbs/ortb" +endpoint: "https://pbs.openwebmp.com/pbs" maintainer: email: "monetization@openweb.com" gvlVendorID: 280 +modifyingVastXmlAllowed: true capabilities: app: mediaTypes: @@ -12,7 +13,6 @@ capabilities: - banner - video userSync: - # openweb supports user syncing, but requires configuration by the host. contact this - # bidder directly at the email address in this file to ask about enabling user sync. - supports: - - redirect + iframe: + url: https://pbs-cs.openwebmp.com/pbs-iframe?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}}&redirect={{.RedirectURL}} + userMacro: "[PBS_UID]" From fbbb48a7845e934a3cc7979135ba6ff75174e0aa Mon Sep 17 00:00:00 2001 From: Zdravko Kosanovic Date: Wed, 24 Apr 2024 00:36:00 +0200 Subject: [PATCH 2/5] Update JSONSchema --- adapters/openweb/params_test.go | 14 ++++++-------- static/bidder-params/openweb.json | 22 ++++++++-------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/adapters/openweb/params_test.go b/adapters/openweb/params_test.go index 7a53124fa30..e77f8ab0e72 100644 --- a/adapters/openweb/params_test.go +++ b/adapters/openweb/params_test.go @@ -39,10 +39,8 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"aid":123}`, - `{"aid":123,"placementId":1234}`, - `{"aid":123,"siteId":4321}`, - `{"aid":123,"siteId":0,"bidFloor":0}`, + `{"org":"123"}`, + `{"org":"123","placementId":"1234"}`, } var invalidParams = []string{ @@ -53,8 +51,8 @@ var invalidParams = []string{ `4.2`, `[]`, `{}`, - `{"aid":"some string instead of int"}`, - `{"aid":"0"}`, - `{"aid":"123","placementId":"123"}`, - `{"aid":123, "placementId":"123", "siteId":"321"}`, + `{"org":123}`, + `{"org":0}`, + `{"org":"123","placementId":123}`, + `{"org":123, "placementId":"123"}`, } diff --git a/static/bidder-params/openweb.json b/static/bidder-params/openweb.json index ec5766ad663..8ca49a4522f 100644 --- a/static/bidder-params/openweb.json +++ b/static/bidder-params/openweb.json @@ -2,25 +2,19 @@ "$schema": "http://json-schema.org/draft-04/schema#", "title": "OpenWeb Adapter Params", "description": "A schema which validates params accepted by the OpenWeb adapter", - "type": "object", "properties": { "placementId": { - "type": "integer", + "type": "string", "description": "An ID which identifies this placement of the impression" }, - "siteId": { - "type": "integer", - "description": "An ID which identifies the site selling the impression" - }, - "aid": { - "type": "integer", - "description": "An ID which identifies the channel" - }, - "bidFloor": { - "type": "number", - "description": "BidFloor, US Dollars" + "org": { + "type": "string", + "description": "The organization ID.", + "minLength": 1 } }, - "required": ["aid"] + "required": [ + "org" + ] } From 548fab3e6e455895869d8331f758557d4e32cd67 Mon Sep 17 00:00:00 2001 From: Zdravko Kosanovic Date: Sun, 26 May 2024 11:27:17 +0200 Subject: [PATCH 3/5] Code review comments --- adapters/openweb/openweb.go | 11 +++++++++-- ...issing-org.json => missing-org-and-aid.json} | 2 +- openrtb_ext/imp_openweb.go | 1 + static/bidder-params/openweb.json | 17 +++++++++++++++-- 4 files changed, 26 insertions(+), 5 deletions(-) rename adapters/openweb/openwebtest/supplemental/{missing-org.json => missing-org-and-aid.json} (91%) diff --git a/adapters/openweb/openweb.go b/adapters/openweb/openweb.go index b763ca04b5b..aa2e7f1d3d9 100644 --- a/adapters/openweb/openweb.go +++ b/adapters/openweb/openweb.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/http" + "strconv" "strings" "github.com/prebid/openrtb/v20/openrtb2" @@ -60,9 +61,13 @@ func extractOrg(request *openrtb2.BidRequest) (string, error) { if impExt.Org != "" { return strings.TrimSpace(impExt.Org), nil } + + if impExt.Aid != 0 { + return strconv.Itoa(impExt.Aid), nil + } } - return "", errors.New("no org supplied") + return "", errors.New("no org or aid supplied") } func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { @@ -80,7 +85,9 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData } bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) - bidResponse.Currency = response.Cur + if response.Cur != "" { + bidResponse.Currency = response.Cur + } var errs []error diff --git a/adapters/openweb/openwebtest/supplemental/missing-org.json b/adapters/openweb/openwebtest/supplemental/missing-org-and-aid.json similarity index 91% rename from adapters/openweb/openwebtest/supplemental/missing-org.json rename to adapters/openweb/openwebtest/supplemental/missing-org-and-aid.json index cbc12b2d3eb..fbc607987f5 100644 --- a/adapters/openweb/openwebtest/supplemental/missing-org.json +++ b/adapters/openweb/openwebtest/supplemental/missing-org-and-aid.json @@ -22,7 +22,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "no org supplied", + "value": "no org or aid supplied", "comparison": "regex" } ] diff --git a/openrtb_ext/imp_openweb.go b/openrtb_ext/imp_openweb.go index 9a2b3fd9ef0..ea3c6f65a22 100644 --- a/openrtb_ext/imp_openweb.go +++ b/openrtb_ext/imp_openweb.go @@ -2,6 +2,7 @@ package openrtb_ext // ExtImpOpenWeb defines the contract for bidrequest.imp[i].ext.prebid.bidder.openweb type ExtImpOpenWeb struct { + Aid int `json:"aid"` Org string `json:"org"` PlacementID string `json:"placementId,omitempty"` } diff --git a/static/bidder-params/openweb.json b/static/bidder-params/openweb.json index 8ca49a4522f..ae904493f55 100644 --- a/static/bidder-params/openweb.json +++ b/static/bidder-params/openweb.json @@ -8,13 +8,26 @@ "type": "string", "description": "An ID which identifies this placement of the impression" }, + "aid": { + "type": "integer", + "description": "Deprecated: An ID which identifies the channel" + }, "org": { "type": "string", "description": "The organization ID.", "minLength": 1 } }, - "required": [ - "org" + "oneOf": [ + { + "required": [ + "aid" + ] + }, + { + "required": [ + "org" + ] + } ] } From 2d1a0378655197822504daf00427fe8d6abd9f3c Mon Sep 17 00:00:00 2001 From: Zdravko Kosanovic Date: Sun, 26 May 2024 12:06:11 +0200 Subject: [PATCH 4/5] Make placementId mandatory --- .../openweb/openwebtest/exemplary/simple-banner.json | 12 ++++++++---- .../openweb/openwebtest/exemplary/simple-video.json | 6 ++++-- .../openwebtest/supplemental/missing-mtype.json | 6 ++++-- .../supplemental/missing-org-and-aid.json | 3 ++- adapters/openweb/params_test.go | 4 +++- static/bidder-params/openweb.json | 4 +++- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/adapters/openweb/openwebtest/exemplary/simple-banner.json b/adapters/openweb/openwebtest/exemplary/simple-banner.json index 236a9e2acfb..e6c1abd7cc6 100644 --- a/adapters/openweb/openwebtest/exemplary/simple-banner.json +++ b/adapters/openweb/openwebtest/exemplary/simple-banner.json @@ -18,7 +18,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } }, @@ -38,7 +39,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } } @@ -67,7 +69,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } }, @@ -87,7 +90,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } } diff --git a/adapters/openweb/openwebtest/exemplary/simple-video.json b/adapters/openweb/openwebtest/exemplary/simple-video.json index 7cc0e650714..3dd0a0da802 100644 --- a/adapters/openweb/openwebtest/exemplary/simple-video.json +++ b/adapters/openweb/openwebtest/exemplary/simple-video.json @@ -14,7 +14,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } } @@ -39,7 +40,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } } diff --git a/adapters/openweb/openwebtest/supplemental/missing-mtype.json b/adapters/openweb/openwebtest/supplemental/missing-mtype.json index 4132c74cd16..68b487216c0 100644 --- a/adapters/openweb/openwebtest/supplemental/missing-mtype.json +++ b/adapters/openweb/openwebtest/supplemental/missing-mtype.json @@ -14,7 +14,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } } @@ -39,7 +40,8 @@ }, "ext": { "bidder": { - "org": "777" + "org": "777", + "placementId": "1" } } } diff --git a/adapters/openweb/openwebtest/supplemental/missing-org-and-aid.json b/adapters/openweb/openwebtest/supplemental/missing-org-and-aid.json index fbc607987f5..6d156985029 100644 --- a/adapters/openweb/openwebtest/supplemental/missing-org-and-aid.json +++ b/adapters/openweb/openwebtest/supplemental/missing-org-and-aid.json @@ -14,7 +14,8 @@ }, "ext": { "bidder": { - "org": "" + "org": "", + "placementId": "1" } } } diff --git a/adapters/openweb/params_test.go b/adapters/openweb/params_test.go index e77f8ab0e72..82e2f9e5ed5 100644 --- a/adapters/openweb/params_test.go +++ b/adapters/openweb/params_test.go @@ -39,7 +39,7 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"org":"123"}`, + `{"aid":123,"placementId":"1234"}`, `{"org":"123","placementId":"1234"}`, } @@ -55,4 +55,6 @@ var invalidParams = []string{ `{"org":0}`, `{"org":"123","placementId":123}`, `{"org":123, "placementId":"123"}`, + `{"aid":123}`, + `{"aid":"123","placementId":"123"}`, } diff --git a/static/bidder-params/openweb.json b/static/bidder-params/openweb.json index ae904493f55..62a4853ed65 100644 --- a/static/bidder-params/openweb.json +++ b/static/bidder-params/openweb.json @@ -6,7 +6,8 @@ "properties": { "placementId": { "type": "string", - "description": "An ID which identifies this placement of the impression" + "description": "An ID which identifies this placement of the impression", + "minLength": 1 }, "aid": { "type": "integer", @@ -18,6 +19,7 @@ "minLength": 1 } }, + "required": [ "placementId" ], "oneOf": [ { "required": [ From 03d44e7165abb29668e141977a26092c61f3284f Mon Sep 17 00:00:00 2001 From: Zdravko Kosanovic Date: Tue, 11 Jun 2024 14:46:34 +0400 Subject: [PATCH 5/5] Code review fixes --- adapters/openweb/openweb.go | 11 +++++-- .../openwebtest/exemplary/simple-video.json | 4 +-- .../supplemental/missing-placement-id.json | 29 +++++++++++++++++++ openrtb_ext/imp_openweb.go | 6 ++-- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 adapters/openweb/openwebtest/supplemental/missing-placement-id.json diff --git a/adapters/openweb/openweb.go b/adapters/openweb/openweb.go index aa2e7f1d3d9..a1996d056b2 100644 --- a/adapters/openweb/openweb.go +++ b/adapters/openweb/openweb.go @@ -21,9 +21,9 @@ type adapter struct { } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) { - org, err := extractOrg(request) + org, err := checkExtAndExtractOrg(request) if err != nil { - errs = append(errs, fmt.Errorf("extractOrg: %w", err)) + errs = append(errs, fmt.Errorf("checkExtAndExtractOrg: %w", err)) return nil, errs } @@ -45,7 +45,8 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRe }), nil } -func extractOrg(request *openrtb2.BidRequest) (string, error) { +// checkExtAndExtractOrg checks the presence of required parameters and extracts the Org ID string. +func checkExtAndExtractOrg(request *openrtb2.BidRequest) (string, error) { var err error for _, imp := range request.Imp { var bidderExt adapters.ExtImpBidder @@ -58,6 +59,10 @@ func extractOrg(request *openrtb2.BidRequest) (string, error) { return "", fmt.Errorf("unmarshal ExtImpOpenWeb: %w", err) } + if impExt.PlacementID == "" { + return "", errors.New("no placement id supplied") + } + if impExt.Org != "" { return strings.TrimSpace(impExt.Org), nil } diff --git a/adapters/openweb/openwebtest/exemplary/simple-video.json b/adapters/openweb/openwebtest/exemplary/simple-video.json index 3dd0a0da802..199607cbe32 100644 --- a/adapters/openweb/openwebtest/exemplary/simple-video.json +++ b/adapters/openweb/openwebtest/exemplary/simple-video.json @@ -14,7 +14,7 @@ }, "ext": { "bidder": { - "org": "777", + "aid": 777, "placementId": "1" } } @@ -40,7 +40,7 @@ }, "ext": { "bidder": { - "org": "777", + "aid": 777, "placementId": "1" } } diff --git a/adapters/openweb/openwebtest/supplemental/missing-placement-id.json b/adapters/openweb/openwebtest/supplemental/missing-placement-id.json new file mode 100644 index 00000000000..d7159e2f638 --- /dev/null +++ b/adapters/openweb/openwebtest/supplemental/missing-placement-id.json @@ -0,0 +1,29 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 900, + "h": 250, + "mimes": [ + "video/x-flv", + "video/mp4" + ] + }, + "ext": { + "bidder": { + "org": "777" + } + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "no placement id supplied", + "comparison": "regex" + } + ] +} diff --git a/openrtb_ext/imp_openweb.go b/openrtb_ext/imp_openweb.go index ea3c6f65a22..5df8e7d18e5 100644 --- a/openrtb_ext/imp_openweb.go +++ b/openrtb_ext/imp_openweb.go @@ -2,7 +2,7 @@ package openrtb_ext // ExtImpOpenWeb defines the contract for bidrequest.imp[i].ext.prebid.bidder.openweb type ExtImpOpenWeb struct { - Aid int `json:"aid"` - Org string `json:"org"` - PlacementID string `json:"placementId,omitempty"` + Aid int `json:"aid,omitempty"` + Org string `json:"org,omitempty"` + PlacementID string `json:"placementId"` }