-
Notifications
You must be signed in to change notification settings - Fork 250
Test: Multiple bidder codes #3866
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
65d0bea
Update alternate bidder code
marki1an 4455bb6
Merge remote-tracking branch 'refs/remotes/origin/multiple-bidder-cod…
marki1an 7cd5d53
Update alternate bidder code
marki1an cbdc451
Update alternate bidder code
marki1an 02bd239
Update after review
marki1an 35ed5c6
Update after review
marki1an b39f68b
Update after review
marki1an 324a808
Minor update
marki1an File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
src/test/groovy/org/prebid/server/functional/model/request/auction/AuctionEnvironment.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,13 @@ import org.prebid.server.functional.model.config.AccountConfig | |
| import org.prebid.server.functional.model.config.AlternateBidderCodes | ||
| import org.prebid.server.functional.model.config.BidderConfig | ||
| import org.prebid.server.functional.model.db.Account | ||
| import org.prebid.server.functional.model.db.StoredImp | ||
| import org.prebid.server.functional.model.db.StoredResponse | ||
| import org.prebid.server.functional.model.request.auction.Amx | ||
| import org.prebid.server.functional.model.request.auction.BidRequest | ||
| import org.prebid.server.functional.model.request.auction.Imp | ||
| import org.prebid.server.functional.model.request.auction.PrebidStoredRequest | ||
| import org.prebid.server.functional.model.request.auction.StoredBidResponse | ||
| import org.prebid.server.functional.model.request.auction.Targeting | ||
| import org.prebid.server.functional.model.response.auction.BidExt | ||
| import org.prebid.server.functional.model.response.auction.BidResponse | ||
|
|
@@ -269,7 +274,7 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| assert response.ext.seatnonbid.size() == 1 | ||
|
|
||
| def seatNonBid = response.ext.seatnonbid[0] | ||
| assert seatNonBid.seat == AMX.value | ||
| assert seatNonBid.seat == bidderName.value | ||
| assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id | ||
| assert seatNonBid.nonBid[0].statusCode == RESPONSE_REJECTED_GENERAL | ||
|
|
||
|
|
@@ -324,7 +329,7 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| assert response.ext.seatnonbid.size() == 1 | ||
|
|
||
| def seatNonBid = response.ext.seatnonbid[0] | ||
| assert seatNonBid.seat == ALIAS.value | ||
| assert seatNonBid.seat == bidderName.value | ||
| assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id | ||
| assert seatNonBid.nonBid[0].statusCode == RESPONSE_REJECTED_GENERAL | ||
|
|
||
|
|
@@ -782,7 +787,7 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| assert response.ext.seatnonbid.size() == 1 | ||
|
|
||
| def seatNonBid = response.ext.seatnonbid[0] | ||
| assert seatNonBid.seat == AMX.value | ||
| assert seatNonBid.seat == UNKNOWN.value | ||
| assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id | ||
| assert seatNonBid.nonBid[0].statusCode == RESPONSE_REJECTED_GENERAL | ||
|
|
||
|
|
@@ -838,7 +843,7 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| assert response.ext.seatnonbid.size() == 1 | ||
|
|
||
| def seatNonBid = response.ext.seatnonbid[0] | ||
| assert seatNonBid.seat == AMX.value | ||
| assert seatNonBid.seat == UNKNOWN.value | ||
| assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id | ||
| assert seatNonBid.nonBid[0].statusCode == RESPONSE_REJECTED_GENERAL | ||
|
|
||
|
|
@@ -1182,7 +1187,7 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| assert response.ext.seatnonbid.size() == 1 | ||
|
|
||
| def seatNonBid = response.ext.seatnonbid[0] | ||
| assert seatNonBid.seat == AMX.value | ||
| assert seatNonBid.seat == requestedAllowedBidderCode.value | ||
| assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id | ||
| assert seatNonBid.nonBid[0].statusCode == RESPONSE_REJECTED_GENERAL | ||
|
|
||
|
|
@@ -1237,7 +1242,7 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| assert response.ext.seatnonbid.size() == 1 | ||
|
|
||
| def seatNonBid = response.ext.seatnonbid[0] | ||
| assert seatNonBid.seat == AMX.value | ||
| assert seatNonBid.seat == requestedAllowedBidderCode.value | ||
| assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id | ||
| assert seatNonBid.nonBid[0].statusCode == RESPONSE_REJECTED_GENERAL | ||
|
|
||
|
|
@@ -1298,7 +1303,7 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| assert response.ext.seatnonbid.size() == 1 | ||
|
|
||
| def seatNonBid = response.ext.seatnonbid[0] | ||
| assert seatNonBid.seat == AMX.value | ||
| assert seatNonBid.seat == allowedBidderCodes.value | ||
| assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id | ||
| assert seatNonBid.nonBid[0].statusCode == RESPONSE_REJECTED_GENERAL | ||
|
|
||
|
|
@@ -1572,6 +1577,228 @@ class AlternateBidderCodeSpec extends BaseSpec { | |
| pbsServiceFactory.removeContainer(pbsConfig) | ||
| } | ||
|
|
||
| def "PBS should populate two seat bid when different bidder response with same seat"() { | ||
| given: "Default bid request with amx and generic bidder" | ||
| def bidRequest = getBidRequestWithAmxBidderAndAlternateBidderCode().tap { | ||
| imp[0].ext.prebid.bidder.generic = new Generic() | ||
| ext.prebid.alternateBidderCodes.bidders = [(AMX): new BidderConfig(enabled: true, allowedBidderCodes: [GENERIC])] | ||
| } | ||
|
|
||
| and: "Bid response with bidder code" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest, AMX).tap { | ||
| it.seatbid[0].bid[0].ext = new BidExt(bidderCode: GENERIC) | ||
| } | ||
| bidder.setResponse(bidRequest.id, bidResponse) | ||
|
|
||
| and: "Flash metrics" | ||
| flushMetrics(pbsServiceWithAmxBidder) | ||
|
|
||
| when: "PBS processes auction request" | ||
| def response = pbsServiceWithAmxBidder.sendAuctionRequest(bidRequest) | ||
|
osulzhenko marked this conversation as resolved.
|
||
|
|
||
| then: "Bid response should contain seat" | ||
| assert response.seatbid.seat.sort() == [GENERIC, GENERIC].sort() | ||
|
|
||
| and: "Response should contain adapter code" | ||
| assert response.seatbid.bid.ext.prebid.meta.adapterCode.flatten().sort() == [AMX, GENERIC].sort() | ||
|
|
||
| and: "Response should contain bidder amx targeting" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Response should contain bidder generic targeting? |
||
| def targeting = response.seatbid.bid.ext.prebid.targeting.flatten().collectEntries() | ||
| assert targeting["hb_pb_${GENERIC}"] | ||
| assert targeting["hb_size_${GENERIC}"] | ||
| assert targeting["hb_bidder_${GENERIC}"] == GENERIC.value | ||
|
|
||
| and: "Response should contain repose millis with corresponding bidder" | ||
| assert response.ext.responsetimemillis.containsKey(GENERIC.value) | ||
|
|
||
| and: "Response shouldn't contain repose millis with amx bidder" | ||
| assert !response.ext.responsetimemillis.containsKey(AMX.value) | ||
|
|
||
| and: "Bidder request should be valid" | ||
| assert bidder.getBidderRequests(bidRequest.id) | ||
|
|
||
| and: "Response shouldn't contain warnings and error and seatNonBid" | ||
| assert !response.ext?.warnings | ||
| assert !response.ext?.errors | ||
| assert !response.ext?.seatnonbid | ||
|
|
||
| and: "Response shouldn't contain demand source" | ||
| assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource | ||
|
|
||
| and: "PBS shouldn't emit validation metrics" | ||
| def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() | ||
| assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] | ||
| assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] | ||
| } | ||
|
|
||
| def "PBS should return two seat when same bidder response with different bidder code"() { | ||
| given: "Default bid request with amx and generic bidder" | ||
| def bidRequest = getBidRequestWithAmxBidderAndAlternateBidderCode().tap { | ||
| imp.add(Imp.getDefaultImpression()) | ||
| imp[1].ext.prebid.bidder.amx = new Amx() | ||
| imp[1].ext.prebid.bidder.generic = null | ||
| ext.prebid.alternateBidderCodes.bidders = [(AMX): new BidderConfig(enabled: true, allowedBidderCodes: [GENERIC, AMX])] | ||
| } | ||
|
|
||
| and: "Bid response with bidder code" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest, AMX).tap { | ||
| it.seatbid[0].bid[0].ext = new BidExt(bidderCode: GENERIC) | ||
| it.seatbid[0].bid[1].ext = new BidExt(bidderCode: AMX) | ||
| } | ||
| bidder.setResponse(bidRequest.id, bidResponse) | ||
|
|
||
| and: "Flash metrics" | ||
| flushMetrics(pbsServiceWithAmxBidder) | ||
|
|
||
| when: "PBS processes auction request" | ||
| def response = pbsServiceWithAmxBidder.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "Bid response should contain seat" | ||
| assert response.seatbid.seat.sort() == [GENERIC, AMX].sort() | ||
|
|
||
| and: "Response should contain adapter code" | ||
| assert response.seatbid.bid.ext.prebid.meta.adapterCode.flatten() == [AMX, AMX] | ||
|
|
||
| and: "Response should contain bidder amx targeting" | ||
| def targeting = response.seatbid.bid.ext.prebid.targeting.flatten().collectEntries() | ||
| assert targeting["hb_pb_${AMX}"] | ||
| assert targeting["hb_size_${AMX}"] | ||
| assert targeting["hb_bidder_${AMX}"] == AMX.value | ||
|
|
||
| and: 'Response targeting should contain generic' | ||
| assert targeting["hb_pb_${GENERIC}"] | ||
| assert targeting["hb_size_${GENERIC}"] | ||
| assert targeting["hb_bidder_${GENERIC}"] == GENERIC.value | ||
|
|
||
| and: "Response should contain repose millis with corresponding bidder" | ||
| assert response.ext.responsetimemillis.containsKey(GENERIC.value) | ||
| assert response.ext.responsetimemillis.containsKey(AMX.value) | ||
|
|
||
| and: "Bidder request should be valid" | ||
| assert bidder.getBidderRequests(bidRequest.id) | ||
|
|
||
| and: "Response shouldn't contain warnings and error and seatNonBid" | ||
| assert !response.ext?.warnings | ||
| assert !response.ext?.errors | ||
| assert !response.ext?.seatnonbid | ||
|
|
||
| and: "Response shouldn't contain demand source" | ||
| assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource | ||
|
|
||
| and: "PBS shouldn't emit validation metrics" | ||
| def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() | ||
| assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] | ||
| assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] | ||
| } | ||
|
|
||
| def "PBS should populate seat bid from stored bid response when stored bid response and alternate bidder code specified"() { | ||
| given: "Default bid request with amx bidder" | ||
| def storedResponseId = PBSUtils.randomNumber | ||
| def bidRequest = getBidRequestWithAmxBidderAndAlternateBidderCode().tap { | ||
| imp[0].ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: AMX)] | ||
| ext.prebid.alternateBidderCodes.bidders = [(AMX): new BidderConfig(enabled: true, allowedBidderCodes: [GENERIC])] | ||
| } | ||
|
|
||
| and: "Stored bid response in DB" | ||
| def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest) | ||
| def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) | ||
| storedResponseDao.save(storedResponse) | ||
|
|
||
| and: "Bid response with bidder code" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest, AMX).tap { | ||
| it.seatbid[0].bid[0].ext = new BidExt(bidderCode: GENERIC) | ||
| } | ||
| bidder.setResponse(bidRequest.id, bidResponse) | ||
|
|
||
| and: "Flash metrics" | ||
| flushMetrics(pbsServiceWithAmxBidder) | ||
|
|
||
| when: "PBS processes auction request" | ||
| def response = pbsServiceWithAmxBidder.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "Bid response should contain seat" | ||
| assert response.seatbid.seat == [AMX] | ||
|
|
||
| and: "Response should contain adapter code" | ||
| assert response.seatbid.bid.ext.prebid.meta.adapterCode.flatten() == [AMX] | ||
|
|
||
| and: "Response should contain bidder generic targeting" | ||
| def targeting = response.seatbid.bid.ext.prebid.targeting.flatten().collectEntries() | ||
| assert targeting["hb_pb_${AMX}"] | ||
| assert targeting["hb_size_${AMX}"] | ||
| assert targeting["hb_bidder_${AMX}"] == AMX.value | ||
|
|
||
| and: "Response should contain repose millis with corresponding bidder" | ||
| assert response.ext.responsetimemillis.containsKey(AMX.value) | ||
|
|
||
| and: "Bidder request shouldn't be called due to storedBidResponse" | ||
| assert !bidder.getBidderRequests(bidRequest.id) | ||
|
|
||
| and: "Response shouldn't contain warnings and error and seatNonBid" | ||
| assert !response.ext?.warnings | ||
| assert !response.ext?.errors | ||
| assert !response.ext?.seatnonbid | ||
|
|
||
| and: "Response shouldn't contain demand source" | ||
| assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource | ||
|
|
||
| and: "PBS shouldn't emit validation metrics" | ||
| def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() | ||
| assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] | ||
| } | ||
|
|
||
| def "PBS auction allow bidder code when imp stored request and allowed bidder code present"() { | ||
| given: "Default bid request" | ||
| def bidRequest = getBidRequestWithAmxBidderAndAlternateBidderCode().tap { | ||
| imp[0].ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomString) | ||
| ext.prebid.alternateBidderCodes.bidders = [(AMX): new BidderConfig(enabled: true, allowedBidderCodes: [GENERIC])] | ||
| } | ||
|
|
||
| and: "Save storedImp into DB" | ||
| def storedImp = StoredImp.getStoredImp(bidRequest) | ||
| storedImpDao.save(storedImp) | ||
|
|
||
| and: "Bid response with bidder code" | ||
| def bidResponse = BidResponse.getDefaultBidResponse(bidRequest, AMX).tap { | ||
| it.seatbid[0].bid[0].ext = new BidExt(bidderCode: GENERIC) | ||
| } | ||
| bidder.setResponse(bidRequest.id, bidResponse) | ||
|
|
||
| when: "Requesting PBS auction" | ||
| def response = pbsServiceWithAmxBidder.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "Bid response should contain seat" | ||
| assert response.seatbid.seat.sort() == [GENERIC].sort() | ||
|
|
||
| and: "Response should contain adapter code" | ||
| assert response.seatbid.bid.ext.prebid.meta.adapterCode.flatten() == [AMX] | ||
|
|
||
| and: "Response should contain bidder generic targeting" | ||
| def targeting = response.seatbid.bid.ext.prebid.targeting.flatten().collectEntries() | ||
| assert targeting["hb_pb_${GENERIC}"] | ||
| assert targeting["hb_size_${GENERIC}"] | ||
| assert targeting["hb_bidder_${GENERIC}"] == GENERIC.value | ||
|
|
||
| and: "Response should contain repose millis with corresponding bidder" | ||
| assert response.ext.responsetimemillis.containsKey(GENERIC.value) | ||
|
|
||
| and: "Bidder request should be called" | ||
| assert bidder.getBidderRequests(bidRequest.id) | ||
|
|
||
| and: "Response shouldn't contain warnings and error and seatNonBid" | ||
| assert !response.ext?.warnings | ||
| assert !response.ext?.errors | ||
| assert !response.ext?.seatnonbid | ||
|
|
||
| and: "Response shouldn't contain demand source" | ||
| assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource | ||
|
|
||
| and: "PBS shouldn't emit validation metrics" | ||
| def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() | ||
| assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] | ||
| assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] | ||
| } | ||
|
|
||
| private static Account getAccountWithAlternateBidderCode(BidRequest bidRequest) { | ||
| new Account().tap { | ||
| it.uuid = bidRequest.accountId | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also pls add smoke case for stored request, response, imp request