Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed $0.00 price bids if there are deals #1910

Merged
merged 2 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions exchange/bidder_validate_bids.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ func validateBid(bid *pbsOrtbBid) (bool, error) {
if bid.bid.ImpID == "" {
return false, fmt.Errorf("Bid \"%s\" missing required field 'impid'", bid.bid.ID)
}
if bid.bid.Price <= 0.0 {
return false, fmt.Errorf("Bid \"%s\" does not contain a positive 'price'", bid.bid.ID)
if bid.bid.Price < 0.0 {
return false, fmt.Errorf("Bid \"%s\" does not contain a positive (or zero if there is a deal) 'price'", bid.bid.ID)
}
if bid.bid.Price == 0.0 && bid.bid.DealID == "" {
return false, fmt.Errorf("Bid \"%s\" does not contain positive 'price' which is required since there is no deal set for this bid", bid.bid.ID)
}
if bid.bid.CrID == "" {
return false, fmt.Errorf("Bid \"%s\" missing creative ID", bid.bid.ID)
Expand Down
60 changes: 56 additions & 4 deletions exchange/bidder_validate_bids_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ func TestAllValidBids(t *testing.T) {
CrID: "789",
},
},
{
bid: &openrtb2.Bid{
ID: "zeroPriceBid",
ImpID: "444",
Price: 0.00,
CrID: "555",
DealID: "777",
},
},
},
},
})
seatBid, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false)
assert.Len(t, seatBid.bids, 3)
assert.Len(t, seatBid.bids, 4)
assert.Len(t, errs, 0)
}

Expand Down Expand Up @@ -79,13 +88,30 @@ func TestAllBadBids(t *testing.T) {
CrID: "blah",
},
},
{
bid: &openrtb2.Bid{
ID: "zeroPriceBidNoDeal",
ImpID: "444",
Price: 0.00,
CrID: "555",
DealID: "",
},
},
{
bid: &openrtb2.Bid{
ID: "negativePrice",
ImpID: "999",
Price: -0.10,
CrID: "888",
},
},
{},
},
},
})
seatBid, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false)
assert.Len(t, seatBid.bids, 0)
assert.Len(t, errs, 5)
assert.Len(t, errs, 7)
}

func TestMixedBids(t *testing.T) {
Expand Down Expand Up @@ -122,13 +148,39 @@ func TestMixedBids(t *testing.T) {
CrID: "blah",
},
},
{
bid: &openrtb2.Bid{
ID: "zeroPriceBid",
ImpID: "444",
Price: 0.00,
CrID: "555",
DealID: "777",
},
},
{
bid: &openrtb2.Bid{
ID: "zeroPriceBidNoDeal",
ImpID: "444",
Price: 0.00,
CrID: "555",
DealID: "",
},
},
{
bid: &openrtb2.Bid{
ID: "negativePrice",
ImpID: "999",
Price: -0.10,
CrID: "888",
},
},
{},
},
},
})
seatBid, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true, false)
assert.Len(t, seatBid.bids, 2)
assert.Len(t, errs, 3)
assert.Len(t, seatBid.bids, 3)
assert.Len(t, errs, 5)
}

func TestCurrencyBids(t *testing.T) {
Expand Down