From 5a60b4d66aa04c9fcaadbcfa7ea11f53b94efb9d Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Mon, 15 Sep 2025 16:12:08 +0300 Subject: [PATCH 1/2] Test: Fix default value of targeting.hb_pb --- .../functional/tests/TargetingSpec.groovy | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy index 960e05b458e..931be1f06c7 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy @@ -543,6 +543,31 @@ class TargetingSpec extends BaseSpec { assert targetingKeyMap["hb_pb"] == String.format("%,.2f", max.setScale(precision, RoundingMode.DOWN)) } + def "PBS auction shouldn't delete bid and update targeting if price equal zero and dealId it present"() { + given: "Default bid request with stored response" + def storedBidResponseId = PBSUtils.randomString + def bidRequest = BidRequest.defaultBidRequest.tap { + imp[0].ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedBidResponseId, bidder: GENERIC)] + ext.prebid.targeting = Targeting.createWithAllValuesSetTo(true) + } + + and: "Create and save stored response with zero prise into DB" + def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + seatbid[0].bid[0].price = 0 + seatbid[0].bid[0].dealid = PBSUtils.randomNumber + } + def storedResponse = new StoredResponse(responseId: storedBidResponseId, storedBidResponse: storedBidResponse) + storedResponseDao.save(storedResponse) + + when: "PBS processes auction request" + def response = defaultPbsService.sendAuctionRequest(bidRequest) + + then: "Response should contain proper targeting hb_pb" + def targetingKeyMap = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting + assert targetingKeyMap["hb_pb"] == '0.0' + assert targetingKeyMap["hb_pb_generic"] == '0.0' + } + def "PBS auction should use default targeting prefix when ext.prebid.targeting.prefix is biggest that twenty"() { given: "Bid request with long targeting prefix" def prefix = PBSUtils.getRandomString(30) From 770da272d0be384b671279785c2c5f5bdad66781 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 26 Sep 2025 18:33:04 +0300 Subject: [PATCH 2/2] Update after review --- .../functional/tests/TargetingSpec.groovy | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy index 931be1f06c7..46078bcd99e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy @@ -62,6 +62,7 @@ class TargetingSpec extends BaseSpec { private static final String HB_ENV_AMP = "amp" private static final Integer MAIN_RANK = 1 private static final Integer SUBORDINATE_RANK = 2 + private static final String EMPTY_CPM = "0.0" def "PBS should include targeting bidder specific keys when alwaysIncludeDeals is true and deal bid wins"() { given: "Bid request with alwaysIncludeDeals = true" @@ -543,29 +544,28 @@ class TargetingSpec extends BaseSpec { assert targetingKeyMap["hb_pb"] == String.format("%,.2f", max.setScale(precision, RoundingMode.DOWN)) } - def "PBS auction shouldn't delete bid and update targeting if price equal zero and dealId it present"() { + def "PBS auction shouldn't delete bid and update targeting if price equal zero and dealId present"() { given: "Default bid request with stored response" - def storedBidResponseId = PBSUtils.randomString def bidRequest = BidRequest.defaultBidRequest.tap { - imp[0].ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedBidResponseId, bidder: GENERIC)] ext.prebid.targeting = Targeting.createWithAllValuesSetTo(true) } - and: "Create and save stored response with zero prise into DB" - def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { + and: "Bid response with zero price" + def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { seatbid[0].bid[0].price = 0 - seatbid[0].bid[0].dealid = PBSUtils.randomNumber + seatbid[0].bid[0].dealid = PBSUtils.randomString } - def storedResponse = new StoredResponse(responseId: storedBidResponseId, storedBidResponse: storedBidResponse) - storedResponseDao.save(storedResponse) + + and: "Set bidder response" + bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes auction request" def response = defaultPbsService.sendAuctionRequest(bidRequest) then: "Response should contain proper targeting hb_pb" def targetingKeyMap = response.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting - assert targetingKeyMap["hb_pb"] == '0.0' - assert targetingKeyMap["hb_pb_generic"] == '0.0' + assert targetingKeyMap["hb_pb"] == EMPTY_CPM + assert targetingKeyMap["hb_pb_generic"] == EMPTY_CPM } def "PBS auction should use default targeting prefix when ext.prebid.targeting.prefix is biggest that twenty"() {