Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.prebid.server.functional.model.db.StoredRequest
import org.prebid.server.functional.model.db.StoredResponse
import org.prebid.server.functional.model.request.amp.AmpRequest
import org.prebid.server.functional.model.request.auction.AdServerTargeting
import org.prebid.server.functional.model.request.auction.App
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.MultiBid
Expand All @@ -20,6 +21,7 @@ import org.prebid.server.functional.model.request.auction.PrebidCache
import org.prebid.server.functional.model.request.auction.PrebidStoredRequest
import org.prebid.server.functional.model.request.auction.PriceGranularity
import org.prebid.server.functional.model.request.auction.Range
import org.prebid.server.functional.model.request.auction.Site
import org.prebid.server.functional.model.request.auction.StoredAuctionResponse
import org.prebid.server.functional.model.request.auction.StoredBidResponse
import org.prebid.server.functional.model.request.auction.Targeting
Expand Down Expand Up @@ -1906,6 +1908,41 @@ class TargetingSpec extends BaseSpec {
]
}

def "PBS amp shouldn't emit error for targeting when site is array"() {
given: "Create targeting with array of site"
def anyRandomValue = PBSUtils.randomString
def targeting = ["site": siteValue, "any": anyRandomValue]

and: "Encode targeting to string"
def encodeTargeting = URLEncoder.encode(encode(targeting), StandardCharsets.UTF_8)

and: "Amp request with targeting"
def ampRequest = AmpRequest.defaultAmpRequest.tap {
it.targeting = encodeTargeting
}

and: "Default bid request"
def ampStoredRequest = BidRequest.defaultBidRequest

and: "Create and save stored request into DB"
def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest)
storedRequestDao.save(storedRequest)

when: "PBS processes amp request"
def ampResponse = pbsWithDefaultTargetingLength.sendAmpRequest(ampRequest)

then: "Amp response should contain value from targeting in imp.ext.data"
def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id)
assert bidderRequest.imp[0].ext.data.any == anyRandomValue

and: "Amp response shouldn't contain any errors"
assert !ampResponse.ext.errors

where:
siteValue << [null, [], [PBSUtils.randomString], [Site.defaultSite], [Site.defaultSite, PBSUtils.randomString],
[PBSUtils.randomString, Site.defaultSite], [App.defaultApp, Site.defaultSite]]
Comment on lines +1940 to +1943
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this implementation isn't correct based on the existing code. If you look at OrtbTypesResolver.normalizeBidRequest, it should throw an error for non-site objects.
We also need to cover:

  • cases where site.size >= 2 it it okay.
  • What are the side effects on bidderRequest and bidRequest?
    Please investigate this further

}

private static Account createAccountWithPriceGranularity(String accountId, PriceGranularityType priceGranularity) {
def accountAuctionConfig = new AccountAuctionConfig(priceGranularity: priceGranularity)
def accountConfig = new AccountConfig(status: ACTIVE, auction: accountAuctionConfig)
Expand Down
Loading