diff --git a/adapters/consumable/adtypes.go b/adapters/consumable/adtypes.go deleted file mode 100644 index 9974a4f26d6..00000000000 --- a/adapters/consumable/adtypes.go +++ /dev/null @@ -1,64 +0,0 @@ -package consumable - -import ( - "strconv" - - "github.com/prebid/openrtb/v19/openrtb2" -) - -/* Turn array of openrtb formats into consumable's code*/ -func getSizeCodes(Formats []openrtb2.Format) []int { - - codes := make([]int, 0) - for _, format := range Formats { - str := strconv.FormatInt(format.W, 10) + "x" + strconv.FormatInt(format.H, 10) - if code, ok := sizeMap[str]; ok { - codes = append(codes, code) - } - } - return codes -} - -var sizeMap = map[string]int{ - "120x90": 1, - // 120x90 is in twice in prebid.js implementation - probably as spacer - "468x60": 3, - "728x90": 4, - "300x250": 5, - "160x600": 6, - "120x600": 7, - "300x100": 8, - "180x150": 9, - "336x280": 10, - "240x400": 11, - "234x60": 12, - "88x31": 13, - "120x60": 14, - "120x240": 15, - "125x125": 16, - "220x250": 17, - "250x250": 18, - "250x90": 19, - "0x0": 20, // TODO: can this be removed - I suspect it's padding in prebid.js impl - "200x90": 21, - "300x50": 22, - "320x50": 23, - "320x480": 24, - "185x185": 25, - "620x45": 26, - "300x125": 27, - "800x250": 28, - // below order is preserved from prebid.js implementation for easy comparison - "970x90": 77, - "970x250": 123, - "300x600": 43, - "970x66": 286, - "970x280": 3230, - "486x60": 429, - "700x500": 374, - "300x1050": 934, - "320x100": 1578, - "320x250": 331, - "320x267": 3301, - "728x250": 2730, -} diff --git a/adapters/consumable/consumable.go b/adapters/consumable/consumable.go index 635bc7058ed..932a58b5679 100644 --- a/adapters/consumable/consumable.go +++ b/adapters/consumable/consumable.go @@ -3,319 +3,144 @@ package consumable import ( "encoding/json" "fmt" - "net/http" - "net/url" - "strconv" - "strings" - "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" - "github.com/prebid/prebid-server/v2/privacy/ccpa" + "net/http" ) -type ConsumableAdapter struct { - clock instant +type adapter struct { endpoint string } -type bidRequest struct { - Placements []placement `json:"placements"` - Time int64 `json:"time"` - NetworkId int `json:"networkId,omitempty"` - SiteId int `json:"siteId"` - UnitId int `json:"unitId"` - UnitName string `json:"unitName,omitempty"` - IncludePricingData bool `json:"includePricingData"` - User user `json:"user,omitempty"` - Referrer string `json:"referrer,omitempty"` - Ip string `json:"ip,omitempty"` - Url string `json:"url,omitempty"` - EnableBotFiltering bool `json:"enableBotFiltering,omitempty"` - Parallel bool `json:"parallel"` - CCPA string `json:"ccpa,omitempty"` - GDPR *bidGdpr `json:"gdpr,omitempty"` - Coppa bool `json:"coppa,omitempty"` - SChain openrtb2.SupplyChain `json:"schain"` - Content *openrtb2.Content `json:"content,omitempty"` - GPP string `json:"gpp,omitempty"` - GPPSID []int8 `json:"gpp_sid,omitempty"` -} - -type placement struct { - DivName string `json:"divName"` - NetworkId int `json:"networkId,omitempty"` - SiteId int `json:"siteId"` - UnitId int `json:"unitId"` - UnitName string `json:"unitName,omitempty"` - AdTypes []int `json:"adTypes"` -} - -type user struct { - Key string `json:"key,omitempty"` - Eids []openrtb2.EID `json:"eids,omitempty"` -} - -type bidGdpr struct { - Applies *bool `json:"applies,omitempty"` - Consent string `json:"consent,omitempty"` -} - -type bidResponse struct { - Decisions map[string]decision `json:"decisions"` // map by bidId -} - -/** - * See https://dev.adzerk.com/v1.0/reference/response - */ -type decision struct { - Pricing *pricing `json:"pricing"` - AdID int64 `json:"adId"` - BidderName string `json:"bidderName,omitempty"` - CreativeID string `json:"creativeId,omitempty"` - Contents []contents `json:"contents"` - ImpressionUrl *string `json:"impressionUrl,omitempty"` - Width uint64 `json:"width,omitempty"` // Consumable extension, not defined by Adzerk - Height uint64 `json:"height,omitempty"` // Consumable extension, not defined by Adzerk - Adomain []string `json:"adomain,omitempty"` - Cats []string `json:"cats,omitempty"` -} - -type contents struct { - Body string `json:"body"` -} - -type pricing struct { - ClearPrice *float64 `json:"clearPrice"` -} - -func (a *ConsumableAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error - headers := http.Header{ "Content-Type": {"application/json"}, "Accept": {"application/json"}, } - - if request.Device != nil { - if request.Device.UA != "" { - headers.Set("User-Agent", request.Device.UA) - } - - if request.Device.IP != "" { - headers.Set("Forwarded", "for="+request.Device.IP) - headers.Set("X-Forwarded-For", request.Device.IP) - } - } - - // Set azk cookie to one we got via sync - if request.User != nil { - userID := strings.TrimSpace(request.User.BuyerUID) - if len(userID) > 0 { - headers.Add("Cookie", fmt.Sprintf("%s=%s", "azk", userID)) - } - } - - if request.Site != nil && request.Site.Page != "" { - headers.Set("Referer", request.Site.Page) - - pageUrl, err := url.Parse(request.Site.Page) - if err != nil { - errs = append(errs, err) - } else { - origin := url.URL{ - Scheme: pageUrl.Scheme, - Opaque: pageUrl.Opaque, - Host: pageUrl.Host, - } - headers.Set("Origin", origin.String()) - } - } - - body := bidRequest{ - Placements: make([]placement, len(request.Imp)), - Time: a.clock.Now().Unix(), - IncludePricingData: true, - EnableBotFiltering: true, - Parallel: true, - } - - if request.Site != nil { - body.Referrer = request.Site.Ref // Effectively the previous page to the page where the ad will be shown - body.Url = request.Site.Page // where the impression will be made - } - - gdpr := bidGdpr{} - - ccpaPolicy, err := ccpa.ReadFromRequest(request) + bodyBytes, err := json.Marshal(request) if err != nil { - errs = append(errs, err) - } else { - body.CCPA = ccpaPolicy.Consent + return nil, []error{err} } - if request.Regs != nil && request.Regs.Ext != nil { - var extRegs openrtb_ext.ExtRegs - if err := json.Unmarshal(request.Regs.Ext, &extRegs); err != nil { - errs = append(errs, err) - } else { - if extRegs.GDPR != nil { - applies := *extRegs.GDPR != 0 - gdpr.Applies = &applies - body.GDPR = &gdpr - } + if request.Site != nil { + _, consumableExt, err := extractExtensions(request.Imp[0]) + if err != nil { + return nil, err } - } - - if request.User != nil && request.User.Ext != nil { - var extUser openrtb_ext.ExtUser - if err := json.Unmarshal(request.User.Ext, &extUser); err != nil { - errs = append(errs, err) - } else { - gdpr.Consent = extUser.Consent - body.GDPR = &gdpr - - if hasEids(extUser.Eids) { - body.User.Eids = extUser.Eids - } + if consumableExt.SiteId == 0 && consumableExt.NetworkId == 0 && consumableExt.UnitId == 0 { + return nil, []error{&errortypes.FailedToRequestBids{ + Message: "SiteId, NetworkId and UnitId are all required for site requests", + }} } - } - - if request.Source != nil && request.Source.Ext != nil { - var extSChain openrtb_ext.ExtRequestPrebidSChain - if err := json.Unmarshal(request.Source.Ext, &extSChain); err != nil { - errs = append(errs, err) - } else { - body.SChain = extSChain.SChain + requests := []*adapters.RequestData{ + { + Method: "POST", + Uri: "https://e.serverbid.com/sb/rtb", + Body: bodyBytes, + Headers: headers, + }, } - } - - body.Coppa = request.Regs != nil && request.Regs.COPPA > 0 - - if request.Regs != nil && request.Regs.GPP != "" { - body.GPP = request.Regs.GPP - } - - if request.Regs != nil && request.Regs.GPPSID != nil { - body.GPPSID = request.Regs.GPPSID - } - - if request.Site != nil && request.Site.Content != nil { - body.Content = request.Site.Content - } else if request.App != nil && request.App.Content != nil { - body.Content = request.App.Content - } - - for i, impression := range request.Imp { - - _, consumableExt, err := extractExtensions(impression) + return requests, errs + } else { + _, consumableExt, err := extractExtensions(request.Imp[0]) if err != nil { return nil, err } - // These get set on the first one in observed working requests - if i == 0 { - body.NetworkId = consumableExt.NetworkId - body.SiteId = consumableExt.SiteId - body.UnitId = consumableExt.UnitId - body.UnitName = consumableExt.UnitName + if consumableExt.PlacementId == "" { + return nil, []error{&errortypes.FailedToRequestBids{ + Message: "PlacementId is required for non-site requests", + }} } - - body.Placements[i] = placement{ - DivName: impression.ID, - NetworkId: consumableExt.NetworkId, - SiteId: consumableExt.SiteId, - UnitId: consumableExt.UnitId, - UnitName: consumableExt.UnitName, - AdTypes: getSizeCodes(impression.Banner.Format), // was adTypes: bid.adTypes || getSize(bid.sizes) in prebid.js + requests := []*adapters.RequestData{ + { + Method: "POST", + Uri: "https://e.serverbid.com/rtb/bid?s=" + consumableExt.PlacementId, + Body: bodyBytes, + Headers: headers, + }, } + return requests, errs } - bodyBytes, err := json.Marshal(body) - if err != nil { - return nil, []error{err} - } - - requests := []*adapters.RequestData{ - { - Method: "POST", - Uri: "https://e.serverbid.com/api/v2", - Body: bodyBytes, - Headers: headers, - }, - } - - return requests, errs } - -/* -internal original request in OpenRTB, external = result of us having converted it (what comes out of MakeRequests) -*/ -func (a *ConsumableAdapter) MakeBids( - internalRequest *openrtb2.BidRequest, - externalRequest *adapters.RequestData, - response *adapters.ResponseData, -) (*adapters.BidderResponse, []error) { - - if response.StatusCode == http.StatusNoContent { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } - if response.StatusCode == http.StatusBadRequest { - return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), - }} - } - - if response.StatusCode != http.StatusOK { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), - }} + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { + return nil, []error{err} } - var serverResponse bidResponse // response from Consumable - if err := json.Unmarshal(response.Body, &serverResponse); err != nil { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("error while decoding response, err: %s", err), - }} + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} } - bidderResponse := adapters.NewBidderResponse() + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur var errors []error + for _, seatBid := range response.SeatBid { + for i, bid := range seatBid.Bid { + bidType, err := getMediaTypeForBid(bid) + if err != nil { + errors = append(errors, err) + continue + } + var bidVideo *openrtb_ext.ExtBidPrebidVideo + if bidType == openrtb_ext.BidTypeVideo { + bidVideo = &openrtb_ext.ExtBidPrebidVideo{Duration: int(bid.Dur)} + } + switch bidType { + case openrtb_ext.BidTypeAudio: + seatBid.Bid[i].MType = openrtb2.MarkupAudio + break + case openrtb_ext.BidTypeVideo: + seatBid.Bid[i].MType = openrtb2.MarkupVideo + break + case openrtb_ext.BidTypeBanner: + seatBid.Bid[i].MType = openrtb2.MarkupBanner + break + } + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &seatBid.Bid[i], + BidType: bidType, + BidVideo: bidVideo, + }) + } + } + return bidResponse, nil +} - for impID, decision := range serverResponse.Decisions { +func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { + if bid.MType != 0 { + switch bid.MType { + case openrtb2.MarkupBanner: + return openrtb_ext.BidTypeBanner, nil + case openrtb2.MarkupVideo: + return openrtb_ext.BidTypeVideo, nil + case openrtb2.MarkupAudio: + return openrtb_ext.BidTypeAudio, nil + } + } - if decision.Pricing != nil && decision.Pricing.ClearPrice != nil { - bid := openrtb2.Bid{} - bid.ID = internalRequest.ID - bid.ImpID = impID - bid.Price = *decision.Pricing.ClearPrice - bid.AdM = retrieveAd(decision) - bid.W = int64(decision.Width) - bid.H = int64(decision.Height) - bid.CrID = strconv.FormatInt(decision.AdID, 10) - bid.Exp = 30 // TODO: Check this is intention of TTL - bid.ADomain = decision.Adomain - bid.Cat = decision.Cats - // not yet ported from prebid.js adapter - //bid.requestId = bidId; - //bid.currency = 'USD'; - //bid.netRevenue = true; - //bid.referrer = utils.getTopWindowUrl(); + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID), + } +} - bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ - Bid: &bid, - // Consumable units are always HTML, never VAST. - // From Prebid's point of view, this means that Consumable units - // are always "banners". - BidType: openrtb_ext.BidTypeBanner, - }) - } +// Builder builds a new instance of the Consumable adapter for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, } - return bidderResponse, errors + return bidder, nil } func extractExtensions(impression openrtb2.Imp) (*adapters.ExtImpBidder, *openrtb_ext.ExtImpConsumable, []error) { @@ -335,21 +160,3 @@ func extractExtensions(impression openrtb2.Imp) (*adapters.ExtImpBidder, *openrt return &bidderExt, &consumableExt, nil } - -// Builder builds a new instance of the Consumable adapter for the given bidder with the given config. -func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { - bidder := &ConsumableAdapter{ - clock: realInstant{}, - endpoint: config.Endpoint, - } - return bidder, nil -} - -func hasEids(eids []openrtb2.EID) bool { - for i := 0; i < len(eids); i++ { - if len(eids[i].UIDs) > 0 && eids[i].UIDs[0].ID != "" { - return true - } - } - return false -} diff --git a/adapters/consumable/consumable/exemplary/app-audio.json b/adapters/consumable/consumable/exemplary/app-audio.json new file mode 100644 index 00000000000..589842c8876 --- /dev/null +++ b/adapters/consumable/consumable/exemplary/app-audio.json @@ -0,0 +1,113 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "audio": { + "mimes": [ + "audio/mp3" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "audio": { + "mimes": [ + "audio/mp3" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ + { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "mtype": 3 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "crid": "crid_10", + "mtype": 3 + }, + "type": "audio" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/consumable/consumable/exemplary/app-banner.json b/adapters/consumable/consumable/exemplary/app-banner.json new file mode 100644 index 00000000000..688ccb74c05 --- /dev/null +++ b/adapters/consumable/consumable/exemplary/app-banner.json @@ -0,0 +1,111 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ + { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/consumable/consumable/exemplary/app-video.json b/adapters/consumable/consumable/exemplary/app-video.json new file mode 100644 index 00000000000..a3772933aba --- /dev/null +++ b/adapters/consumable/consumable/exemplary/app-video.json @@ -0,0 +1,126 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ + { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "cat": ["IAB15"], + "dur": 30, + "mtype": 2 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "cat": ["IAB15"], + "dur": 30, + "mtype": 2 + }, + "type": "video", + "BidType": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/consumable/consumable/exemplary/simple-banner.json b/adapters/consumable/consumable/exemplary/simple-banner.json index 173104ee9ad..2e401b88087 100644 --- a/adapters/consumable/consumable/exemplary/simple-banner.json +++ b/adapters/consumable/consumable/exemplary/simple-banner.json @@ -5,20 +5,32 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 250}] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { "networkId": 11, "siteId": 32, - "unitId": 42 + "unitId": 42, + "unitName": "cnsmbl-audio-728x90-slider" } } } ], "device": { "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36", - "ip": "123.123.123.123" + "ip": "123.123.123.123", + "geo": { + "country": "USA", + "region": "IL", + "city": "Elgin", + "zip": "60123" + } }, "site": { "domain": "www.some.com", @@ -28,75 +40,68 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36", + "geo": { + "country": "USA", + "region": "IL", + "city": "Elgin", + "zip": "60123" + } + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42, + "unitName": "cnsmbl-audio-728x90-slider" + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" - }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -107,14 +112,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/app-audio-bad-params.json b/adapters/consumable/consumable/supplemental/app-audio-bad-params.json new file mode 100644 index 00000000000..2dadc39c111 --- /dev/null +++ b/adapters/consumable/consumable/supplemental/app-audio-bad-params.json @@ -0,0 +1,37 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + + } + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "PlacementId is required for non-site requests", + "comparison": "literal" + } + ] +} diff --git a/adapters/consumable/consumable/supplemental/app-banner-no-ad.json b/adapters/consumable/consumable/supplemental/app-banner-no-ad.json new file mode 100644 index 00000000000..c3d7238e104 --- /dev/null +++ b/adapters/consumable/consumable/supplemental/app-banner-no-ad.json @@ -0,0 +1,75 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": { + } + } + } + ], + "expectedBidResponses": [ + + ] +} \ No newline at end of file diff --git a/adapters/consumable/consumable/supplemental/app-video-no-media-type.json b/adapters/consumable/consumable/supplemental/app-video-no-media-type.json new file mode 100644 index 00000000000..3cba39bb5b5 --- /dev/null +++ b/adapters/consumable/consumable/supplemental/app-video-no-media-type.json @@ -0,0 +1,110 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ + { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "cat": ["IAB15"], + "dur": 30 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + + ] + } + ] +} \ No newline at end of file diff --git a/adapters/consumable/consumable/supplemental/bad-dsp-request-example.json b/adapters/consumable/consumable/supplemental/bad-dsp-request-example.json new file mode 100644 index 00000000000..c66bb9ab5de --- /dev/null +++ b/adapters/consumable/consumable/supplemental/bad-dsp-request-example.json @@ -0,0 +1,78 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": { + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/consumable/consumable/supplemental/dsp-server-internal-error-example.json b/adapters/consumable/consumable/supplemental/dsp-server-internal-error-example.json new file mode 100644 index 00000000000..07ad8e2358a --- /dev/null +++ b/adapters/consumable/consumable/supplemental/dsp-server-internal-error-example.json @@ -0,0 +1,78 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 500, + "body": { + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 500. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/consumable/consumable/supplemental/simple-banner-content-meta.json b/adapters/consumable/consumable/supplemental/simple-banner-content-meta.json index 56d24166fec..220c8ab2069 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-content-meta.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-content-meta.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{ "w": 728, "h": 250 }] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -36,71 +41,69 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": ["application/json"], - "Content-Type": ["application/json"], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": ["123.123.123.123"], - "Forwarded": ["for=123.123.123.123"], - "Origin": ["http://www.some.com"], - "Referer": ["http://www.some.com/page-where-ad-will-be-shown"] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "content": { - "id": "1009680902", - "title": "What You Know Bout Love", - "context": 3, - "url": "https://www.deezer.com/track/1009680902", - "artist": "Pop Smoke", - "album": "Shoot For The Stars Aim For The Moon" + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" }, - "placements": [ + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" - }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user": {}, - "enableBotFiltering": true, - "parallel": true + "site": { + "content": { + "album": "Shoot For The Stars Aim For The Moon", + "artist": "Pop Smoke", + "context": 3, + "id": "1009680902", + "title": "What You Know Bout Love", + "url": "https://www.deezer.com/track/1009680902" + }, + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents": [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -111,14 +114,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-coppa.json b/adapters/consumable/consumable/supplemental/simple-banner-coppa.json index d1551c92e7c..25b732a21ce 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-coppa.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-coppa.json @@ -31,76 +31,64 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "regs": { + "coppa": 1 }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "coppa": true + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -111,14 +99,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-eids.json b/adapters/consumable/consumable/supplemental/simple-banner-eids.json index 106796e21c0..d273117b1ae 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-eids.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-eids.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 250}] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -26,103 +31,99 @@ }, "user": { "ext": { - "eids": [{ - "source": "adserver.org", - "uids": [{ - "id": "TTD_ID", - "atype": 1, - "ext": { - "rtiPartner": "TDID" - } - }] - }] + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "TTD_ID", + "atype": 1, + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] } } }, "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, "user": { - "eids": [{ - "source": "adserver.org", - "uids": [{ - "id": "TTD_ID", - "atype": 1, - "ext": { - "rtiPartner": "TDID" + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "atype": 1, + "ext": { + "rtiPartner": "TDID" + }, + "id": "TTD_ID" + } + ] } - }] - }] - }, - "enableBotFiltering": true, - "gdpr": {}, - "parallel": true + ] + } + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -133,14 +134,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-gdpr-2.json b/adapters/consumable/consumable/supplemental/simple-banner-gdpr-2.json index 2e2d8588326..b2dbc9bdfbf 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-gdpr-2.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-gdpr-2.json @@ -33,78 +33,66 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "regs": { + "ext": { + "gdpr": 0 + } }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "gdpr": { - "applies": false + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -115,14 +103,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-gdpr-3.json b/adapters/consumable/consumable/supplemental/simple-banner-gdpr-3.json index ea7be2342b2..fccc96ed6df 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-gdpr-3.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-gdpr-3.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 250}] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -33,78 +38,66 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "gdpr": { - "consent": "abcdefghijklm" + "user": { + "ext": { + "consent": "abcdefghijklm" + } } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -115,14 +108,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-gdpr.json b/adapters/consumable/consumable/supplemental/simple-banner-gdpr.json index 3f6a953efa8..99105a77325 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-gdpr.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-gdpr.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 250}] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -38,79 +43,71 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "regs": { + "ext": { + "gdpr": 1 + } + }, + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "gdpr": { - "applies": true, - "consent": "abcdefghijklm" + "user": { + "ext": { + "consent": "abcdefghijklm" + } } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -121,14 +118,15 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 + }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-gpp.json b/adapters/consumable/consumable/supplemental/simple-banner-gpp.json index 9b2e3d75031..eae291c1c61 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-gpp.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-gpp.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 250}] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -26,83 +31,75 @@ }, "regs": { "gpp": "gppString", - "gpp_sid": [7] + "gpp_sid": [ + 7 + ] } }, "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "regs": { + "gpp": "gppString", + "gpp_sid": [ + 7 + ] }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "gpp": "gppString", - "gpp_sid": [7] + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -113,14 +110,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-meta.json b/adapters/consumable/consumable/supplemental/simple-banner-meta.json index 6c94c835aab..782ddc7bbe7 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-meta.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-meta.json @@ -28,77 +28,61 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" - }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } - ], - "adomain": ["consumabletv.com"], - "cats": ["IAB1", "IAB2"] + ] } - } + ], + "cur": "USD" } } } @@ -109,16 +93,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250, - "adomain": ["consumabletv.com"], - "cat": ["IAB1", "IAB2"] + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-no-impressionUrl.json b/adapters/consumable/consumable/supplemental/simple-banner-no-impressionUrl.json index 6e9787ee163..fddf160a548 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-no-impressionUrl.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-no-impressionUrl.json @@ -5,7 +5,12 @@ { "id": "test-no-impUrl-id", "banner": { - "format": [{"w": 300, "h": 250}] + "format": [ + { + "w": 300, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -30,104 +35,87 @@ "buyeruid": "azk-user-id" } }, - "httpCalls": [ { "expectedRequest": { - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "Cookie": [ - "azk=azk-user-id" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, - "uri": "https://e.serverbid.com/api/v2", + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [5], - "divName": "test-no-impUrl-id", - "networkId": 11, - "siteId": 32, - "unitId": 42, - "unitName": "the-answer" + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42, + "unitName": "the-answer" + } + }, + "id": "test-no-impUrl-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown", + "ref": "http://www.some.com/page-before-the-ad-if-any" }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "unitName": "the-answer", - "time": 1451651415, - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "referrer": "http://www.some.com/page-before-the-ad-if-any" + "user": { + "buyeruid": "azk-user-id" + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-no-impUrl-id": { - "adId": 1234567890, - "bidderName": "aol", - "pricing": { - "clearPrice": 0.5 - }, - "width": 300, - "height": 250, - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } ], - "expectedBidResponses": [ { "currency": "USD", "bids": [ { "bid": { - "id": "test-request-id", - "crid": "1234567890", - "impid": "test-no-impUrl-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "exp": 30, - "w": 300, - "h": 250 + "adm": "some-test-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-no-params.json b/adapters/consumable/consumable/supplemental/simple-banner-no-params.json new file mode 100644 index 00000000000..03d1ca9ce3e --- /dev/null +++ b/adapters/consumable/consumable/supplemental/simple-banner-no-params.json @@ -0,0 +1,43 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + + } + } + } + ], + "device": { + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36", + "ip": "123.123.123.123", + "geo": { + "country": "USA", + "region": "IL", + "city": "Elgin", + "zip": "60123" + } + }, + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "SiteId, NetworkId and UnitId are all required for site requests", + "comparison": "literal" + } + ] +} diff --git a/adapters/consumable/consumable/supplemental/simple-banner-schain.json b/adapters/consumable/consumable/supplemental/simple-banner-schain.json index 0b963a507e7..c3491e6d1e0 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-schain.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-schain.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 250}] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -43,81 +48,76 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "schain": { - "complete": 1, - "nodes": [ - { - "asi": "indirectseller.com", - "hp": 1, - "sid": "00001" + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" + }, + "source": { + "ext": { + "schain": { + "complete": 1, + "nodes": [ + { + "asi": "indirectseller.com", + "hp": 1, + "sid": "00001" + } + ], + "ver": "1.0" } - ], - "ver": "1.0" + } } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -128,14 +128,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/simple-banner-us-privacy.json b/adapters/consumable/consumable/supplemental/simple-banner-us-privacy.json index c09200c4bd3..bf27672805c 100644 --- a/adapters/consumable/consumable/supplemental/simple-banner-us-privacy.json +++ b/adapters/consumable/consumable/supplemental/simple-banner-us-privacy.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 250}] + "format": [ + { + "w": 728, + "h": 250 + } + ] }, "ext": { "bidder": { @@ -33,76 +38,66 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://e.serverbid.com/api/v2", - "headers": { - "Accept": [ - "application/json" - ], - "Content-Type": [ - "application/json" - ], - "User-Agent": [ - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" - ], - "X-Forwarded-For": [ - "123.123.123.123" - ], - "Forwarded": [ - "for=123.123.123.123" - ], - "Origin": [ - "http://www.some.com" - ], - "Referer": [ - "http://www.some.com/page-where-ad-will-be-shown" - ] - }, + "uri": "https://e.serverbid.com/sb/rtb", "body": { - "placements": [ + "device": { + "ip": "123.123.123.123", + "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36" + }, + "id": "test-request-id", + "imp": [ { - "adTypes": [2730], - "divName": "test-imp-id", - "networkId": 11, - "siteId": 32, - "unitId": 42 + "banner": { + "format": [ + { + "h": 250, + "w": 728 + } + ] + }, + "ext": { + "bidder": { + "networkId": 11, + "siteId": 32, + "unitId": 42 + } + }, + "id": "test-imp-id" } ], - "schain": { - "complete": 0, - "nodes": null, - "ver": "" + "site": { + "domain": "www.some.com", + "page": "http://www.some.com/page-where-ad-will-be-shown" }, - "networkId": 11, - "siteId": 32, - "unitId": 42, - "time": 1451651415, - "url": "http://www.some.com/page-where-ad-will-be-shown", - "includePricingData": true, - "user":{}, - "enableBotFiltering": true, - "parallel": true, - "ccpa": "1NYN" + "regs": { + "ext": { + "us_privacy": "1NYN" + } + } } }, "mockResponse": { "status": 200, "body": { - "decisions": { - "test-imp-id": { - "adId": 1234567890, - "pricing": { - "clearPrice": 0.5 - }, - "width": 728, - "height": 250, - "impressionUrl": "http://localhost:8080/shown", - "contents" : [ + "id": "test-request-id", + "seatbid": [ + { + "seat": "bmtm", + "bid": [ { - "body": "Remember this: https://www.google.com/search?q=blink+tag ?" + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1 } ] } - } + ], + "cur": "USD" } } } @@ -113,14 +108,14 @@ "bids": [ { "bid": { - "id": "test-request-id", + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "Remember this: https://www.google.com/search?q=blink+tag ?", - "crid": "1234567890", - "exp": 30, + "adm": "some-test-ad", + "crid": "crid_10", "w": 728, - "h": 250 + "h": 90, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/consumable/consumable/supplemental/unknown-status-code-example.json b/adapters/consumable/consumable/supplemental/unknown-status-code-example.json new file mode 100644 index 00000000000..58fafcff6b2 --- /dev/null +++ b/adapters/consumable/consumable/supplemental/unknown-status-code-example.json @@ -0,0 +1,78 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://e.serverbid.com/rtb/bid?s=0421008445828ceb46f496700a5fa65e", + "body": { + "id": "test-request-id", + "app": { + "id": "1", + "bundle": "com.foo.bar" + }, + "device": { + "ua": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36", + "ip": "73.55.27.72" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 728, + "h": 90 + } + ] + }, + "ext": { + "bidder": { + "placementId": "0421008445828ceb46f496700a5fa65e" + } + } + } + ] + } + }, + "mockResponse": { + "status": 301, + "body": { + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 301. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/consumable/consumable_test.go b/adapters/consumable/consumable_test.go index e3bedce5e2f..75e69535f20 100644 --- a/adapters/consumable/consumable_test.go +++ b/adapters/consumable/consumable_test.go @@ -1,14 +1,14 @@ package consumable import ( - "testing" - "time" - + "encoding/json" + "github.com/prebid/openrtb/v19/adcom1" + "github.com/prebid/openrtb/v19/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" + "testing" ) func TestJsonSamples(t *testing.T) { @@ -19,18 +19,75 @@ func TestJsonSamples(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - assertClock(t, bidder) - replaceClockWithKnownTime(bidder) - adapterstest.RunJSONBidderTest(t, "consumable", bidder) } -func assertClock(t *testing.T, bidder adapters.Bidder) { - bidderConsumable, _ := bidder.(*ConsumableAdapter) - assert.NotNil(t, bidderConsumable.clock) -} +func TestConsumableMakeBidsWithCategoryDuration(t *testing.T) { + bidder := &adapter{} + + mockedReq := &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ + ID: "1_1", + Video: &openrtb2.Video{ + W: 640, + H: 360, + MIMEs: []string{"video/mp4"}, + MaxDuration: 60, + Protocols: []adcom1.MediaCreativeSubtype{2, 3, 5, 6}, + }, + Ext: json.RawMessage( + `{ + "prebid": {}, + "bidder": { + "placementId": "123456" + } + }`, + )}, + }, + } + mockedExtReq := &adapters.RequestData{} + mockedBidResponse := &openrtb2.BidResponse{ + ID: "test-1", + SeatBid: []openrtb2.SeatBid{{ + Seat: "Buyer", + Bid: []openrtb2.Bid{{ + ID: "1", + ImpID: "1_1", + Price: 1.23, + AdID: "123", + Cat: []string{"IAB18-1"}, + Dur: 30, + MType: openrtb2.MarkupVideo, + }}, + }}, + } + body, _ := json.Marshal(mockedBidResponse) + mockedRes := &adapters.ResponseData{ + StatusCode: 200, + Body: body, + } + + expectedBidCount := 1 + expectedBidType := openrtb_ext.BidTypeVideo + expectedBidDuration := 30 + expectedBidCategory := "IAB18-1" + expectedErrorCount := 0 -func replaceClockWithKnownTime(bidder adapters.Bidder) { - bidderConsumable, _ := bidder.(*ConsumableAdapter) - bidderConsumable.clock = knownInstant(time.Date(2016, 1, 1, 12, 30, 15, 0, time.UTC)) + bidResponse, errors := bidder.MakeBids(mockedReq, mockedExtReq, mockedRes) + + if len(bidResponse.Bids) != expectedBidCount { + t.Errorf("should have 1 bid, bids=%v", bidResponse.Bids) + } + if bidResponse.Bids[0].BidType != expectedBidType { + t.Errorf("bid type should be video, bidType=%s", bidResponse.Bids[0].BidType) + } + if bidResponse.Bids[0].BidVideo.Duration != expectedBidDuration { + t.Errorf("video duration should be set") + } + if bidResponse.Bids[0].Bid.Cat[0] != expectedBidCategory { + t.Errorf("bid category should be set") + } + if len(errors) != expectedErrorCount { + t.Errorf("should not have any errors, errors=%v", errors) + } } diff --git a/adapters/consumable/instant.go b/adapters/consumable/instant.go deleted file mode 100644 index a6162d44e22..00000000000 --- a/adapters/consumable/instant.go +++ /dev/null @@ -1,21 +0,0 @@ -package consumable - -import "time" - -type instant interface { - Now() time.Time -} - -// Send a real instance when you construct it in adapter_map.go -type realInstant struct{} - -func (realInstant) Now() time.Time { - return time.Now() -} - -// Use this for tests e.g. knownInstant(time.Date(y, m, ..., time.UTC)) -type knownInstant time.Time - -func (i knownInstant) Now() time.Time { - return time.Time(i) -} diff --git a/adapters/consumable/params_test.go b/adapters/consumable/params_test.go index fdb3edec41b..99a993e9752 100644 --- a/adapters/consumable/params_test.go +++ b/adapters/consumable/params_test.go @@ -43,6 +43,7 @@ var validParams = []string{ `{"networkId": 22, "siteId": 1, "unitId": 101, "unitName": "unit-1"}`, `{"networkId": 22, "siteId": 1, "unitId": 101, "unitName": "-unit-1"}`, // unitName can start with a dash `{"networkId": 22, "siteId": 1, "unitId": 101}`, // unitName can be omitted (although prebid.js doesn't allow that) + `{"placementId": "abcdjk232"}`, } var invalidParams = []string{ @@ -56,4 +57,5 @@ var invalidParams = []string{ `{"siteId": 1, "unitId": 101, "unitName": 11}`, // networkId must be present `{"networkId": 22, "unitId": 101, "unitName": 11}`, // siteId must be present `{"siteId": 1, "networkId": 22, "unitName": 11}`, // unitId must be present + `{"placementId": "---abjk;jkewj;k;jwejklfs}`, // placementId must be alphanumeric } diff --git a/adapters/consumable/retrieveAd.go b/adapters/consumable/retrieveAd.go deleted file mode 100644 index 7f69a1bbc23..00000000000 --- a/adapters/consumable/retrieveAd.go +++ /dev/null @@ -1,10 +0,0 @@ -package consumable - -func retrieveAd(decision decision) string { - - if decision.Contents != nil && len(decision.Contents) > 0 { - return decision.Contents[0].Body - } - - return "" -} diff --git a/adapters/dxkulture/dxkulture_test.go b/adapters/dxkulture/dxkulture_test.go index fb14c2b3c6a..7344d5a9d51 100644 --- a/adapters/dxkulture/dxkulture_test.go +++ b/adapters/dxkulture/dxkulture_test.go @@ -9,7 +9,7 @@ import ( ) func TestJsonSamples(t *testing.T) { - bidder, buildErr := Builder("dxkulture", config.Adapter{Endpoint: "https://ads.kulture.media/pbs"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + bidder, buildErr := Builder("dxkulture", config.Adapter{Endpoint: "https://ads.dxkulture.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/dxkulture/dxkulturetest/exemplary/banner.json b/adapters/dxkulture/dxkulturetest/exemplary/banner.json index 3b84881fc67..86b0e928c67 100644 --- a/adapters/dxkulture/dxkulturetest/exemplary/banner.json +++ b/adapters/dxkulture/dxkulturetest/exemplary/banner.json @@ -57,7 +57,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/exemplary/empty-site-domain-ref.json b/adapters/dxkulture/dxkulturetest/exemplary/empty-site-domain-ref.json index 630467ce96b..7460153f5ab 100644 --- a/adapters/dxkulture/dxkulturetest/exemplary/empty-site-domain-ref.json +++ b/adapters/dxkulture/dxkulturetest/exemplary/empty-site-domain-ref.json @@ -53,7 +53,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/exemplary/ipv6.json b/adapters/dxkulture/dxkulturetest/exemplary/ipv6.json index 58f7e7fdf2c..20841500d58 100644 --- a/adapters/dxkulture/dxkulturetest/exemplary/ipv6.json +++ b/adapters/dxkulture/dxkulturetest/exemplary/ipv6.json @@ -53,7 +53,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/exemplary/video-test-request.json b/adapters/dxkulture/dxkulturetest/exemplary/video-test-request.json index 6a0746ad258..f1d0a840ba0 100644 --- a/adapters/dxkulture/dxkulturetest/exemplary/video-test-request.json +++ b/adapters/dxkulture/dxkulturetest/exemplary/video-test-request.json @@ -62,7 +62,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=test", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=test", "body": { "id": "test-request-id", "test": 1, diff --git a/adapters/dxkulture/dxkulturetest/exemplary/video.json b/adapters/dxkulture/dxkulturetest/exemplary/video.json index 017dd5ea2bc..37f4b9e8236 100644 --- a/adapters/dxkulture/dxkulturetest/exemplary/video.json +++ b/adapters/dxkulture/dxkulturetest/exemplary/video.json @@ -61,7 +61,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/supplemental/invalid-response.json b/adapters/dxkulture/dxkulturetest/supplemental/invalid-response.json index 8fff1bb0375..4ef0539c69b 100644 --- a/adapters/dxkulture/dxkulturetest/supplemental/invalid-response.json +++ b/adapters/dxkulture/dxkulturetest/supplemental/invalid-response.json @@ -61,7 +61,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/supplemental/no-mtype.json b/adapters/dxkulture/dxkulturetest/supplemental/no-mtype.json index a56200fad50..a65a46ef0ee 100644 --- a/adapters/dxkulture/dxkulturetest/supplemental/no-mtype.json +++ b/adapters/dxkulture/dxkulturetest/supplemental/no-mtype.json @@ -61,7 +61,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/supplemental/status-code-bad-request.json b/adapters/dxkulture/dxkulturetest/supplemental/status-code-bad-request.json index f0f2ce2c47b..0338be9f811 100644 --- a/adapters/dxkulture/dxkulturetest/supplemental/status-code-bad-request.json +++ b/adapters/dxkulture/dxkulturetest/supplemental/status-code-bad-request.json @@ -61,7 +61,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/supplemental/status-code-no-content.json b/adapters/dxkulture/dxkulturetest/supplemental/status-code-no-content.json index 43c53f3d64c..4363b998cf7 100644 --- a/adapters/dxkulture/dxkulturetest/supplemental/status-code-no-content.json +++ b/adapters/dxkulture/dxkulturetest/supplemental/status-code-no-content.json @@ -61,7 +61,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/dxkulture/dxkulturetest/supplemental/status-code-other-error.json b/adapters/dxkulture/dxkulturetest/supplemental/status-code-other-error.json index 3e1b0b33c1e..608521b42a0 100644 --- a/adapters/dxkulture/dxkulturetest/supplemental/status-code-other-error.json +++ b/adapters/dxkulture/dxkulturetest/supplemental/status-code-other-error.json @@ -61,7 +61,7 @@ "2.5" ] }, - "uri": "https://ads.kulture.media/pbs?placement_id=placement123&publisher_id=pub123", + "uri": "https://ads.dxkulture.com/pbs?placement_id=placement123&publisher_id=pub123", "body": { "id": "test-request-id", "user": { diff --git a/adapters/nextmillennium/nextmillennium.go b/adapters/nextmillennium/nextmillennium.go index 5d10cac2d9e..966f96de47a 100644 --- a/adapters/nextmillennium/nextmillennium.go +++ b/adapters/nextmillennium/nextmillennium.go @@ -14,6 +14,7 @@ import ( type adapter struct { endpoint string + nmmFlags []string } type nmExtPrebidStoredRequest struct { @@ -22,8 +23,12 @@ type nmExtPrebidStoredRequest struct { type nmExtPrebid struct { StoredRequest nmExtPrebidStoredRequest `json:"storedrequest"` } +type nmExtNMM struct { + NmmFlags []string `json:"nmmFlags,omitempty"` +} type nextMillJsonExt struct { - Prebid nmExtPrebid `json:"prebid"` + Prebid nmExtPrebid `json:"prebid"` + NextMillennium nmExtNMM `json:"nextMillennium,omitempty"` } // MakeRequests prepares request information for prebid-server core @@ -77,7 +82,7 @@ func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ImpExtNextMillennium, err } func (adapter *adapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ImpExtNextMillennium) (*adapters.RequestData, error) { - newBidRequest := createBidRequest(prebidBidRequest, params) + newBidRequest := createBidRequest(prebidBidRequest, params, adapter.nmmFlags) reqJSON, err := json.Marshal(newBidRequest) if err != nil { @@ -96,7 +101,7 @@ func (adapter *adapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidReques Headers: headers}, nil } -func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ImpExtNextMillennium) *openrtb2.BidRequest { +func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ImpExtNextMillennium, flags []string) *openrtb2.BidRequest { placementID := params.PlacementID if params.GroupID != "" { @@ -122,6 +127,7 @@ func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext } ext := nextMillJsonExt{} ext.Prebid.StoredRequest.ID = placementID + ext.NextMillennium.NmmFlags = flags jsonExt, err := json.Marshal(ext) if err != nil { return prebidBidRequest @@ -169,7 +175,15 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR // Builder builds a new instance of the NextMillennium adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + var info nmExtNMM + if config.ExtraAdapterInfo != "" { + if err := json.Unmarshal([]byte(config.ExtraAdapterInfo), &info); err != nil { + return nil, fmt.Errorf("invalid extra info: %v", err) + } + } + return &adapter{ endpoint: config.Endpoint, + nmmFlags: info.NmmFlags, }, nil } diff --git a/adapters/nextmillennium/nextmillennium_test.go b/adapters/nextmillennium/nextmillennium_test.go index ec813ba2412..6e51edc5e17 100644 --- a/adapters/nextmillennium/nextmillennium_test.go +++ b/adapters/nextmillennium/nextmillennium_test.go @@ -6,6 +6,7 @@ import ( "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) { @@ -18,3 +19,15 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "nextmillenniumtest", bidder) } +func TestWithExtraInfo(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderNextMillennium, config.Adapter{ + Endpoint: "https://pbs.nextmillmedia.com/openrtb2/auction", + ExtraAdapterInfo: "{\"nmmFlags\":[\"flag1\",\"flag2\"]}", + }, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + bidderNextMillennium, _ := bidder.(*adapter) + assert.Equal(t, bidderNextMillennium.nmmFlags, []string{"flag1", "flag2"}) +} diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-empty-group-id.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-empty-group-id.json index 7a628d0fd91..19212134463 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-empty-group-id.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-empty-group-id.json @@ -33,6 +33,7 @@ "body":{ "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" @@ -54,6 +55,7 @@ ] }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id.json index 3538113014d..129c025e1da 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id.json @@ -44,6 +44,7 @@ "body":{ "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;www.example.com" @@ -67,6 +68,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;www.example.com" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id_app.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id_app.json index 25c1f36deff..2ddf9bee948 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id_app.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-group-id_app.json @@ -40,6 +40,7 @@ "domain": "www.example.com" }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;www.example.com" @@ -63,6 +64,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;www.example.com" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-only-width.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-only-width.json index 79c9894f424..4db65ec46cd 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-only-width.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-only-width.json @@ -29,6 +29,7 @@ "domain": "www.example.com" }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;;www.example.com" @@ -41,6 +42,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;;www.example.com" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-wh.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-wh.json index 6af7816eb21..f7da0784728 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-wh.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-with-wh.json @@ -30,6 +30,7 @@ "domain": "www.example.com" }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;www.example.com" @@ -43,6 +44,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;www.example.com" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-domain.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-domain.json index 181dab3548b..d27dffafaf1 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-domain.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-domain.json @@ -34,6 +34,7 @@ "body":{ "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;" @@ -57,6 +58,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-size.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-size.json index f2422033b81..c5b9276700d 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-size.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner-wo-size.json @@ -32,6 +32,7 @@ "body":{ "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;" @@ -53,6 +54,7 @@ ] }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;320x250;" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner.json index fa8834fa998..df736d79757 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/banner.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/banner.json @@ -34,6 +34,7 @@ "body":{ "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" @@ -57,6 +58,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" diff --git a/adapters/nextmillennium/nextmillenniumtest/exemplary/empty-banner-obj.json b/adapters/nextmillennium/nextmillenniumtest/exemplary/empty-banner-obj.json index cc9f9eb980b..2d357ffb99c 100644 --- a/adapters/nextmillennium/nextmillenniumtest/exemplary/empty-banner-obj.json +++ b/adapters/nextmillennium/nextmillenniumtest/exemplary/empty-banner-obj.json @@ -21,6 +21,7 @@ "body":{ "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;;" @@ -31,6 +32,7 @@ { "banner": {}, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "g7819;;" diff --git a/adapters/nextmillennium/nextmillenniumtest/supplemental/empty-seatbid.json b/adapters/nextmillennium/nextmillenniumtest/supplemental/empty-seatbid.json index dd070d62427..8f3588de144 100644 --- a/adapters/nextmillennium/nextmillenniumtest/supplemental/empty-seatbid.json +++ b/adapters/nextmillennium/nextmillenniumtest/supplemental/empty-seatbid.json @@ -33,6 +33,7 @@ "body": { "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" @@ -56,6 +57,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" diff --git a/adapters/nextmillennium/nextmillenniumtest/supplemental/error-response.json b/adapters/nextmillennium/nextmillenniumtest/supplemental/error-response.json index 3e8047fae54..f7b23ac9bcf 100644 --- a/adapters/nextmillennium/nextmillenniumtest/supplemental/error-response.json +++ b/adapters/nextmillennium/nextmillenniumtest/supplemental/error-response.json @@ -29,6 +29,7 @@ "body": { "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" @@ -48,6 +49,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" diff --git a/adapters/nextmillennium/nextmillenniumtest/supplemental/no-content.json b/adapters/nextmillennium/nextmillenniumtest/supplemental/no-content.json index c4710a376d0..699be4e9aad 100644 --- a/adapters/nextmillennium/nextmillenniumtest/supplemental/no-content.json +++ b/adapters/nextmillennium/nextmillenniumtest/supplemental/no-content.json @@ -29,6 +29,7 @@ "body": { "id": "testid", "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" @@ -48,6 +49,7 @@ "w": 320 }, "ext": { + "nextMillennium": {}, "prebid": { "storedrequest": { "id": "7819" diff --git a/adapters/sovrnXsp/params_test.go b/adapters/sovrnXsp/params_test.go new file mode 100644 index 00000000000..cca8b22cf51 --- /dev/null +++ b/adapters/sovrnXsp/params_test.go @@ -0,0 +1,56 @@ +package sovrnXsp + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v2/openrtb_ext" +) + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + + if err != nil { + t.Fatalf("Failed to fetch json-schemas. %v", err) + } + + for _, param := range validParams { + if err := validator.Validate(openrtb_ext.BidderSovrnXsp, json.RawMessage(param)); err != nil { + t.Errorf("Schema rejected sovrnXsp params: %s", param) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + + if err != nil { + t.Fatalf("Failed to fetch json-schemas. %v", err) + } + + for _, param := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderSovrnXsp, json.RawMessage(param)); err == nil { + t.Errorf("Schema allowed sovrnXsp params: %s", param) + } + } +} + +var validParams = []string{ + `{"pub_id":"1234"}`, + `{"pub_id":"1234","med_id":"1234"}`, + `{"pub_id":"1234","med_id":"1234","zone_id":"abcdefghijklmnopqrstuvwxyz"}`, + `{"pub_id":"1234","med_id":"1234","zone_id":"abcdefghijklmnopqrstuvwxyz","force_bid":true}`, + `{"pub_id":"1234","med_id":"1234","zone_id":"abcdefghijklmnopqrstuvwxyz","force_bid":false}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `0`, + `[]`, + `{}`, + `{"pub_id":""}`, + `{"pub_id":"123"}`, + `{"pub_id":"1234","zone_id":"123"}`, +} diff --git a/adapters/sovrnXsp/sovrnXsp.go b/adapters/sovrnXsp/sovrnXsp.go new file mode 100644 index 00000000000..a026f888c72 --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsp.go @@ -0,0 +1,172 @@ +package sovrnXsp + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/prebid/prebid-server/v2/adapters" + "github.com/prebid/prebid-server/v2/config" + "github.com/prebid/prebid-server/v2/errortypes" + "github.com/prebid/prebid-server/v2/openrtb_ext" + + "github.com/prebid/openrtb/v19/openrtb2" +) + +type adapter struct { + Endpoint string +} + +// bidExt.CreativeType values. +const ( + creativeTypeBanner int = 0 + creativeTypeVideo = 1 + creativeTypeNative = 2 + creativeTypeAudio = 3 +) + +// Bid response extension from XSP. +type bidExt struct { + CreativeType int `json:"creative_type"` +} + +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + appCopy := *request.App + if appCopy.Publisher == nil { + appCopy.Publisher = &openrtb2.Publisher{} + } else { + publisherCopy := *appCopy.Publisher + appCopy.Publisher = &publisherCopy + } + request.App = &appCopy + + var errors []error + var imps []openrtb2.Imp + + for idx, imp := range request.Imp { + if imp.Banner == nil && imp.Video == nil && imp.Native == nil { + continue + } + + var bidderExt adapters.ExtImpBidder + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + err = &errortypes.BadInput{ + Message: fmt.Sprintf("imp #%d: ext.bidder not provided", idx), + } + errors = append(errors, err) + continue + } + + var xspExt openrtb_ext.ExtImpSovrnXsp + if err := json.Unmarshal(bidderExt.Bidder, &xspExt); err != nil { + err = &errortypes.BadInput{ + Message: fmt.Sprintf("imp #%d: %s", idx, err.Error()), + } + errors = append(errors, err) + continue + } + + request.App.Publisher.ID = xspExt.PubID + if xspExt.MedID != "" { + request.App.ID = xspExt.MedID + } + if xspExt.ZoneID != "" { + imp.TagID = xspExt.ZoneID + } + imps = append(imps, imp) + } + + if len(imps) == 0 { + return nil, append(errors, &errortypes.BadInput{ + Message: "no matching impression with ad format", + }) + } + + request.Imp = imps + requestJson, err := json.Marshal(request) + if err != nil { + return nil, append(errors, err) + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + headers.Add("x-openrtb-version", "2.5") + + return []*adapters.RequestData{{ + Method: "POST", + Uri: a.Endpoint, + Body: requestJson, + Headers: headers, + }}, errors +} + +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(responseData); err != nil { + return nil, []error{err} + } + + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } + + var errors []error + result := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + + for _, seatBid := range response.SeatBid { + for _, bid := range seatBid.Bid { + bid := bid + var ext bidExt + if err := json.Unmarshal(bid.Ext, &ext); err != nil { + errors = append(errors, err) + continue + } + + var bidType openrtb_ext.BidType + var mkupType openrtb2.MarkupType + switch ext.CreativeType { + case creativeTypeBanner: + bidType = openrtb_ext.BidTypeBanner + mkupType = openrtb2.MarkupBanner + case creativeTypeVideo: + bidType = openrtb_ext.BidTypeVideo + mkupType = openrtb2.MarkupVideo + case creativeTypeNative: + bidType = openrtb_ext.BidTypeNative + mkupType = openrtb2.MarkupNative + default: + errors = append(errors, &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unsupported creative type: %d", ext.CreativeType), + }) + continue + } + + if bid.MType == 0 { + bid.MType = mkupType + } + + result.Bids = append(result.Bids, &adapters.TypedBid{ + Bid: &bid, + BidType: bidType, + }) + } + } + + if len(result.Bids) == 0 { + // it's possible an empty seat array was sent as a response + return nil, errors + } + return result, errors +} + +// Builder builds a new instance of the SovrnXSP adapter for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + bidder := &adapter{ + Endpoint: config.Endpoint, + } + return bidder, nil +} diff --git a/adapters/sovrnXsp/sovrnXsp_test.go b/adapters/sovrnXsp/sovrnXsp_test.go new file mode 100644 index 00000000000..4c93fc39fa8 --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsp_test.go @@ -0,0 +1,20 @@ +package sovrnXsp + +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" +) + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderSovrnXsp, config.Adapter{ + Endpoint: "http://xsp.lijit.com/json/rtb/prebid/server"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "sovrnXsptest", bidder) +} diff --git a/adapters/sovrnXsp/sovrnXsptest/exemplary/banner.json b/adapters/sovrnXsp/sovrnXsptest/exemplary/banner.json new file mode 100644 index 00000000000..08f36adb91b --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/exemplary/banner.json @@ -0,0 +1,119 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://xsp.lijit.com/json/rtb/prebid/server", + "body":{ + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [{ + "id": "imp123", + "tagid": "FgUtQqop18uf1I2fwDie", + "bidfloor": 1.0, + "banner": { + "format": [{ + "w": 300, + "h": 250 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "abc", + "seatbid": [ + { + "bid": [ + { + "adm": "", + "crid": "test_banner_crid", + "cid": "test_cid", + "impid": "imp123", + "id": "1", + "price": 1.0, + "ext": { + "creative_type": 0 + } + } + ] + } + ] + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "crid": "test_banner_crid", + "cid": "test_cid", + "impid": "imp123", + "price": 1.0, + "id": "1", + "mtype": 1, + "ext": { + "creative_type": 0 + } + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/sovrnXsp/sovrnXsptest/exemplary/native.json b/adapters/sovrnXsp/sovrnXsptest/exemplary/native.json new file mode 100644 index 00000000000..f82297e3bb2 --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/exemplary/native.json @@ -0,0 +1,109 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "native": { + "ver": "1.2", + "request": "{\"context\":1,\"plcmttype\":1,\"assets\":[{\"id\":0,\"required\":1,\"img\":{\"type\":3,\"w\":300,\"h\":250}},{\"id\":1,\"required\":1,\"title\":{\"len\":140}},{\"id\":2,\"data\":{\"type\":1}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1]}]}" + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://xsp.lijit.com/json/rtb/prebid/server", + "body":{ + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [{ + "id": "imp123", + "tagid": "FgUtQqop18uf1I2fwDie", + "bidfloor": 1.0, + "native": { + "ver": "1.2", + "request": "{\"context\":1,\"plcmttype\":1,\"assets\":[{\"id\":0,\"required\":1,\"img\":{\"type\":3,\"w\":300,\"h\":250}},{\"id\":1,\"required\":1,\"title\":{\"len\":140}},{\"id\":2,\"data\":{\"type\":1}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1]}]}" + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "abc", + "seatbid": [ + { + "bid": [ + { + "adm": "{\"ver\":\"1.2\",\"link\":{\"url\":\"https://sovrn.com\"},\"assets\":[{\"id\":0,\"img\":{\"w\":300,\"h\":250,\"url\":\"https://ads.smrtb.com/demo/ads/300x250.png\"}},{\"id\":1,\"title\":{\"text\":\"Test Ad\",\"len\":7}},{\"id\":2,\"data\":{\"value\":\"0\",\"len\":1}}]}", + "crid": "test_native_crid", + "cid": "test_cid", + "impid": "imp123", + "id": "1", + "price": 1.0, + "ext": { + "creative_type": 2 + } + } + ] + } + ] + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "{\"ver\":\"1.2\",\"link\":{\"url\":\"https://sovrn.com\"},\"assets\":[{\"id\":0,\"img\":{\"w\":300,\"h\":250,\"url\":\"https://ads.smrtb.com/demo/ads/300x250.png\"}},{\"id\":1,\"title\":{\"text\":\"Test Ad\",\"len\":7}},{\"id\":2,\"data\":{\"value\":\"0\",\"len\":1}}]}", + "crid": "test_native_crid", + "cid": "test_cid", + "impid": "imp123", + "price": 1.0, + "id": "1", + "mtype": 4, + "ext": { + "creative_type": 2 + } + }, + "type": "native" + } + ] + } + ] +} diff --git a/adapters/sovrnXsp/sovrnXsptest/exemplary/video.json b/adapters/sovrnXsp/sovrnXsptest/exemplary/video.json new file mode 100644 index 00000000000..5ba8259f063 --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/exemplary/video.json @@ -0,0 +1,121 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "video": { + "w": 300, + "h": 250, + "protocols": [1,2,3,4,5,6,7,8], + "playbackmethod": [1], + "mimes": ["video/mp4"], + "skip": 1, + "api": [2], + "maxbitrate": 3000 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://xsp.lijit.com/json/rtb/prebid/server", + "body":{ + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [{ + "id": "imp123", + "bidfloor": 1.0, + "tagid": "FgUtQqop18uf1I2fwDie", + "video": { + "w": 300, + "h": 250, + "protocols": [1,2,3,4,5,6,7,8], + "playbackmethod": [1], + "mimes": ["video/mp4"], + "skip": 1, + "api": [2], + "maxbitrate": 3000 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "abc", + "seatbid": [ + { + "bid": [ + { + "adm": "Mc0Sovrn PSA00:00:30", + "crid": "sovrn_psa_crid_1", + "cid": "sovrn_psa", + "impid": "imp123", + "id": "1", + "price": 1.0, + "ext": { + "creative_type": 1 + } + } + ] + } + ] + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "Mc0Sovrn PSA00:00:30", + "crid": "sovrn_psa_crid_1", + "cid": "sovrn_psa", + "impid": "imp123", + "price": 1.0, + "id": "1", + "mtype": 2, + "ext": { + "creative_type": 1 + } + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/sovrnXsp/sovrnXsptest/supplemental/request-no-matching-imp.json b/adapters/sovrnXsp/sovrnXsptest/supplemental/request-no-matching-imp.json new file mode 100644 index 00000000000..d9719d0a2e1 --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/supplemental/request-no-matching-imp.json @@ -0,0 +1,30 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "expectedMakeRequestsErrors": [{ + "value": "no matching impression with ad format", + "comparison": "literal" + }] +} diff --git a/adapters/sovrnXsp/sovrnXsptest/supplemental/response-empty-seat.json b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-empty-seat.json new file mode 100644 index 00000000000..0de8fa072f8 --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-empty-seat.json @@ -0,0 +1,82 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://xsp.lijit.com/json/rtb/prebid/server", + "body":{ + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [{ + "id": "imp123", + "tagid": "FgUtQqop18uf1I2fwDie", + "bidfloor": 1.0, + "banner": { + "format": [{ + "w": 300, + "h": 250 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "abc", + "seatbid": [{}] + } + } + } + ], + + "expectedBidResponses": [] +} diff --git a/adapters/sovrnXsp/sovrnXsptest/supplemental/response-http-error.json b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-http-error.json new file mode 100644 index 00000000000..10f647186fd --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-http-error.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://xsp.lijit.com/json/rtb/prebid/server", + "body":{ + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [{ + "id": "imp123", + "tagid": "FgUtQqop18uf1I2fwDie", + "bidfloor": 1.0, + "banner": { + "format": [{ + "w": 300, + "h": 250 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + }] + } + }, + "mockResponse": { + "status": 500, + "body": {} + } + } + ], + + "expectedBidResponses": [], + + "expectedMakeBidsErrors": [{ + "value": "Unexpected status code: 500", + "comparison": "regex" + }] +} diff --git a/adapters/sovrnXsp/sovrnXsptest/supplemental/response-invalid-crtype.json b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-invalid-crtype.json new file mode 100644 index 00000000000..73bc7d87a53 --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-invalid-crtype.json @@ -0,0 +1,103 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://xsp.lijit.com/json/rtb/prebid/server", + "body":{ + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [{ + "id": "imp123", + "tagid": "FgUtQqop18uf1I2fwDie", + "bidfloor": 1.0, + "banner": { + "format": [{ + "w": 300, + "h": 250 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "abc", + "seatbid": [ + { + "bid": [ + { + "adm": "", + "crid": "test_banner_crid", + "cid": "test_cid", + "impid": "imp123", + "id": "1", + "price": 1.0, + "ext": { + "creative_type": 100 + } + } + ] + } + ] + } + } + } + ], + + "expectedBidResponses": [], + + "expectedMakeBidsErrors": [{ + "value": "Unsupported creative type: 100", + "comparison": "literal" + }] +} diff --git a/adapters/sovrnXsp/sovrnXsptest/supplemental/response-nobid.json b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-nobid.json new file mode 100644 index 00000000000..bb0e04a50fc --- /dev/null +++ b/adapters/sovrnXsp/sovrnXsptest/supplemental/response-nobid.json @@ -0,0 +1,79 @@ +{ + "mockBidRequest": { + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [ + { + "id": "imp123", + "bidfloor": 1.0, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://xsp.lijit.com/json/rtb/prebid/server", + "body":{ + "id": "abc", + "app": { + "id": "0jqCuiqHfPDHAHrdFfGG", + "bundle": "test", + "publisher": { + "id": "sovrn" + } + }, + "imp": [{ + "id": "imp123", + "tagid": "FgUtQqop18uf1I2fwDie", + "bidfloor": 1.0, + "banner": { + "format": [{ + "w": 300, + "h": 250 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "pub_id": "sovrn", + "med_id": "0jqCuiqHfPDHAHrdFfGG", + "zone_id": "FgUtQqop18uf1I2fwDie" + } + } + }] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + + "expectedBidResponses": [] +} diff --git a/adapters/stroeerCore/stroeercore.go b/adapters/stroeerCore/stroeercore.go index 5f0194061a8..590e641ff1f 100644 --- a/adapters/stroeerCore/stroeercore.go +++ b/adapters/stroeerCore/stroeercore.go @@ -30,6 +30,18 @@ type bidResponse struct { Height int64 `json:"height"` Ad string `json:"ad"` CrID string `json:"crid"` + Mtype string `json:"mtype"` +} + +func (b bidResponse) resolveMediaType() (mt openrtb2.MarkupType, bt openrtb_ext.BidType, err error) { + switch b.Mtype { + case "banner": + return openrtb2.MarkupBanner, openrtb_ext.BidTypeBanner, nil + case "video": + return openrtb2.MarkupVideo, openrtb_ext.BidTypeVideo, nil + default: + return mt, bt, fmt.Errorf("unable to determine media type for bid with id \"%s\"", b.BidID) + } } func (a *adapter) MakeBids(bidRequest *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { @@ -51,6 +63,14 @@ func (a *adapter) MakeBids(bidRequest *openrtb2.BidRequest, requestData *adapter bidderResponse.Currency = "EUR" for _, bid := range stroeerResponse.Bids { + markupType, bidType, err := bid.resolveMediaType() + if err != nil { + errors = append(errors, &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Bid media type error: %s", err.Error()), + }) + continue + } + openRtbBid := openrtb2.Bid{ ID: bid.ID, ImpID: bid.BidID, @@ -59,11 +79,12 @@ func (a *adapter) MakeBids(bidRequest *openrtb2.BidRequest, requestData *adapter Price: bid.CPM, AdM: bid.Ad, CrID: bid.CrID, + MType: markupType, } bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ Bid: &openRtbBid, - BidType: openrtb_ext.BidTypeBanner, + BidType: bidType, }) } diff --git a/adapters/stroeerCore/stroeercoretest/exemplary/mobile-banner-single.json b/adapters/stroeerCore/stroeercoretest/exemplary/mobile-banner-single.json index 0abdbc8b499..b91cc72fbde 100644 --- a/adapters/stroeerCore/stroeercoretest/exemplary/mobile-banner-single.json +++ b/adapters/stroeerCore/stroeercoretest/exemplary/mobile-banner-single.json @@ -161,7 +161,8 @@ "width": 468, "height": 60, "ad": "advert", - "crid": "XYZijk" + "crid": "XYZijk", + "mtype": "banner" } ] } @@ -179,7 +180,8 @@ "adm": "advert", "w": 468, "h": 60, - "crid": "XYZijk" + "crid": "XYZijk", + "mtype": 1 }, "type": "banner" }] diff --git a/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-multi.json b/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-multi.json index 091f244c6ef..03d6f10214e 100644 --- a/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-multi.json +++ b/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-multi.json @@ -138,7 +138,8 @@ "width": 468, "height": 60, "ad": "advert", - "crid": "qwert" + "crid": "qwert", + "mtype": "banner" }, { "id": "3929239282-02", @@ -147,7 +148,8 @@ "width": 770, "height": 250, "ad": "another advert", - "crid": "wasd" + "crid": "wasd", + "mtype": "banner" } ] } @@ -166,7 +168,8 @@ "adm": "advert", "w": 468, "h": 60, - "crid": "qwert" + "crid": "qwert", + "mtype": 1 }, "type": "banner" }, @@ -178,7 +181,8 @@ "adm": "another advert", "w": 770, "h": 250, - "crid": "wasd" + "crid": "wasd", + "mtype": 1 }, "type": "banner" } diff --git a/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-single.json b/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-single.json index ca6ea0c26ea..7dd860a72ba 100644 --- a/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-single.json +++ b/adapters/stroeerCore/stroeercoretest/exemplary/site-banner-single.json @@ -105,7 +105,8 @@ "width": 468, "height": 60, "ad": "advert", - "crid": "wasd" + "crid": "wasd", + "mtype": "banner" } ] } @@ -123,7 +124,8 @@ "adm": "advert", "w": 468, "h": 60, - "crid": "wasd" + "crid": "wasd", + "mtype": 1 }, "type": "banner" }] diff --git a/adapters/stroeerCore/stroeercoretest/exemplary/site-multi-format-single.json b/adapters/stroeerCore/stroeercoretest/exemplary/site-multi-format-single.json new file mode 100644 index 00000000000..57a6e39bc6e --- /dev/null +++ b/adapters/stroeerCore/stroeercoretest/exemplary/site-multi-format-single.json @@ -0,0 +1,146 @@ +{ + "mockBidRequest": { + "id": "auction-id", + "cur": ["EUR"], + "imp": [ + { + "id": "3", + "banner": { + "format": [ + { + "w": 468, + "h": 60 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "video": { + "mimes": ["video/mp4"], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "sid": "123456" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/some/path", + "ext": { + "amp": 1 + } + }, + "user": { + "buyeruid": "test-buyer-user-id" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Accept": ["application/json"], + "Content-Type": ["application/json;charset=utf-8"] + }, + "uri": "http://localhost/s2sdsh", + "body": { + "id": "auction-id", + "cur": ["EUR"], + "imp": [ + { + "id": "3", + "tagid": "123456", + "banner": { + "format": [ + { + "w": 468, + "h": 60 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "video": { + "mimes": ["video/mp4"], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "sid": "123456" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/some/path", + "ext": { + "amp": 1 + } + }, + "user": { + "buyeruid": "test-buyer-user-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "bids": [ + { + "id": "3929239282-01", + "bidId": "3", + "cpm": 2, + "width": 468, + "height": 60, + "ad": "banner ad", + "crid": "qwert", + "mtype": "banner" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ + { + "bid": { + "id": "3929239282-01", + "impid": "3", + "price": 2, + "adm": "banner ad", + "w": 468, + "h": 60, + "crid": "qwert", + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/stroeerCore/stroeercoretest/exemplary/site-multi-types.json b/adapters/stroeerCore/stroeercoretest/exemplary/site-multi-types.json new file mode 100644 index 00000000000..27cd32ba1d0 --- /dev/null +++ b/adapters/stroeerCore/stroeercoretest/exemplary/site-multi-types.json @@ -0,0 +1,186 @@ +{ + "mockBidRequest": { + "id": "auction-id", + "cur": ["EUR"], + "imp": [ + { + "id": "3", + "banner": { + "format": [ + { + "w": 468, + "h": 60 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "sid": "123456" + } + } + }, + { + "id": "9", + "video": { + "mimes": ["video/mp4"], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "sid": "85310" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/some/path", + "ext": { + "amp": 1 + } + }, + "user": { + "buyeruid": "test-buyer-user-id" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Accept": ["application/json"], + "Content-Type": ["application/json;charset=utf-8"] + }, + "uri": "http://localhost/s2sdsh", + "body": { + "id": "auction-id", + "cur": ["EUR"], + "imp": [ + { + "id": "3", + "tagid": "123456", + "banner": { + "format": [ + { + "w": 468, + "h": 60 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "sid": "123456" + } + } + }, + { + "id": "9", + "tagid": "85310", + "video": { + "mimes": ["video/mp4"], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "sid": "85310" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/some/path", + "ext": { + "amp": 1 + } + }, + "user": { + "buyeruid": "test-buyer-user-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "bids": [ + { + "id": "3929239282-01", + "bidId": "3", + "cpm": 2, + "width": 468, + "height": 60, + "ad": "banner ad", + "crid": "qwert", + "mtype": "banner" + }, + { + "id": "3929239282-02", + "bidId": "9", + "cpm": 7.21, + "width": 770, + "height": 250, + "ad": "video ad", + "crid": "wasd", + "mtype": "video" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids": [ + { + "bid": { + "id": "3929239282-01", + "impid": "3", + "price": 2, + "adm": "banner ad", + "w": 468, + "h": 60, + "crid": "qwert", + "mtype": 1 + }, + "type": "banner" + }, + { + "bid": { + "id": "3929239282-02", + "impid": "9", + "price": 7.21, + "adm": "video ad", + "w": 770, + "h": 250, + "crid": "wasd", + "mtype": 2 + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/stroeerCore/stroeercoretest/exemplary/site-video-single.json b/adapters/stroeerCore/stroeercoretest/exemplary/site-video-single.json new file mode 100644 index 00000000000..65b2da804ea --- /dev/null +++ b/adapters/stroeerCore/stroeercoretest/exemplary/site-video-single.json @@ -0,0 +1,116 @@ +{ + "mockBidRequest": { + "id": "auction-id", + "cur": ["EUR"], + "imp": [ + { + "id": "3", + "video": { + "mimes": ["video/mp4"], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "sid": "123456" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/some/path", + "ext": { + "amp": 0 + } + }, + "user": { + "buyeruid": "test-buyer-user-id" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Accept": ["application/json"], + "Content-Type": ["application/json;charset=utf-8"] + }, + "uri": "http://localhost/s2sdsh", + "body": { + "id": "auction-id", + "cur": ["EUR"], + "imp": [ + { + "id": "3", + "tagid": "123456", + "video": { + "mimes": ["video/mp4"], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "sid": "123456" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/some/path", + "ext": { + "amp": 0 + } + }, + "user": { + "buyeruid": "test-buyer-user-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "bids": [ + { + "id": "8923356982838-09", + "bidId": "3", + "cpm": 2, + "ad": "
video
", + "crid": "wasd", + "mtype": "video" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids" : [{ + "bid": { + "id": "8923356982838-09", + "impid": "3", + "price": 2, + "adm": "
video
", + "crid": "wasd", + "mtype": 2 + }, + "type": "video" + }] + } + ] +} diff --git a/adapters/stroeerCore/stroeercoretest/supplemental/unknown-bid-media-type.json b/adapters/stroeerCore/stroeercoretest/supplemental/unknown-bid-media-type.json new file mode 100644 index 00000000000..0cb74cd47a6 --- /dev/null +++ b/adapters/stroeerCore/stroeercoretest/supplemental/unknown-bid-media-type.json @@ -0,0 +1,193 @@ +{ + "mockBidRequest": { + "id": "id", + "imp": [ + { + "id": "banner-1", + "banner": { + "format": [ + { + "w": 300, + "h": 200 + } + ] + }, + "ext": { + "bidder": { + "sid": "tagid" + } + } + }, + { + "id": "banner-2", + "banner": { + "format": [ + { + "w": 300, + "h": 200 + } + ] + }, + "ext": { + "bidder": { + "sid": "tagid" + } + } + }, + { + "id": "banner-3", + "banner": { + "format": [ + { + "w": 300, + "h": 200 + } + ] + }, + "ext": { + "bidder": { + "sid": "tagid" + } + } + } + ], + "user": { + "buyeruid": "test-buyer-user-id" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Accept": ["application/json"], + "Content-Type": ["application/json;charset=utf-8"] + }, + "uri": "http://localhost/s2sdsh", + "body": { + "id": "id", + "imp": [ + { + "id": "banner-1", + "tagid": "tagid", + "banner": { + "format": [ + { + "w": 300, + "h": 200 + } + ] + }, + "ext": { + "bidder": { + "sid": "tagid" + } + } + }, + { + "id": "banner-2", + "tagid": "tagid", + "banner": { + "format": [ + { + "w": 300, + "h": 200 + } + ] + }, + "ext": { + "bidder": { + "sid": "tagid" + } + } + }, + { + "id": "banner-3", + "tagid": "tagid", + "banner": { + "format": [ + { + "w": 300, + "h": 200 + } + ] + }, + "ext": { + "bidder": { + "sid": "tagid" + } + } + } + ], + "user": { + "buyeruid": "test-buyer-user-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "bids": [ + { + "id": "3929239282-01", + "bidId": "banner-1", + "cpm": 2, + "width": 300, + "height": 200, + "ad": "banner ad 1", + "crid": "qwert", + "mtype": "unknown" + }, + { + "id": "3929239282-02", + "bidId": "banner-2", + "cpm": 2, + "width": 300, + "height": 200, + "ad": "banner ad 2", + "crid": "qwert" + }, + { + "id": "3929239282-03", + "bidId": "banner-3", + "cpm": 2, + "width": 300, + "height": 200, + "ad": "banner ad 3", + "crid": "qwert", + "mtype": "banner" + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "EUR", + "bids" : [{ + "bid": { + "id": "3929239282-03", + "impid": "banner-3", + "price": 2, + "adm": "banner ad 3", + "w": 300, + "h": 200, + "crid": "qwert", + "mtype": 1 + }, + "type": "banner" + }] + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Bid media type error: unable to determine media type for bid with id \"banner-1\"", + "comparison": "literal" + }, + { + "value": "Bid media type error: unable to determine media type for bid with id \"banner-2\"", + "comparison": "literal" + } + ] +} diff --git a/config/bidderinfo.go b/config/bidderinfo.go index d3c874f706b..d78f5722552 100644 --- a/config/bidderinfo.go +++ b/config/bidderinfo.go @@ -125,6 +125,9 @@ type Syncer struct { // SupportCORS identifies if CORS is supported for the user syncing endpoints. SupportCORS *bool `yaml:"supportCors" mapstructure:"support_cors"` + // FormatOverride allows a bidder to override their callback type "b" for iframe, "i" for redirect + FormatOverride string `yaml:"formatOverride" mapstructure:"format_override"` + // Enabled signifies whether a bidder is enabled/disabled for user sync Enabled *bool `yaml:"enabled" mapstructure:"enabled"` @@ -206,6 +209,11 @@ type InfoReaderFromDisk struct { Path string } +const ( + SyncResponseFormatIFrame = "b" // b = blank HTML response + SyncResponseFormatRedirect = "i" // i = image response +) + func (r InfoReaderFromDisk) Read() (map[string][]byte, error) { bidderConfigs, err := os.ReadDir(r.Path) if err != nil { @@ -562,6 +570,10 @@ func validateSyncer(bidderInfo BidderInfo) error { return nil } + if bidderInfo.Syncer.FormatOverride != SyncResponseFormatIFrame && bidderInfo.Syncer.FormatOverride != SyncResponseFormatRedirect && bidderInfo.Syncer.FormatOverride != "" { + return fmt.Errorf("syncer could not be created, invalid format override value: %s", bidderInfo.Syncer.FormatOverride) + } + for _, supports := range bidderInfo.Syncer.Supports { if !strings.EqualFold(supports, "iframe") && !strings.EqualFold(supports, "redirect") { return fmt.Errorf("syncer could not be created, invalid supported endpoint: %s", supports) diff --git a/config/bidderinfo_test.go b/config/bidderinfo_test.go index ee1b35d4994..3305e34e88a 100644 --- a/config/bidderinfo_test.go +++ b/config/bidderinfo_test.go @@ -593,6 +593,7 @@ func TestBidderInfoValidationPositive(t *testing.T) { URL: "http://bidderB.com/usersync", UserMacro: "UID", }, + FormatOverride: SyncResponseFormatRedirect, }, }, "bidderC": BidderInfo{ @@ -627,6 +628,9 @@ func TestBidderInfoValidationPositive(t *testing.T) { }, }, }, + Syncer: &Syncer{ + FormatOverride: SyncResponseFormatIFrame, + }, }, } errs := bidderInfos.validate(make([]error, 0)) @@ -1318,6 +1322,37 @@ func TestBidderInfoValidationNegative(t *testing.T) { errors.New("parent bidder: bidderC not found for an alias: bidderB"), }, }, + { + "Invalid format override value", + BidderInfos{ + "bidderB": BidderInfo{ + Endpoint: "http://bidderA.com/openrtb2", + Maintainer: &MaintainerInfo{ + Email: "maintainer@bidderA.com", + }, + Capabilities: &CapabilitiesInfo{ + App: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{ + openrtb_ext.BidTypeBanner, + openrtb_ext.BidTypeNative, + }, + }, + Site: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{ + openrtb_ext.BidTypeBanner, + openrtb_ext.BidTypeNative, + }, + }, + }, + Syncer: &Syncer{ + FormatOverride: "x", + }, + }, + }, + []error{ + errors.New("syncer could not be created, invalid format override value: x"), + }, + }, } for _, test := range testCases { diff --git a/endpoints/cookie_sync_test.go b/endpoints/cookie_sync_test.go index 401c6796237..adfdcb22fab 100644 --- a/endpoints/cookie_sync_test.go +++ b/endpoints/cookie_sync_test.go @@ -2094,7 +2094,7 @@ func (m *MockSyncer) Key() string { return args.String(0) } -func (m *MockSyncer) DefaultSyncType() usersync.SyncType { +func (m *MockSyncer) DefaultResponseFormat() usersync.SyncType { args := m.Called() return args.Get(0).(usersync.SyncType) } diff --git a/endpoints/openrtb2/sample-requests/hooks/auction_bidder_reject.json b/endpoints/openrtb2/sample-requests/hooks/auction_bidder_reject.json index 94769e4f6cd..0bc86e4c4a5 100644 --- a/endpoints/openrtb2/sample-requests/hooks/auction_bidder_reject.json +++ b/endpoints/openrtb2/sample-requests/hooks/auction_bidder_reject.json @@ -32,7 +32,7 @@ } } ], - "tmax": 50, + "tmax": 500, "test": 1, "ext": { "prebid": { diff --git a/endpoints/openrtb2/sample-requests/hooks/auction_bidder_response_reject.json b/endpoints/openrtb2/sample-requests/hooks/auction_bidder_response_reject.json index 6198e3e23bc..16a7f43c87a 100644 --- a/endpoints/openrtb2/sample-requests/hooks/auction_bidder_response_reject.json +++ b/endpoints/openrtb2/sample-requests/hooks/auction_bidder_response_reject.json @@ -32,7 +32,7 @@ } } ], - "tmax": 50, + "tmax": 500, "test": 1, "ext": { "prebid": { diff --git a/endpoints/openrtb2/sample-requests/hooks/auction_entrypoint_reject.json b/endpoints/openrtb2/sample-requests/hooks/auction_entrypoint_reject.json index c67b8d4b490..3481b986bc3 100644 --- a/endpoints/openrtb2/sample-requests/hooks/auction_entrypoint_reject.json +++ b/endpoints/openrtb2/sample-requests/hooks/auction_entrypoint_reject.json @@ -28,7 +28,7 @@ } } ], - "tmax": 50, + "tmax": 500, "ext": { "prebid": { "trace": "verbose" diff --git a/endpoints/openrtb2/sample-requests/hooks/auction_processed_auction_request_reject.json b/endpoints/openrtb2/sample-requests/hooks/auction_processed_auction_request_reject.json index eca136cf75f..4c160dec007 100644 --- a/endpoints/openrtb2/sample-requests/hooks/auction_processed_auction_request_reject.json +++ b/endpoints/openrtb2/sample-requests/hooks/auction_processed_auction_request_reject.json @@ -28,7 +28,7 @@ } } ], - "tmax": 50, + "tmax": 500, "ext": { "prebid": { "trace": "verbose" diff --git a/endpoints/openrtb2/sample-requests/hooks/auction_raw_auction_request_reject.json b/endpoints/openrtb2/sample-requests/hooks/auction_raw_auction_request_reject.json index dc192baffee..ed284e6687d 100644 --- a/endpoints/openrtb2/sample-requests/hooks/auction_raw_auction_request_reject.json +++ b/endpoints/openrtb2/sample-requests/hooks/auction_raw_auction_request_reject.json @@ -28,7 +28,7 @@ } } ], - "tmax": 50, + "tmax": 500, "ext": { "prebid": { "trace": "verbose" diff --git a/endpoints/openrtb2/test_utils.go b/endpoints/openrtb2/test_utils.go index e3e7803e551..a0ac836e30e 100644 --- a/endpoints/openrtb2/test_utils.go +++ b/endpoints/openrtb2/test_utils.go @@ -1579,7 +1579,7 @@ var entryPointHookUpdate = hooks.HookWrapper[hookstage.Entrypoint]{ ch := hookstage.ChangeSet[hookstage.EntrypointPayload]{} ch.AddMutation(func(payload hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) { - body, err := jsonpatch.MergePatch(payload.Body, []byte(`{"tmax":50}`)) + body, err := jsonpatch.MergePatch(payload.Body, []byte(`{"tmax":600}`)) if err == nil { payload.Body = body } diff --git a/endpoints/setuid.go b/endpoints/setuid.go index aae31f10e2e..0f4d36d35ac 100644 --- a/endpoints/setuid.go +++ b/endpoints/setuid.go @@ -362,7 +362,7 @@ func getResponseFormat(query url.Values, syncer usersync.Syncer) (string, error) formatEmpty := len(format) == 0 || format[0] == "" if !formatProvided || formatEmpty { - switch syncer.DefaultSyncType() { + switch syncer.DefaultResponseFormat() { case usersync.SyncTypeIFrame: return "b", nil case usersync.SyncTypeRedirect: diff --git a/endpoints/setuid_test.go b/endpoints/setuid_test.go index 145be3d3d13..ded528abeb3 100644 --- a/endpoints/setuid_test.go +++ b/endpoints/setuid_test.go @@ -34,6 +34,7 @@ func TestSetUIDEndpoint(t *testing.T) { gdprAllowsHostCookies bool gdprReturnsError bool gdprMalformed bool + formatOverride string expectedSyncs map[string]string expectedBody string expectedStatusCode int @@ -346,6 +347,17 @@ func TestSetUIDEndpoint(t *testing.T) { expectedStatusCode: http.StatusBadRequest, expectedBody: "invalid gpp_sid encoding, must be a csv list of integers", }, + { + uri: "/setuid?bidder=pubmatic&uid=123", + syncersBidderNameToKey: map[string]string{"pubmatic": "pubmatic"}, + existingSyncs: nil, + gdprAllowsHostCookies: true, + formatOverride: "i", + expectedSyncs: map[string]string{"pubmatic": "123"}, + expectedStatusCode: http.StatusOK, + expectedHeaders: map[string]string{"Content-Length": "86", "Content-Type": "image/png"}, + description: "Format not provided in URL, but formatOverride is defined", + }, } analytics := analyticsBuild.New(&config.Analytics{}) @@ -353,7 +365,7 @@ func TestSetUIDEndpoint(t *testing.T) { for _, test := range testCases { response := doRequest(makeRequest(test.uri, test.existingSyncs), analytics, metrics, - test.syncersBidderNameToKey, test.gdprAllowsHostCookies, test.gdprReturnsError, test.gdprMalformed, false, 0, nil) + test.syncersBidderNameToKey, test.gdprAllowsHostCookies, test.gdprReturnsError, test.gdprMalformed, false, 0, nil, test.formatOverride) assert.Equal(t, test.expectedStatusCode, response.Code, "Test Case: %s. /setuid returned unexpected error code", test.description) if test.expectedSyncs != nil { @@ -477,7 +489,7 @@ func TestSetUIDPriorityEjection(t *testing.T) { request.AddCookie(httpCookie) // Make Request to /setuid - response := doRequest(request, analytics, &metricsConf.NilMetricsEngine{}, syncersByBidder, true, false, false, false, test.givenMaxCookieSize, test.givenPriorityGroups) + response := doRequest(request, analytics, &metricsConf.NilMetricsEngine{}, syncersByBidder, true, false, false, false, test.givenMaxCookieSize, test.givenPriorityGroups, "") if test.expectedWarning != "" { assert.Equal(t, test.expectedWarning, response.Body.String(), test.description) @@ -1343,7 +1355,7 @@ func TestSetUIDEndpointMetrics(t *testing.T) { for _, v := range test.cookies { addCookie(req, v) } - response := doRequest(req, analyticsEngine, metricsEngine, test.syncersBidderNameToKey, test.gdprAllowsHostCookies, false, false, test.cfgAccountRequired, 0, nil) + response := doRequest(req, analyticsEngine, metricsEngine, test.syncersBidderNameToKey, test.gdprAllowsHostCookies, false, false, test.cfgAccountRequired, 0, nil, "") assert.Equal(t, test.expectedResponseCode, response.Code, test.description) analyticsEngine.AssertExpectations(t) @@ -1359,7 +1371,7 @@ func TestOptedOut(t *testing.T) { syncersBidderNameToKey := map[string]string{"pubmatic": "pubmatic"} analytics := analyticsBuild.New(&config.Analytics{}) metrics := &metricsConf.NilMetricsEngine{} - response := doRequest(request, analytics, metrics, syncersBidderNameToKey, true, false, false, false, 0, nil) + response := doRequest(request, analytics, metrics, syncersBidderNameToKey, true, false, false, false, 0, nil, "") assert.Equal(t, http.StatusUnauthorized, response.Code) } @@ -1455,6 +1467,30 @@ func TestGetResponseFormat(t *testing.T) { expectedFormat: "i", description: "parameter given is empty (by empty item), use default sync type redirect", }, + { + urlValues: url.Values{"f": []string{""}}, + syncer: fakeSyncer{key: "a", defaultSyncType: usersync.SyncTypeRedirect}, + expectedFormat: "i", + description: "parameter given is empty (by empty item), use default sync type redirect", + }, + { + urlValues: url.Values{"f": []string{}}, + syncer: fakeSyncer{key: "a", formatOverride: "i"}, + expectedFormat: "i", + description: "format not provided, but formatOverride is defined, expect i", + }, + { + urlValues: url.Values{"f": []string{}}, + syncer: fakeSyncer{key: "a", formatOverride: "b"}, + expectedFormat: "b", + description: "format not provided, but formatOverride is defined, expect b", + }, + { + urlValues: url.Values{"f": []string{}}, + syncer: fakeSyncer{key: "a", formatOverride: "b", defaultSyncType: usersync.SyncTypeRedirect}, + expectedFormat: "b", + description: "format not provided, default is defined but formatOverride is defined as well, expect b", + }, } for _, test := range testCases { @@ -1554,7 +1590,7 @@ func makeRequest(uri string, existingSyncs map[string]string) *http.Request { return request } -func doRequest(req *http.Request, analytics analytics.Runner, metrics metrics.MetricsEngine, syncersBidderNameToKey map[string]string, gdprAllowsHostCookies, gdprReturnsError, gdprReturnsMalformedError, cfgAccountRequired bool, maxCookieSize int, priorityGroups [][]string) *httptest.ResponseRecorder { +func doRequest(req *http.Request, analytics analytics.Runner, metrics metrics.MetricsEngine, syncersBidderNameToKey map[string]string, gdprAllowsHostCookies, gdprReturnsError, gdprReturnsMalformedError, cfgAccountRequired bool, maxCookieSize int, priorityGroups [][]string, formatOverride string) *httptest.ResponseRecorder { cfg := config.Configuration{ AccountRequired: cfgAccountRequired, AccountDefaults: config.Account{}, @@ -1585,7 +1621,7 @@ func doRequest(req *http.Request, analytics analytics.Runner, metrics metrics.Me syncersByBidder := make(map[string]usersync.Syncer) for bidderName, syncerKey := range syncersBidderNameToKey { - syncersByBidder[bidderName] = fakeSyncer{key: syncerKey, defaultSyncType: usersync.SyncTypeIFrame} + syncersByBidder[bidderName] = fakeSyncer{key: syncerKey, defaultSyncType: usersync.SyncTypeIFrame, formatOverride: formatOverride} if priorityGroups == nil { cfg.UserSync.PriorityGroups = [][]string{{}} cfg.UserSync.PriorityGroups[0] = append(cfg.UserSync.PriorityGroups[0], bidderName) @@ -1676,14 +1712,22 @@ func (g *fakePermsSetUID) AuctionActivitiesAllowed(ctx context.Context, bidderCo type fakeSyncer struct { key string defaultSyncType usersync.SyncType + formatOverride string } func (s fakeSyncer) Key() string { return s.key } -func (s fakeSyncer) DefaultSyncType() usersync.SyncType { - return s.defaultSyncType +func (s fakeSyncer) DefaultResponseFormat() usersync.SyncType { + switch s.formatOverride { + case "b": + return usersync.SyncTypeIFrame + case "i": + return usersync.SyncTypeRedirect + default: + return s.defaultSyncType + } } func (s fakeSyncer) SupportsType(syncTypes []usersync.SyncType) bool { diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index 5de2d78362e..0e85a39a314 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -161,6 +161,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters/smilewanted" "github.com/prebid/prebid-server/v2/adapters/sonobi" "github.com/prebid/prebid-server/v2/adapters/sovrn" + "github.com/prebid/prebid-server/v2/adapters/sovrnXsp" "github.com/prebid/prebid-server/v2/adapters/sspBC" "github.com/prebid/prebid-server/v2/adapters/stroeerCore" "github.com/prebid/prebid-server/v2/adapters/taboola" @@ -359,6 +360,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderSmileWanted: smilewanted.Builder, openrtb_ext.BidderSonobi: sonobi.Builder, openrtb_ext.BidderSovrn: sovrn.Builder, + openrtb_ext.BidderSovrnXsp: sovrnXsp.Builder, openrtb_ext.BidderSspBC: sspBC.Builder, openrtb_ext.BidderStroeerCore: stroeerCore.Builder, openrtb_ext.BidderTaboola: taboola.Builder, diff --git a/go.mod b/go.mod index ac394a6742c..9a55cddb00a 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 github.com/yudai/gojsondiff v1.0.0 golang.org/x/net v0.17.0 - golang.org/x/text v0.13.0 + golang.org/x/text v0.14.0 google.golang.org/grpc v1.56.3 gopkg.in/evanphx/json-patch.v4 v4.12.0 gopkg.in/yaml.v3 v3.0.1 @@ -70,8 +70,8 @@ require ( github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yudai/pp v2.0.1+incompatible // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/sys v0.13.0 // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/sys v0.15.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.66.4 // indirect diff --git a/go.sum b/go.sum index 6331beb3287..ad2d5ba94b8 100644 --- a/go.sum +++ b/go.sum @@ -530,8 +530,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -728,8 +728,8 @@ golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -742,8 +742,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index cc4e095a93e..4f5aaebab94 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -179,6 +179,7 @@ var coreBidderNames []BidderName = []BidderName{ BidderSmileWanted, BidderSonobi, BidderSovrn, + BidderSovrnXsp, BidderSspBC, BidderStroeerCore, BidderTaboola, @@ -457,6 +458,7 @@ const ( BidderSmileWanted BidderName = "smilewanted" BidderSonobi BidderName = "sonobi" BidderSovrn BidderName = "sovrn" + BidderSovrnXsp BidderName = "sovrnXsp" BidderSspBC BidderName = "sspBC" BidderStroeerCore BidderName = "stroeerCore" BidderTaboola BidderName = "taboola" diff --git a/openrtb_ext/imp_consumable.go b/openrtb_ext/imp_consumable.go index fe916b09972..8158b41d2cc 100644 --- a/openrtb_ext/imp_consumable.go +++ b/openrtb_ext/imp_consumable.go @@ -6,5 +6,6 @@ type ExtImpConsumable struct { SiteId int `json:"siteId,omitempty"` UnitId int `json:"unitId,omitempty"` /* UnitName gets used as a classname and in the URL when building the ad markup */ - UnitName string `json:"unitName,omitempty"` + UnitName string `json:"unitName,omitempty"` + PlacementId string `json:"placementid,omitempty"` } diff --git a/openrtb_ext/imp_sovrnXsp.go b/openrtb_ext/imp_sovrnXsp.go new file mode 100644 index 00000000000..90c78d707e4 --- /dev/null +++ b/openrtb_ext/imp_sovrnXsp.go @@ -0,0 +1,8 @@ +package openrtb_ext + +type ExtImpSovrnXsp struct { + PubID string `json:"pub_id,omitempty"` + MedID string `json:"med_id,omitempty"` + ZoneID string `json:"zone_id,omitempty"` + ForceBid bool `json:"force_bid,omitempty"` +} diff --git a/static/bidder-info/33across.yaml b/static/bidder-info/33across.yaml index 902db6b362b..cbbdedb2193 100644 --- a/static/bidder-info/33across.yaml +++ b/static/bidder-info/33across.yaml @@ -1,4 +1,7 @@ endpoint: "https://ssc.33across.com/api/v1/s2s" +# This bidder does not operate globally. Please consider setting "disabled: true" in European datacenters. +geoscope: + - "!EEA" maintainer: email: "headerbidding@33across.com" gvlVendorID: 58 @@ -10,4 +13,4 @@ capabilities: userSync: iframe: url: "https://ssc-cms.33across.com/ps/?m=xch&rt=html&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&ru={{.RedirectURL}}&id=zzz000000000002zzz" - userMacro: "33XUSERID33X" \ No newline at end of file + userMacro: "33XUSERID33X" diff --git a/static/bidder-info/consumable.yaml b/static/bidder-info/consumable.yaml index cc290149be2..0f240e87942 100644 --- a/static/bidder-info/consumable.yaml +++ b/static/bidder-info/consumable.yaml @@ -2,10 +2,13 @@ endpoint: "https://e.serverbid.com/api/v2" maintainer: email: "prebid@consumable.com" gvlVendorID: 591 +endpointCompression: gzip capabilities: app: mediaTypes: - banner + - video + - audio site: mediaTypes: - banner diff --git a/static/bidder-info/dxkulture.yaml b/static/bidder-info/dxkulture.yaml index 1af72e9fc33..d6f03044fda 100644 --- a/static/bidder-info/dxkulture.yaml +++ b/static/bidder-info/dxkulture.yaml @@ -1,6 +1,6 @@ -endpoint: "https://ads.kulture.media/pbs" +endpoint: "https://ads.dxkulture.com/pbs" maintainer: - email: "devops@kulture.media" + email: "devops@dxkulture.com" capabilities: app: mediaTypes: @@ -12,5 +12,5 @@ capabilities: - video userSync: redirect: - url: "https://ads.kulture.media/usync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb={{.RedirectURL}}" + url: "https://ads.dxkulture.com/usync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb={{.RedirectURL}}" userMacro: "$UID" diff --git a/static/bidder-info/imds.yaml b/static/bidder-info/imds.yaml index 491a5bd0ac6..135b67fc1f9 100644 --- a/static/bidder-info/imds.yaml +++ b/static/bidder-info/imds.yaml @@ -1,4 +1,8 @@ endpoint: "https://pbs.technoratimedia.com/openrtb/bids/{{.AccountID}}?src={{.SourceId}}&adapter=imds" +# This bidder does not operate globally. Please consider setting "disabled: true" outside of the following regions: +geoscope: + - USA + - CAN maintainer: email: "eng-demand@imds.tv" capabilities: diff --git a/static/bidder-info/iqx.yaml b/static/bidder-info/iqx.yaml index ab10ad96289..3569c3accf8 100644 --- a/static/bidder-info/iqx.yaml +++ b/static/bidder-info/iqx.yaml @@ -1,6 +1,6 @@ endpoint: "http://rtb.iqzone.com?pid={{.SourceId}}&host={{.Host}}&pbs=1" maintainer: - email: "it@iqzone.com" + email: "adops@iqzone.com" capabilities: app: mediaTypes: @@ -16,4 +16,4 @@ userSync: # IQX 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 \ No newline at end of file + - redirect diff --git a/static/bidder-info/iqzone.yaml b/static/bidder-info/iqzone.yaml index 3465cfabcb0..620ea01e43c 100644 --- a/static/bidder-info/iqzone.yaml +++ b/static/bidder-info/iqzone.yaml @@ -1,6 +1,6 @@ endpoint: "http://smartssp-us-east.iqzone.com/pserver" maintainer: - email: "smartssp@iqzone.com" + email: "adops@iqzone.com" capabilities: site: mediaTypes: diff --git a/static/bidder-info/lockerdome.yaml b/static/bidder-info/lockerdome.yaml index cfefb2f995b..530c54eaaff 100644 --- a/static/bidder-info/lockerdome.yaml +++ b/static/bidder-info/lockerdome.yaml @@ -1,4 +1,7 @@ endpoint: "https://lockerdome.com/ladbid/prebidserver/openrtb2" +# This bidder does not operate globally. Please consider setting "disabled: true" outside of the following regions: +geoscope: + - USA maintainer: email: "bidding@lockerdome.com" capabilities: diff --git a/static/bidder-info/lunamedia.yaml b/static/bidder-info/lunamedia.yaml index 4064a566040..6f450382c0e 100644 --- a/static/bidder-info/lunamedia.yaml +++ b/static/bidder-info/lunamedia.yaml @@ -1,4 +1,6 @@ endpoint: "http://rtb.lunamedia.live/?pid={{.PublisherID}}" +geoscope: + - USA maintainer: email: "cs@lunamedia.io" capabilities: diff --git a/static/bidder-info/magnite.yaml b/static/bidder-info/magnite.yaml new file mode 100644 index 00000000000..109c20d03bf --- /dev/null +++ b/static/bidder-info/magnite.yaml @@ -0,0 +1 @@ +aliasOf: "rubicon" \ No newline at end of file diff --git a/static/bidder-info/mobilefuse.yaml b/static/bidder-info/mobilefuse.yaml index e1474f775fc..1d6b323c3a6 100644 --- a/static/bidder-info/mobilefuse.yaml +++ b/static/bidder-info/mobilefuse.yaml @@ -1,4 +1,8 @@ endpoint: "http://mfx.mobilefuse.com/openrtb?pub_id={{.PublisherID}}" +# This bidder does not operate globally. Please consider setting "disabled: true" outside of the following regions: +geoscope: + - USA + - CAN maintainer: email: prebid@mobilefuse.com gvlVendorID: 909 @@ -8,4 +12,4 @@ capabilities: - banner - video - native -endpointCompression: "GZIP" \ No newline at end of file +endpointCompression: "GZIP" diff --git a/static/bidder-info/rise.yaml b/static/bidder-info/rise.yaml index d429e8780a7..72e56c334c8 100644 --- a/static/bidder-info/rise.yaml +++ b/static/bidder-info/rise.yaml @@ -2,7 +2,7 @@ endpoint: "https://pbs.yellowblue.io/pbs" maintainer: email: rise-prog-dev@risecodes.com gvlVendorID: 1043 -modifyingVastXmlAllowed: false +modifyingVastXmlAllowed: true capabilities: app: mediaTypes: diff --git a/static/bidder-info/rubicon.yaml b/static/bidder-info/rubicon.yaml index b3de838c9fd..c3943058511 100644 --- a/static/bidder-info/rubicon.yaml +++ b/static/bidder-info/rubicon.yaml @@ -1,5 +1,15 @@ -endpoint: "http://exapi-us-east.rubiconproject.com/a/api/exchange.json" +# Contact global-support@magnite.com to ask about enabling a connection to the Magnite (formerly Rubicon) exchange. +# We have the following regional endpoint domains: exapi-us-east, exapi-us-west, exapi-apac, exapi-eu +# Please deploy this config in each of your datacenters with the appropriate regional subdomain +endpoint: "https://REGION.rubiconproject.com/a/api/exchange" +endpointCompression: GZIP +geoscope: + - global disabled: true +xapi: + username: GET_FROM_MAGNITE + password: GET_FROM_MAGNITE + tracker: SAME_AS_USERNAME maintainer: email: "header-bidding@rubiconproject.com" gvlVendorID: 52 @@ -15,7 +25,6 @@ capabilities: - video - native userSync: - # rubicon 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. + # rubicon supports user syncing, but requires configuration. Please contact global-support@magnite.com. supports: - redirect diff --git a/static/bidder-info/smaato.yaml b/static/bidder-info/smaato.yaml index 59a734c90fd..2b1b5c3fe17 100644 --- a/static/bidder-info/smaato.yaml +++ b/static/bidder-info/smaato.yaml @@ -15,6 +15,8 @@ capabilities: - video - native userSync: + # This bidder does not sync when GDPR is in-scope. Please consider removing the usersync + # block when deploying to European datacenters redirect: url: "https://s.ad.smaato.net/c/?adExInit=p&redir={{.RedirectURL}}&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" userMacro: "$UID" diff --git a/static/bidder-info/smartyads.yaml b/static/bidder-info/smartyads.yaml index b36983bc7b1..21b8a0a11d6 100644 --- a/static/bidder-info/smartyads.yaml +++ b/static/bidder-info/smartyads.yaml @@ -1,6 +1,7 @@ endpoint: "http://{{.Host}}.smartyads.com/bid?rtb_seat_id={{.SourceId}}&secret_key={{.AccountID}}" maintainer: email: "support@smartyads.com" +gvlVendorID: 534 capabilities: app: mediaTypes: diff --git a/static/bidder-info/sovrnXsp.yaml b/static/bidder-info/sovrnXsp.yaml new file mode 100644 index 00000000000..3cce11a551c --- /dev/null +++ b/static/bidder-info/sovrnXsp.yaml @@ -0,0 +1,12 @@ +endpoint: "http://xsp.lijit.com/json/rtb/prebid/server" +maintainer: + email: "sovrnoss@sovrn.com" +endpointCompression: gzip +gvlVendorID: 13 +modifyingVastXmlAllowed: true +capabilities: + app: + mediaTypes: + - banner + - video + - native diff --git a/static/bidder-info/stroeerCore.yaml b/static/bidder-info/stroeerCore.yaml index 32c78590bb8..9c0904508ac 100644 --- a/static/bidder-info/stroeerCore.yaml +++ b/static/bidder-info/stroeerCore.yaml @@ -7,9 +7,11 @@ capabilities: app: mediaTypes: - banner + - video site: mediaTypes: - banner + - video userSync: # for both user syncs, stroeerCore appends the user id to end of the redirect url and does not utilize a macro iframe: diff --git a/static/bidder-info/teads.yaml b/static/bidder-info/teads.yaml index 47686977673..307b631efb4 100644 --- a/static/bidder-info/teads.yaml +++ b/static/bidder-info/teads.yaml @@ -1,6 +1,6 @@ endpoint: "https://psrv.teads.tv/prebid-server/bid-request" maintainer: - email: "support-sdk@teads.com" + email: "innov-ssp@teads.tv" gvlVendorID: 132 capabilities: app: diff --git a/static/bidder-params/consumable.json b/static/bidder-params/consumable.json index b1db53568b9..7709ab09d37 100644 --- a/static/bidder-params/consumable.json +++ b/static/bidder-params/consumable.json @@ -24,7 +24,15 @@ "type": "string", "description": "The unit name from Consumable (expected to be a valid CSS class name)", "pattern": "^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$" + }, + "placementId": { + "type": "string", + "description": "The placementID from Consumable, Required for non-site requests", + "pattern": "^[a-zA-Z0-9]+$" } }, - "required": ["siteId", "networkId","unitId"] + "oneOf": [ + {"required": ["siteId", "networkId","unitId"] }, + {"required": ["placementId"] } + ] } diff --git a/static/bidder-params/sovrnXsp.json b/static/bidder-params/sovrnXsp.json new file mode 100644 index 00000000000..beea3f588df --- /dev/null +++ b/static/bidder-params/sovrnXsp.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Sovrn XSP Adapter Params", + "description": "Schema validating params accepted by the Sovrn XSP adapter", + "type": "object", + "properties": { + "pub_id": { + "type": "string", + "description": "Assigned publisher ID", + "minLength": 4 + }, + "med_id": { + "type": "string", + "description": "Property ID not zone ID not provided" + }, + "zone_id": { + "type": "string", + "description": "Specific zone ID for this placement, belonging to app/site", + "minLength": 20 + }, + "force_bid": { + "type": "boolean", + "description": "Force bids with a test creative" + } + }, + "required": [ "pub_id" ] + } diff --git a/usersync/chooser_test.go b/usersync/chooser_test.go index 9bc06100e81..f48dbeff9f1 100644 --- a/usersync/chooser_test.go +++ b/usersync/chooser_test.go @@ -720,13 +720,14 @@ type fakeSyncer struct { key string supportsIFrame bool supportsRedirect bool + formatOverride string } func (s fakeSyncer) Key() string { return s.key } -func (s fakeSyncer) DefaultSyncType() SyncType { +func (s fakeSyncer) DefaultResponseFormat() SyncType { return SyncTypeIFrame } diff --git a/usersync/syncer.go b/usersync/syncer.go index 3add47e5873..50985eca5be 100644 --- a/usersync/syncer.go +++ b/usersync/syncer.go @@ -26,8 +26,8 @@ type Syncer interface { // necessarily, a one-to-one mapping with a bidder. Key() string - // DefaultSyncType is the default SyncType for this syncer. - DefaultSyncType() SyncType + // DefaultResponseFormat is the default SyncType for this syncer. + DefaultResponseFormat() SyncType // SupportsType returns true if the syncer supports at least one of the specified sync types. SupportsType(syncTypes []SyncType) bool @@ -50,13 +50,9 @@ type standardSyncer struct { iframe *template.Template redirect *template.Template supportCORS bool + formatOverride string } -const ( - setuidSyncTypeIFrame = "b" // b = blank HTML response - setuidSyncTypeRedirect = "i" // i = image response -) - // NewSyncer creates a new Syncer from the provided configuration, or return an error if macro substition // fails or an endpoint url is invalid. func NewSyncer(hostConfig config.UserSync, syncerConfig config.Syncer, bidder string) (Syncer, error) { @@ -72,11 +68,12 @@ func NewSyncer(hostConfig config.UserSync, syncerConfig config.Syncer, bidder st key: syncerConfig.Key, defaultSyncType: resolveDefaultSyncType(syncerConfig), supportCORS: syncerConfig.SupportCORS != nil && *syncerConfig.SupportCORS, + formatOverride: syncerConfig.FormatOverride, } if syncerConfig.IFrame != nil { var err error - syncer.iframe, err = buildTemplate(bidder, setuidSyncTypeIFrame, hostConfig, syncerConfig.ExternalURL, *syncerConfig.IFrame) + syncer.iframe, err = buildTemplate(bidder, config.SyncResponseFormatIFrame, hostConfig, syncerConfig.ExternalURL, *syncerConfig.IFrame, syncerConfig.FormatOverride) if err != nil { return nil, fmt.Errorf("iframe %v", err) } @@ -87,7 +84,7 @@ func NewSyncer(hostConfig config.UserSync, syncerConfig config.Syncer, bidder st if syncerConfig.Redirect != nil { var err error - syncer.redirect, err = buildTemplate(bidder, setuidSyncTypeRedirect, hostConfig, syncerConfig.ExternalURL, *syncerConfig.Redirect) + syncer.redirect, err = buildTemplate(bidder, config.SyncResponseFormatRedirect, hostConfig, syncerConfig.ExternalURL, *syncerConfig.Redirect, syncerConfig.FormatOverride) if err != nil { return nil, fmt.Errorf("redirect %v", err) } @@ -117,12 +114,16 @@ var ( macroRegex = regexp.MustCompile(`{{\s*\..*?\s*}}`) ) -func buildTemplate(bidderName, syncTypeValue string, hostConfig config.UserSync, syncerExternalURL string, syncerEndpoint config.SyncerEndpoint) (*template.Template, error) { +func buildTemplate(bidderName, syncTypeValue string, hostConfig config.UserSync, syncerExternalURL string, syncerEndpoint config.SyncerEndpoint, formatOverride string) (*template.Template, error) { redirectTemplate := syncerEndpoint.RedirectURL if redirectTemplate == "" { redirectTemplate = hostConfig.RedirectURL } + if formatOverride != "" { + syncTypeValue = formatOverride + } + externalURL := chooseExternalURL(syncerEndpoint.ExternalURL, syncerExternalURL, hostConfig.ExternalURL) redirectURL := macroRegexSyncerKey.ReplaceAllLiteralString(redirectTemplate, bidderName) @@ -189,8 +190,15 @@ func (s standardSyncer) Key() string { return s.key } -func (s standardSyncer) DefaultSyncType() SyncType { - return s.defaultSyncType +func (s standardSyncer) DefaultResponseFormat() SyncType { + switch s.formatOverride { + case config.SyncResponseFormatIFrame: + return SyncTypeIFrame + case config.SyncResponseFormatRedirect: + return SyncTypeRedirect + default: + return s.defaultSyncType + } } func (s standardSyncer) SupportsType(syncTypes []SyncType) bool { diff --git a/usersync/syncer_test.go b/usersync/syncer_test.go index 6aa3103211e..c9c568e299a 100644 --- a/usersync/syncer_test.go +++ b/usersync/syncer_test.go @@ -27,6 +27,7 @@ func TestNewSyncer(t *testing.T) { givenIFrameConfig *config.SyncerEndpoint givenRedirectConfig *config.SyncerEndpoint givenExternalURL string + givenForceType string expectedError string expectedDefault SyncType expectedIFrame string @@ -322,7 +323,7 @@ func TestBuildTemplate(t *testing.T) { } for _, test := range testCases { - result, err := buildTemplate(key, syncTypeValue, hostConfig, test.givenSyncerExternalURL, test.givenSyncerEndpoint) + result, err := buildTemplate(key, syncTypeValue, hostConfig, test.givenSyncerExternalURL, test.givenSyncerEndpoint, "") if test.expectedError == "" { assert.NoError(t, err, test.description+":err") @@ -480,7 +481,36 @@ func TestSyncerKey(t *testing.T) { func TestSyncerDefaultSyncType(t *testing.T) { syncer := standardSyncer{defaultSyncType: SyncTypeRedirect} - assert.Equal(t, SyncTypeRedirect, syncer.DefaultSyncType()) + assert.Equal(t, SyncTypeRedirect, syncer.DefaultResponseFormat()) +} + +func TestSyncerDefaultResponseFormat(t *testing.T) { + testCases := []struct { + description string + givenSyncer standardSyncer + expectedSyncType SyncType + }{ + { + description: "IFrame", + givenSyncer: standardSyncer{formatOverride: config.SyncResponseFormatIFrame}, + expectedSyncType: SyncTypeIFrame, + }, + { + description: "Default with Redirect Override", + givenSyncer: standardSyncer{defaultSyncType: SyncTypeIFrame, formatOverride: config.SyncResponseFormatRedirect}, + expectedSyncType: SyncTypeRedirect, + }, + { + description: "Default with no override", + givenSyncer: standardSyncer{defaultSyncType: SyncTypeRedirect}, + expectedSyncType: SyncTypeRedirect, + }, + } + + for _, test := range testCases { + syncType := test.givenSyncer.DefaultResponseFormat() + assert.Equal(t, test.expectedSyncType, syncType, test.description) + } } func TestSyncerSupportsType(t *testing.T) {