diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index f000cbc1625..35b3f7f2711 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -34,6 +34,15 @@ type IxDiag struct { MultipleSiteIds string `json:"multipleSiteIds,omitempty"` } +type auctionConfig struct { + BidId string `json:"bidId,omitempty"` + Config json.RawMessage `json:"config,omitempty"` +} + +type ixRespExt struct { + AuctionConfig []auctionConfig `json:"protectedAudienceAuctionConfigs,omitempty"` +} + func (a *IxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { requests := make([]*adapters.RequestData, 0, len(request.Imp)) errs := make([]error, 0) @@ -273,6 +282,26 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque } } + if bidResponse.Ext != nil { + var bidRespExt ixRespExt + if err := json.Unmarshal(bidResponse.Ext, &bidRespExt); err != nil { + return nil, append(errs, err) + } + + if bidRespExt.AuctionConfig != nil { + bidderResponse.FledgeAuctionConfigs = make([]*openrtb_ext.FledgeAuctionConfig, 0, len(bidRespExt.AuctionConfig)) + for _, config := range bidRespExt.AuctionConfig { + if config.Config != nil { + fledgeAuctionConfig := &openrtb_ext.FledgeAuctionConfig{ + ImpId: config.BidId, + Config: config.Config, + } + bidderResponse.FledgeAuctionConfigs = append(bidderResponse.FledgeAuctionConfigs, fledgeAuctionConfig) + } + } + } + } + return bidderResponse, errs } diff --git a/adapters/ix/ix_test.go b/adapters/ix/ix_test.go index e2651ca523e..5e2450e7ded 100644 --- a/adapters/ix/ix_test.go +++ b/adapters/ix/ix_test.go @@ -274,3 +274,109 @@ func TestMakeRequestsErrIxDiag(t *testing.T) { _, errs := bidder.MakeRequests(req, nil) assert.Len(t, errs, 1) } + +func TestPABidResponse(t *testing.T) { + bidder := &IxAdapter{} + + mockedReq := &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ + ID: "1_1", + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{W: 300, H: 250}}, + }, + Ext: json.RawMessage( + `{ + "ae": 1, + "bidder": { + "siteID": "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", + Ext: json.RawMessage( + `{ + "prebid": { + "video": { + "duration": 60, + "primary_category": "IAB18-1" + } + } + }`, + ), + }}, + }}, + } + + testCases := []struct { + name string + ext json.RawMessage + expectedLen int + }{ + { + name: "properly formatted", + ext: json.RawMessage( + `{ + "protectedAudienceAuctionConfigs": [{ + "bidId": "test-imp-id", + "config": { + "seller": "https://seller.com", + "decisionLogicUrl": "https://ssp.com/decision-logic.js", + "interestGroupBuyers": [ + "https://buyer.com" + ], + "sellerSignals": { + "callbackUrl": "https://callbackurl.com" + }, + "perBuyerSignals": { + "https://buyer.com": [] + } + } + }] + }`, + ), + expectedLen: 1, + }, + { + name: "no protected audience auction configs returned", + ext: json.RawMessage(`{}`), + expectedLen: 0, + }, + { + name: "no config", + ext: json.RawMessage( + `{ + "protectedAudienceAuctionConfigs": [{ + "bidId": "test-imp-id" + }] + }`, + ), + expectedLen: 0, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + mockedBidResponse.Ext = tc.ext + body, _ := json.Marshal(mockedBidResponse) + mockedRes := &adapters.ResponseData{ + StatusCode: 200, + Body: body, + } + bidResponse, errors := bidder.MakeBids(mockedReq, mockedExtReq, mockedRes) + + assert.Nil(t, errors) + assert.Len(t, bidResponse.FledgeAuctionConfigs, tc.expectedLen) + }) + } +} diff --git a/adapters/ix/ixtest/exemplary/fledge.json b/adapters/ix/ixtest/exemplary/fledge.json new file mode 100644 index 00000000000..919c7076556 --- /dev/null +++ b/adapters/ix/ixtest/exemplary/fledge.json @@ -0,0 +1,171 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + }, + { + "w": 600, + "h": 800 + } + ] + }, + "ext": { + "bidder": { + "siteId": "569749" + }, + "ae": 1 + } + } + ], + "site": { + "page": "https://www.example.com/" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://host/endpoint", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + }, + { + "w": 600, + "h": 800 + } + ] + }, + "ext": { + "bidder": { + "siteId": "569749" + }, + "ae": 1 + } + } + ], + "site": { + "page": "https://www.example.com/", + "publisher": { + "id": "569749" + } + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "some-test-ad", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "h": 250, + "w": 300, + "ext": { + "ix": {} + } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD", + "ext": { + "protectedAudienceAuctionConfigs": [{ + "bidId": "test-imp-id", + "config": { + "seller": "https://seller.com", + "decisionLogicUrl": "https://ssp.com/decision-logic.js", + "interestGroupBuyers": [ + "https://buyer.com" + ], + "sellerSignals": { + "callbackURL": "https://callbackurl.com" + }, + "perBuyerSignals": { + "https://buyer.com": [] + } + } + }] + } + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "adid": "29681110", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "w": 300, + "h": 250, + "ext": { + "ix": {} + } + }, + "type": "banner" + } + ], + "fledgeauctionconfigs": [{ + "impid": "test-imp-id", + "config": { + "seller": "https://seller.com", + "decisionLogicUrl": "https://ssp.com/decision-logic.js", + "interestGroupBuyers": [ + "https://buyer.com" + ], + "sellerSignals": { + "callbackURL": "https://callbackurl.com" + }, + "perBuyerSignals": { + "https://buyer.com": [] + } + } + }] + } + ] +} diff --git a/adapters/ix/ixtest/supplemental/bad-fledge.json b/adapters/ix/ixtest/supplemental/bad-fledge.json new file mode 100644 index 00000000000..97cc91e4ae6 --- /dev/null +++ b/adapters/ix/ixtest/supplemental/bad-fledge.json @@ -0,0 +1,134 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + }, + { + "w": 600, + "h": 800 + } + ] + }, + "ext": { + "bidder": { + "siteId": "569749" + }, + "ae": 1 + } + } + ], + "site": { + "page": "https://www.example.com/" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://host/endpoint", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + }, + { + "w": 600, + "h": 800 + } + ] + }, + "ext": { + "bidder": { + "siteId": "569749" + }, + "ae": 1 + } + } + ], + "site": { + "page": "https://www.example.com/", + "publisher": { + "id": "569749" + } + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "some-test-ad", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "h": 250, + "w": 300, + "ext": { + "ix": {} + } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD", + "ext": { + "protectedAudienceAuctionConfigs": [{ + "bidId": 123, + "config": { + "seller": "https://seller.com", + "decisionLogicUrl": "https://ssp.com/decision-logic.js", + "interestGroupBuyers": [ + "https://buyer.com" + ], + "sellerSignals": { + "callbackURL": "https://callbackurl.com" + }, + "perBuyerSignals": { + "https://buyer.com": [] + } + } + }] + } + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal number into Go struct field auctionConfig.protectedAudienceAuctionConfigs.bidId of type string", + "comparison": "literal" + } + ] +} diff --git a/adapters/ix/ixtest/supplemental/fledge-no-bid.json b/adapters/ix/ixtest/supplemental/fledge-no-bid.json new file mode 100644 index 00000000000..139dd579ae7 --- /dev/null +++ b/adapters/ix/ixtest/supplemental/fledge-no-bid.json @@ -0,0 +1,137 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + }, + { + "w": 600, + "h": 800 + } + ] + }, + "ext": { + "bidder": { + "siteId": "569749" + }, + "ae": 1 + } + } + ], + "site": { + "page": "https://www.example.com/" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://host/endpoint", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + }, + { + "w": 600, + "h": 800 + } + ] + }, + "ext": { + "bidder": { + "siteId": "569749" + }, + "ae": 1 + } + } + ], + "site": { + "page": "https://www.example.com/", + "publisher": { + "id": "569749" + } + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "some-test-ad", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "h": 250, + "w": 300, + "ext": { + "ix": {} + } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "adid": "29681110", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "w": 300, + "h": 250, + "ext": { + "ix": {} + } + }, + "type": "banner" + } + ] + } + ] +}