Skip to content
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

Update privacy functional test: GVL file handling #3644

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
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 @@ -121,7 +121,7 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec {
accountDao.save(account)

when: "PBS processes auction requests"
def bidResponse = pbsServiceFactory.getService(PBS_CONFIG).sendAuctionRequest(bidRequest)
def bidResponse = activityPbsService.sendAuctionRequest(bidRequest)

then: "Bid response should contain basic info in debug"
def infrastructure = bidResponse.ext.debug.trace.activityInfrastructure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import org.prebid.server.functional.model.request.auction.BidRequest
import org.prebid.server.functional.model.request.auction.DistributionChannel
import org.prebid.server.functional.model.request.auction.Regs
import org.prebid.server.functional.model.request.auction.RegsExt
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.testcontainers.container.PrebidServerContainer
import org.prebid.server.functional.util.PBSUtils
import org.prebid.server.functional.util.privacy.BogusConsent
import org.prebid.server.functional.util.privacy.CcpaConsent
Expand Down Expand Up @@ -320,10 +318,8 @@ class GdprAmpSpec extends PrivacyBaseSpec {
def startTime = Instant.now()

and: "Create new container"
def serverContainer = new PrebidServerContainer(GDPR_VENDOR_LIST_CONFIG +
["adapters.generic.meta-info.vendor-id": GENERIC_VENDOR_ID as String])
serverContainer.start()
def privacyPbsService = new PrebidServerService(serverContainer)
def config = GDPR_VENDOR_LIST_CONFIG + ["adapters.generic.meta-info.vendor-id": GENERIC_VENDOR_ID as String]
def defaultPrivacyPbsService = pbsServiceFactory.getService(config)

and: "Prepare tcf consent string"
def tcfConsent = new TcfConsent.Builder()
Expand All @@ -347,21 +343,21 @@ class GdprAmpSpec extends PrivacyBaseSpec {
vendorListResponse.setResponse(tcfPolicyVersion)

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

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
assert vendorList.tcfPolicyVersion == tcfPolicyVersion.vendorListVersion

and: "Logs should contain proper vendor list version"
def logs = privacyPbsService.getLogsByTime(startTime)
def logs = defaultPrivacyPbsService.getLogsByTime(startTime)
assert getLogsByText(logs, "Created new TCF 2 vendor list for version " +
"v${tcfPolicyVersion.vendorListVersion}.${tcfPolicyVersion.vendorListVersion}")

cleanup: "Stop container with default request"
serverContainer.stop()
cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(config)

where:
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
Expand Down Expand Up @@ -410,7 +406,10 @@ class GdprAmpSpec extends PrivacyBaseSpec {
}

def "PBS amp should emit the same error without a second GVL list request if a retry is too soon for the exponential-backoff"() {
given: "Test start time"
given: "Prebid server with privacy settings"
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)

and: "Test start time"
def startTime = Instant.now()

and: "Prepare tcf consent string"
Expand Down Expand Up @@ -438,33 +437,36 @@ class GdprAmpSpec extends PrivacyBaseSpec {
vendorListResponse.setResponse(tcfPolicyVersion, Delay.seconds(EXPONENTIAL_BACKOFF_MAX_DELAY + 3))

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

then: "PBS shouldn't fetch vendor list"
def vendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
assert !privacyPbsService.isFileExist(vendorListPath)
assert !defaultPrivacyPbsService.isFileExist(vendorListPath)

and: "Logs should contain proper vendor list version"
def logs = privacyPbsService.getLogsByTime(startTime)
def logs = defaultPrivacyPbsService.getLogsByTime(startTime)
def tcfError = "TCF 2 vendor list for version v${tcfPolicyVersion.vendorListVersion}.${tcfPolicyVersion.vendorListVersion} not found, started downloading."
assert getLogsByText(logs, tcfError)

and: "Second start for fetch second round of logs"
def secondStartTime = Instant.now()

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

then: "PBS shouldn't fetch vendor list"
assert !privacyPbsService.isFileExist(vendorListPath)
assert !defaultPrivacyPbsService.isFileExist(vendorListPath)

and: "Logs should contain proper vendor list version"
def logsSecond = privacyPbsService.getLogsByTime(secondStartTime)
def logsSecond = defaultPrivacyPbsService.getLogsByTime(secondStartTime)
assert getLogsByText(logsSecond, tcfError)

and: "Reset vendor list response"
vendorListResponse.reset()

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)

where:
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
}
Expand Down Expand Up @@ -659,7 +661,10 @@ class GdprAmpSpec extends PrivacyBaseSpec {
}

def "PBS amp should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() {
given: "Tcf consent setup"
given: "Prebid server with privacy settings"
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)

and: "Tcf consent setup"
def tcfConsent = new TcfConsent.Builder()
.setPurposesLITransparency(BASIC_ADS)
.setTcfPolicyVersion(tcfPolicyVersion.value)
Expand All @@ -681,14 +686,17 @@ class GdprAmpSpec extends PrivacyBaseSpec {
vendorListResponse.setResponse(tcfPolicyVersion)

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

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
assert vendorList.gvlSpecificationVersion == V3

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)

where:
tcfPolicyVersion << [TCF_POLICY_V4, TCF_POLICY_V5]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import org.prebid.server.functional.model.request.auction.DistributionChannel
import org.prebid.server.functional.model.request.auction.Regs
import org.prebid.server.functional.model.request.auction.RegsExt
import org.prebid.server.functional.model.response.auction.ErrorType
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.testcontainers.container.PrebidServerContainer
import org.prebid.server.functional.util.PBSUtils
import org.prebid.server.functional.util.privacy.BogusConsent
import org.prebid.server.functional.util.privacy.TcfConsent
Expand Down Expand Up @@ -278,10 +276,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
def startTime = Instant.now()

and: "Create new container"
def serverContainer = new PrebidServerContainer(GDPR_VENDOR_LIST_CONFIG +
["adapters.generic.meta-info.vendor-id": GENERIC_VENDOR_ID as String])
serverContainer.start()
def privacyPbsService = new PrebidServerService(serverContainer)
def config = GDPR_VENDOR_LIST_CONFIG + ["adapters.generic.meta-info.vendor-id": GENERIC_VENDOR_ID as String]
def defaultPrivacyPbsService = pbsServiceFactory.getService(config)

and: "Tcf consent setup"
def tcfConsent = new TcfConsent.Builder()
Expand All @@ -298,21 +294,21 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
vendorListResponse.setResponse(tcfPolicyVersion)

when: "PBS processes auction request"
privacyPbsService.sendAuctionRequest(bidRequest)
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
assert vendorList.tcfPolicyVersion == tcfPolicyVersion.vendorListVersion

and: "Logs should contain proper vendor list version"
def logs = privacyPbsService.getLogsByTime(startTime)
def logs = defaultPrivacyPbsService.getLogsByTime(startTime)
assert getLogsByText(logs, "Created new TCF 2 vendor list for version " +
"v${tcfPolicyVersion.vendorListVersion}.${tcfPolicyVersion.vendorListVersion}")

cleanup: "Stop container with default request"
serverContainer.stop()
cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(config)

where:
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
Expand Down Expand Up @@ -357,7 +353,10 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
}

def "PBS auction should emit the same error without a second GVL list request if a retry is too soon for the exponential-backoff"() {
given: "Test start time"
given: "Prebid server with privacy settings"
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)

and: "Test start time"
def startTime = Instant.now()

and: "Tcf consent setup"
Expand All @@ -378,33 +377,36 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
vendorListResponse.setResponse(tcfPolicyVersion, Delay.seconds(EXPONENTIAL_BACKOFF_MAX_DELAY + 3))

when: "PBS processes auction request"
privacyPbsService.sendAuctionRequest(bidRequest)
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
assert !privacyPbsService.isFileExist(properVendorListPath)
assert !defaultPrivacyPbsService.isFileExist(properVendorListPath)

and: "Logs should contain proper vendor list version"
def logs = privacyPbsService.getLogsByTime(startTime)
def logs = defaultPrivacyPbsService.getLogsByTime(startTime)
def tcfError = "TCF 2 vendor list for version v${tcfPolicyVersion.vendorListVersion}.${tcfPolicyVersion.vendorListVersion} not found, started downloading."
assert getLogsByText(logs, tcfError)

and: "Second start for fetch second round of logs"
def secondStartTime = Instant.now()

when: "PBS processes amp request"
privacyPbsService.sendAuctionRequest(bidRequest)
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)

then: "PBS shouldn't fetch vendor list"
assert !privacyPbsService.isFileExist(properVendorListPath)
assert !defaultPrivacyPbsService.isFileExist(properVendorListPath)

and: "Logs should contain proper vendor list version"
def logsSecond = privacyPbsService.getLogsByTime(secondStartTime)
def logsSecond = defaultPrivacyPbsService.getLogsByTime(secondStartTime)
assert getLogsByText(logsSecond, tcfError)

and: "Reset vendor list response"
vendorListResponse.reset()

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)

where:
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
}
Expand Down Expand Up @@ -783,7 +785,10 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
}

def "PBS auction should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() {
given: "Tcf consent setup"
given: "Prebid server with privacy settings"
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)

and: "Tcf consent setup"
def tcfConsent = new TcfConsent.Builder()
.setPurposesLITransparency(BASIC_ADS)
.setTcfPolicyVersion(tcfPolicyVersion.value)
Expand All @@ -798,14 +803,17 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
vendorListResponse.setResponse(tcfPolicyVersion)

when: "PBS processes auction request"
privacyPbsService.sendAuctionRequest(bidRequest)
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
assert vendorList.gvlSpecificationVersion == V3

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)

where:
tcfPolicyVersion << [TCF_POLICY_V4, TCF_POLICY_V5]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS cookie sync should process rule when geo doesn't intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + GEO_LOCATION +
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.geo-info.[0].country": countyConfig,
"geolocation.configurations.geo-info.[0].region" : regionConfig])

Expand Down Expand Up @@ -1830,7 +1830,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS setuid should process rule when geo doesn't intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + GEO_LOCATION +
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": countyConfig,
"geolocation.configurations.[0].geo-info.region" : regionConfig])

Expand Down Expand Up @@ -1885,7 +1885,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS cookie sync should disallowed rule when device.geo intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + GEO_LOCATION +
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": countyConfig,
"geolocation.configurations.[0].geo-info.region" : regionConfig])

Expand Down Expand Up @@ -1936,7 +1936,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS setuid should disallowed rule when device.geo intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + GEO_LOCATION +
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": countyConfig,
"geolocation.configurations.[0].geo-info.region" : regionConfig])

Expand Down Expand Up @@ -1986,7 +1986,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS cookie sync should fetch geo once when gpp sync user and account require geo look up"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + GEO_LOCATION +
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": USA.ISOAlpha3,
"geolocation.configurations.[0].geo-info.region" : ALABAMA.abbreviation])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,14 @@ abstract class PrivacyBaseSpec extends BaseSpec {
protected static final Integer MAX_INVALID_TCF_POLICY_VERSION = 63
protected static final Integer MIN_INVALID_TCF_POLICY_VERSION = 6

@Shared
protected final PrebidServerService privacyPbsService = pbsServiceFactory.getService(GDPR_VENDOR_LIST_CONFIG +
GENERIC_CONFIG + GENERIC_VENDOR_CONFIG + RETRY_POLICY_EXPONENTIAL_CONFIG + GDPR_EEA_COUNTRY)
protected static final Map<String, String> GENERAL_PRIVACY_CONFIG =
GENERIC_CONFIG + GDPR_VENDOR_LIST_CONFIG + GENERIC_VENDOR_CONFIG + RETRY_POLICY_EXPONENTIAL_CONFIG

protected static final Map<String, String> PBS_CONFIG = OPENX_CONFIG +
GENERIC_CONFIG + GDPR_VENDOR_LIST_CONFIG + SETTING_CONFIG + GENERIC_VENDOR_CONFIG
@Shared
protected final PrebidServerService privacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GDPR_EEA_COUNTRY)

@Shared
protected final PrebidServerService activityPbsService = pbsServiceFactory.getService(PBS_CONFIG)
protected final PrebidServerService activityPbsService = pbsServiceFactory.getService(OPENX_CONFIG + SETTING_CONFIG + GENERAL_PRIVACY_CONFIG)

def setupSpec() {
vendorListResponse.setResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TcfFullTransmitEidsActivitiesSpec extends PrivacyBaseSpec {
private static PrebidServerService privacyPbsServiceWithMultipleGvl

def setupSpec() {
privacyPbsContainerWithMultipleGvl = new PrebidServerContainer(PBS_CONFIG)
privacyPbsContainerWithMultipleGvl = new PrebidServerContainer(GENERAL_PRIVACY_CONFIG)
def prepareEncodeResponseBodyWithPurposesOnly = getVendorListContent(true, false, false)
def prepareEncodeResponseBodyWithLegIntPurposes = getVendorListContent(false, true, false)
def prepareEncodeResponseBodyWithLegIntAndFlexiblePurposes = getVendorListContent(false, true, true)
Expand Down
Loading