Skip to content

Commit

Permalink
Add a functional test to ensure that bidder implementation is always …
Browse files Browse the repository at this point in the history
…merged (#3397)

* Add a functional test to ensure that the correct bidder implementation is always merged
  • Loading branch information
osulzhenko authored Aug 23, 2024
1 parent bb2afc7 commit 161409e
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.prebid.server.functional.tests

import org.prebid.server.functional.model.bidder.Openx
import org.prebid.server.functional.model.db.StoredImp
import org.prebid.server.functional.model.request.auction.BidRequest
import org.prebid.server.functional.model.request.auction.Imp
Expand All @@ -13,10 +14,12 @@ import static org.prebid.server.functional.model.bidder.BidderName.ALIAS_CAMEL_C
import static org.prebid.server.functional.model.bidder.BidderName.EMPTY
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC_CAMEL_CASE
import static org.prebid.server.functional.model.bidder.BidderName.OPENX
import static org.prebid.server.functional.model.bidder.BidderName.RUBICON
import static org.prebid.server.functional.model.bidder.BidderName.UNKNOWN
import static org.prebid.server.functional.model.bidder.BidderName.WILDCARD
import static org.prebid.server.functional.model.response.auction.ErrorType.PREBID
import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer

class ImpRequestSpec extends BaseSpec {

Expand Down Expand Up @@ -184,6 +187,41 @@ class ImpRequestSpec extends BaseSpec {
assert !bidderRequest?.imp?.first?.ext?.prebid?.bidder
}

def "PBS should always update specified bidder imp when imp.ext.prebid.imp contain such bidder"() {
given: "PBs with openx bidder"
def pbsService = pbsServiceFactory.getService(
["adapters.openx.enabled" : "true",
"adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()])

and: "Default basic BidRequest"
def impPmp = Pmp.defaultPmp
def extPrebidImpPmp = Pmp.defaultPmp
def bidRequest = BidRequest.defaultBidRequest.tap {
imp.first.tap {
pmp = impPmp
ext.prebid.bidder.openx = Openx.defaultOpenx
ext.prebid.imp = [(OPENX): new Imp(pmp: extPrebidImpPmp)]
}
}

when: "Requesting PBS auction"
def response = pbsService.sendAuctionRequest(bidRequest)

then: "Bid response should not contain warning"
assert !response?.ext?.warnings

and: "Generic bidderRequest should contain pmp from original imp"
def bidderToBidderRequests = getRequests(response)
assert bidderToBidderRequests[GENERIC.value].first.imp.pmp == [impPmp]

and: "OpenX bidderRequest should contain pmp from ext.prebid.imp"
assert bidderToBidderRequests[OPENX.value].first.imp.pmp == [extPrebidImpPmp]

and: "PBS should remove imp.ext.prebid.bidder from bidderRequests"
def bidderRequests = bidder.getBidderRequests(bidRequest.id)
assert !bidderRequests?.imp?.ext?.prebid?.imp?.flatten()
}

def "PBS should validate imp and add proper warning when imp.ext.prebid.imp contain invalid ortb data"() {
given: "BidRequest with invalid config for ext.prebid.imp"
def impPmp = Pmp.defaultPmp
Expand Down

0 comments on commit 161409e

Please sign in to comment.