Skip to content

Commit

Permalink
Rubicon: Add bid.ext.prebid.meta tests (prebid#3949)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoxaAntoxic authored Dec 10, 2024
1 parent 30b1d75 commit e923c1c
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ func TestOpenRTBResponseSettingOfNetworkId(t *testing.T) {

var givenBidExt json.RawMessage
if scenario.bidExt != nil {
marshalledExt, _ := json.Marshal(scenario.bidExt)
marshalledExt, _ := json.Marshal(&openrtb_ext.ExtBid{Prebid: scenario.bidExt})
givenBidExt = marshalledExt
} else {
givenBidExt = nil
Expand Down Expand Up @@ -1041,6 +1041,46 @@ func TestOpenRTBResponseSettingOfNetworkId(t *testing.T) {
}
}

func TestOpenRTBResponseBidExtPrebidMetaPassthrough(t *testing.T) {
request := &openrtb2.BidRequest{
Imp: []openrtb2.Imp{{
ID: "test-imp-id",
Banner: &openrtb2.Banner{},
}},
}

requestJson, _ := json.Marshal(request)
reqData := &adapters.RequestData{
Method: "POST",
Uri: "test-uri",
Body: requestJson,
Headers: nil,
}

bidExt := &openrtb_ext.ExtBid{Prebid: &openrtb_ext.ExtBidPrebid{Meta: &openrtb_ext.ExtBidPrebidMeta{AdapterCode: "1", MediaType: "banner"}}}
givenBidExt, _ := json.Marshal(bidExt)

givenBidResponse := rubiconBidResponse{
SeatBid: []rubiconSeatBid{{
Bid: []rubiconBid{{
Bid: openrtb2.Bid{Price: 123.2, ImpID: "test-imp-id", Ext: givenBidExt}}}}},
}
body, _ := json.Marshal(&givenBidResponse)
httpResp := &adapters.ResponseData{
StatusCode: http.StatusOK,
Body: body,
}

bidder := new(RubiconAdapter)
bidResponse, errs := bidder.MakeBids(request, reqData, httpResp)
assert.Empty(t, errs)

var actualBidExt openrtb_ext.ExtBid
err := json.Unmarshal(bidResponse.Bids[0].Bid.Ext, &actualBidExt)
assert.NoError(t, err)
assert.Equal(t, bidExt.Prebid.Meta, actualBidExt.Prebid.Meta)
}

func TestOpenRTBResponseOverridePriceFromCorrespondingImp(t *testing.T) {
request := &openrtb2.BidRequest{
ID: "test-request-id",
Expand Down

0 comments on commit e923c1c

Please sign in to comment.