Skip to content

Commit

Permalink
Test: consented_providers_settings (#3577)
Browse files Browse the repository at this point in the history
  • Loading branch information
marki1an authored Dec 4, 2024
1 parent 21d4875 commit b3795a0
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.prebid.server.functional.model.request.auction

import com.fasterxml.jackson.databind.PropertyNamingStrategies
import com.fasterxml.jackson.databind.annotation.JsonNaming
import groovy.transform.ToString

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy)
class ConsentedProvidersSettings {

String consentedProviders
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.prebid.server.functional.model.request.auction

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.PropertyNamingStrategies
import com.fasterxml.jackson.databind.annotation.JsonNaming
import groovy.transform.ToString

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy)
class UserExt {

String consent
Expand All @@ -11,6 +15,9 @@ class UserExt {
UserTime time
UserExtData data
UserExtPrebid prebid
ConsentedProvidersSettings consentedProvidersSettings
@JsonProperty("ConsentedProvidersSettings")
ConsentedProvidersSettings consentedProvidersSettingsCamelCase

static UserExt getFPDUserExt() {
new UserExt(data: UserExtData.FPDUserExtData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ 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.BidRequest
import org.prebid.server.functional.model.request.auction.ConsentedProvidersSettings
import org.prebid.server.functional.model.request.auction.DistributionChannel
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.User
import org.prebid.server.functional.model.request.auction.UserExt
import org.prebid.server.functional.model.response.auction.SeatBid
import org.prebid.server.functional.service.PrebidServerException
import org.prebid.server.functional.util.PBSUtils
Expand Down Expand Up @@ -56,7 +59,7 @@ class AmpSpec extends BaseSpec {
assert exception.responseBody == "Invalid request format: request.${channel.value.toLowerCase()} must not exist in AMP stored requests."

where:
channel << [DistributionChannel.APP, DistributionChannel.DOOH]
channel << [DistributionChannel.APP, DistributionChannel.DOOH]
}

def "PBS should return info from the stored response when it's defined in the stored request"() {
Expand Down Expand Up @@ -180,4 +183,79 @@ class AmpSpec extends BaseSpec {
assert bidderRequest.imp[0]?.banner?.format[0]?.weight == ampStoredRequest.imp[0].banner.format[0].weight
assert bidderRequest.regs?.gdpr == ampStoredRequest.regs.gdpr
}

def "PBS should pass addtl_consent to user.ext.{consented_providers_settings/ConsentedProvidersSettings}.consented_providers"() {
given: "Default amp request with addtlConsent"
def randomAddtlConsent = PBSUtils.randomString
def ampRequest = AmpRequest.defaultAmpRequest.tap {
addtlConsent = randomAddtlConsent
}

and: "Save storedRequest into DB"
def ampStoredRequest = BidRequest.defaultBidRequest.tap {
user = new User(ext: new UserExt(
consentedProvidersSettingsCamelCase: new ConsentedProvidersSettings(consentedProviders: PBSUtils.randomString),
consentedProvidersSettings: new ConsentedProvidersSettings(consentedProviders: PBSUtils.randomString)))
}
def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest)
storedRequestDao.save(storedRequest)

when: "PBS processes amp request"
defaultPbsService.sendAmpRequest(ampRequest)

then: "Bidder request should contain addtl consent"
def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id)
assert bidderRequest.user.ext.consentedProvidersSettingsCamelCase.consentedProviders == randomAddtlConsent
assert bidderRequest.user.ext.consentedProvidersSettings.consentedProviders == randomAddtlConsent
}

def "PBS should process original user.ext.{consented_providers_settings/ConsentedProvidersSettings}.consented_providers when ampRequest doesn't contain addtl_consent"() {
given: "Default amp request with addtlConsent"
def ampRequest = AmpRequest.defaultAmpRequest.tap {
addtlConsent = null
}

and: "Save storedRequest into DB"
def consentProvidersKebabCase = PBSUtils.randomString
def consentProviders = PBSUtils.randomString
def ampStoredRequest = BidRequest.defaultBidRequest.tap {
user = new User(ext: new UserExt(
consentedProvidersSettingsCamelCase: new ConsentedProvidersSettings(consentedProviders: consentProvidersKebabCase),
consentedProvidersSettings: new ConsentedProvidersSettings(consentedProviders: consentProviders)))
}
def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest)
storedRequestDao.save(storedRequest)

when: "PBS processes amp request"
defaultPbsService.sendAmpRequest(ampRequest)

then: "Bidder request should contain requested consent"
def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id)
assert bidderRequest.user.ext.consentedProvidersSettingsCamelCase.consentedProviders == consentProvidersKebabCase
assert bidderRequest.user.ext.consentedProvidersSettings.consentedProviders == consentProviders
}

def "PBS should left user.ext.{consented_providers_settings/ConsentedProvidersSettings}.consented_providers empty when addtl_consent and original fields are empty"() {
given: "Default amp request with addtlConsent"
def ampRequest = AmpRequest.defaultAmpRequest.tap {
addtlConsent = null
}

and: "Save storedRequest into DB"
def ampStoredRequest = BidRequest.defaultBidRequest.tap {
user = new User(ext: new UserExt(
consentedProvidersSettingsCamelCase: new ConsentedProvidersSettings(consentedProviders: null),
consentedProvidersSettings: new ConsentedProvidersSettings(consentedProviders: null)))
}
def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest)
storedRequestDao.save(storedRequest)

when: "PBS processes amp request"
defaultPbsService.sendAmpRequest(ampRequest)

then: "Bidder request shouldn't contain consent"
def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id)
assert !bidderRequest.user.ext.consentedProvidersSettingsCamelCase.consentedProviders
assert !bidderRequest.user.ext.consentedProvidersSettings.consentedProviders
}
}

0 comments on commit b3795a0

Please sign in to comment.