Skip to content

Commit 19d25f3

Browse files
authored
Update privacy functional test: GVL file handling (prebid#3644)
1 parent 2a59c20 commit 19d25f3

File tree

6 files changed

+74
-59
lines changed

6 files changed

+74
-59
lines changed

src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec {
121121
accountDao.save(account)
122122

123123
when: "PBS processes auction requests"
124-
def bidResponse = pbsServiceFactory.getService(PBS_CONFIG).sendAuctionRequest(bidRequest)
124+
def bidResponse = activityPbsService.sendAuctionRequest(bidRequest)
125125

126126
then: "Bid response should contain basic info in debug"
127127
def infrastructure = bidResponse.ext.debug.trace.activityInfrastructure

src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import org.prebid.server.functional.model.request.auction.BidRequest
1313
import org.prebid.server.functional.model.request.auction.DistributionChannel
1414
import org.prebid.server.functional.model.request.auction.Regs
1515
import org.prebid.server.functional.model.request.auction.RegsExt
16-
import org.prebid.server.functional.service.PrebidServerService
17-
import org.prebid.server.functional.testcontainers.container.PrebidServerContainer
1816
import org.prebid.server.functional.util.PBSUtils
1917
import org.prebid.server.functional.util.privacy.BogusConsent
2018
import org.prebid.server.functional.util.privacy.CcpaConsent
@@ -320,10 +318,8 @@ class GdprAmpSpec extends PrivacyBaseSpec {
320318
def startTime = Instant.now()
321319

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

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

349345
when: "PBS processes amp request"
350-
privacyPbsService.sendAmpRequest(ampRequest)
346+
defaultPrivacyPbsService.sendAmpRequest(ampRequest)
351347

352348
then: "Used vendor list have proper specification version of GVL"
353349
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
354-
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
355-
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
350+
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
351+
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
356352
assert vendorList.tcfPolicyVersion == tcfPolicyVersion.vendorListVersion
357353

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

363-
cleanup: "Stop container with default request"
364-
serverContainer.stop()
359+
cleanup: "Stop and remove pbs container"
360+
pbsServiceFactory.removeContainer(config)
365361

366362
where:
367363
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
@@ -410,7 +406,10 @@ class GdprAmpSpec extends PrivacyBaseSpec {
410406
}
411407

412408
def "PBS amp should emit the same error without a second GVL list request if a retry is too soon for the exponential-backoff"() {
413-
given: "Test start time"
409+
given: "Prebid server with privacy settings"
410+
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)
411+
412+
and: "Test start time"
414413
def startTime = Instant.now()
415414

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

440439
when: "PBS processes amp request"
441-
privacyPbsService.sendAmpRequest(ampRequest)
440+
defaultPrivacyPbsService.sendAmpRequest(ampRequest)
442441

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

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

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

455454
when: "PBS processes amp request"
456-
privacyPbsService.sendAmpRequest(ampRequest)
455+
defaultPrivacyPbsService.sendAmpRequest(ampRequest)
457456

458457
then: "PBS shouldn't fetch vendor list"
459-
assert !privacyPbsService.isFileExist(vendorListPath)
458+
assert !defaultPrivacyPbsService.isFileExist(vendorListPath)
460459

461460
and: "Logs should contain proper vendor list version"
462-
def logsSecond = privacyPbsService.getLogsByTime(secondStartTime)
461+
def logsSecond = defaultPrivacyPbsService.getLogsByTime(secondStartTime)
463462
assert getLogsByText(logsSecond, tcfError)
464463

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

467+
cleanup: "Stop and remove pbs container"
468+
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)
469+
468470
where:
469471
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
470472
}
@@ -659,7 +661,10 @@ class GdprAmpSpec extends PrivacyBaseSpec {
659661
}
660662

661663
def "PBS amp should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() {
662-
given: "Tcf consent setup"
664+
given: "Prebid server with privacy settings"
665+
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)
666+
667+
and: "Tcf consent setup"
663668
def tcfConsent = new TcfConsent.Builder()
664669
.setPurposesLITransparency(BASIC_ADS)
665670
.setTcfPolicyVersion(tcfPolicyVersion.value)
@@ -681,14 +686,17 @@ class GdprAmpSpec extends PrivacyBaseSpec {
681686
vendorListResponse.setResponse(tcfPolicyVersion)
682687

683688
when: "PBS processes amp request"
684-
privacyPbsService.sendAmpRequest(ampRequest)
689+
defaultPrivacyPbsService.sendAmpRequest(ampRequest)
685690

686691
then: "Used vendor list have proper specification version of GVL"
687692
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
688-
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
689-
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
693+
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
694+
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
690695
assert vendorList.gvlSpecificationVersion == V3
691696

697+
cleanup: "Stop and remove pbs container"
698+
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)
699+
692700
where:
693701
tcfPolicyVersion << [TCF_POLICY_V4, TCF_POLICY_V5]
694702
}

src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAuctionSpec.groovy

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import org.prebid.server.functional.model.request.auction.DistributionChannel
1010
import org.prebid.server.functional.model.request.auction.Regs
1111
import org.prebid.server.functional.model.request.auction.RegsExt
1212
import org.prebid.server.functional.model.response.auction.ErrorType
13-
import org.prebid.server.functional.service.PrebidServerService
14-
import org.prebid.server.functional.testcontainers.container.PrebidServerContainer
1513
import org.prebid.server.functional.util.PBSUtils
1614
import org.prebid.server.functional.util.privacy.BogusConsent
1715
import org.prebid.server.functional.util.privacy.TcfConsent
@@ -278,10 +276,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
278276
def startTime = Instant.now()
279277

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

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

300296
when: "PBS processes auction request"
301-
privacyPbsService.sendAuctionRequest(bidRequest)
297+
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)
302298

303299
then: "Used vendor list have proper specification version of GVL"
304300
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
305-
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
306-
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
301+
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
302+
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
307303
assert vendorList.tcfPolicyVersion == tcfPolicyVersion.vendorListVersion
308304

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

314-
cleanup: "Stop container with default request"
315-
serverContainer.stop()
310+
cleanup: "Stop and remove pbs container"
311+
pbsServiceFactory.removeContainer(config)
316312

317313
where:
318314
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
@@ -357,7 +353,10 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
357353
}
358354

359355
def "PBS auction should emit the same error without a second GVL list request if a retry is too soon for the exponential-backoff"() {
360-
given: "Test start time"
356+
given: "Prebid server with privacy settings"
357+
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)
358+
359+
and: "Test start time"
361360
def startTime = Instant.now()
362361

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

380379
when: "PBS processes auction request"
381-
privacyPbsService.sendAuctionRequest(bidRequest)
380+
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)
382381

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

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

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

395394
when: "PBS processes amp request"
396-
privacyPbsService.sendAuctionRequest(bidRequest)
395+
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)
397396

398397
then: "PBS shouldn't fetch vendor list"
399-
assert !privacyPbsService.isFileExist(properVendorListPath)
398+
assert !defaultPrivacyPbsService.isFileExist(properVendorListPath)
400399

401400
and: "Logs should contain proper vendor list version"
402-
def logsSecond = privacyPbsService.getLogsByTime(secondStartTime)
401+
def logsSecond = defaultPrivacyPbsService.getLogsByTime(secondStartTime)
403402
assert getLogsByText(logsSecond, tcfError)
404403

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

407+
cleanup: "Stop and remove pbs container"
408+
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)
409+
408410
where:
409411
tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5]
410412
}
@@ -783,7 +785,10 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
783785
}
784786

785787
def "PBS auction should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() {
786-
given: "Tcf consent setup"
788+
given: "Prebid server with privacy settings"
789+
def defaultPrivacyPbsService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG)
790+
791+
and: "Tcf consent setup"
787792
def tcfConsent = new TcfConsent.Builder()
788793
.setPurposesLITransparency(BASIC_ADS)
789794
.setTcfPolicyVersion(tcfPolicyVersion.value)
@@ -798,14 +803,17 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
798803
vendorListResponse.setResponse(tcfPolicyVersion)
799804

800805
when: "PBS processes auction request"
801-
privacyPbsService.sendAuctionRequest(bidRequest)
806+
defaultPrivacyPbsService.sendAuctionRequest(bidRequest)
802807

803808
then: "Used vendor list have proper specification version of GVL"
804809
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
805-
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
806-
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
810+
PBSUtils.waitUntil { defaultPrivacyPbsService.isFileExist(properVendorListPath) }
811+
def vendorList = defaultPrivacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
807812
assert vendorList.gvlSpecificationVersion == V3
808813

814+
cleanup: "Stop and remove pbs container"
815+
pbsServiceFactory.removeContainer(GENERAL_PRIVACY_CONFIG)
816+
809817
where:
810818
tcfPolicyVersion << [TCF_POLICY_V4, TCF_POLICY_V5]
811819
}

src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
17781778

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

@@ -1830,7 +1830,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
18301830

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

@@ -1885,7 +1885,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
18851885

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

@@ -1936,7 +1936,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
19361936

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

@@ -1986,7 +1986,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
19861986

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

src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,14 @@ abstract class PrivacyBaseSpec extends BaseSpec {
106106
protected static final Integer MAX_INVALID_TCF_POLICY_VERSION = 63
107107
protected static final Integer MIN_INVALID_TCF_POLICY_VERSION = 6
108108

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

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

116115
@Shared
117-
protected final PrebidServerService activityPbsService = pbsServiceFactory.getService(PBS_CONFIG)
116+
protected final PrebidServerService activityPbsService = pbsServiceFactory.getService(OPENX_CONFIG + SETTING_CONFIG + GENERAL_PRIVACY_CONFIG)
118117

119118
def setupSpec() {
120119
vendorListResponse.setResponse()

src/test/groovy/org/prebid/server/functional/tests/privacy/TcfFullTransmitEidsActivitiesSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TcfFullTransmitEidsActivitiesSpec extends PrivacyBaseSpec {
2525
private static PrebidServerService privacyPbsServiceWithMultipleGvl
2626

2727
def setupSpec() {
28-
privacyPbsContainerWithMultipleGvl = new PrebidServerContainer(PBS_CONFIG)
28+
privacyPbsContainerWithMultipleGvl = new PrebidServerContainer(GENERAL_PRIVACY_CONFIG)
2929
def prepareEncodeResponseBodyWithPurposesOnly = getVendorListContent(true, false, false)
3030
def prepareEncodeResponseBodyWithLegIntPurposes = getVendorListContent(false, true, false)
3131
def prepareEncodeResponseBodyWithLegIntAndFlexiblePurposes = getVendorListContent(false, true, true)

0 commit comments

Comments
 (0)