From f5d3da7b778592587c7affa0d9aba39ff9b0c5a3 Mon Sep 17 00:00:00 2001 From: Danylo Date: Thu, 10 Oct 2024 01:59:36 +0200 Subject: [PATCH 1/2] Update TCF policy version validation. --- .../privacy/gdpr/TcfDefinerService.java | 16 ++++++--- .../VersionedVendorListService.java | 5 --- .../config/PrivacyServiceConfiguration.java | 6 ++-- .../privacy/gdpr/TcfDefinerServiceTest.java | 34 ++++++++++++------- .../VersionedVendorListServiceTest.java | 21 ++---------- 5 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java b/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java index 8836fbaa24c..b02698bbce3 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/TcfDefinerService.java @@ -66,6 +66,7 @@ public class TcfDefinerService { private final BidderCatalog bidderCatalog; private final IpAddressHelper ipAddressHelper; private final Metrics metrics; + private final double samplingRate; public TcfDefinerService(GdprConfig gdprConfig, Set eeaCountries, @@ -73,7 +74,8 @@ public TcfDefinerService(GdprConfig gdprConfig, GeoLocationServiceWrapper geoLocationServiceWrapper, BidderCatalog bidderCatalog, IpAddressHelper ipAddressHelper, - Metrics metrics) { + Metrics metrics, + double samplingRate) { this.gdprEnabled = gdprConfig != null && BooleanUtils.isNotFalse(gdprConfig.getEnabled()); this.gdprDefaultValue = gdprConfig != null ? gdprConfig.getDefaultValue() : null; @@ -85,6 +87,7 @@ public TcfDefinerService(GdprConfig gdprConfig, this.bidderCatalog = Objects.requireNonNull(bidderCatalog); this.ipAddressHelper = Objects.requireNonNull(ipAddressHelper); this.metrics = Objects.requireNonNull(metrics); + this.samplingRate = samplingRate; } /** @@ -360,11 +363,14 @@ private TCStringParsingResult toValidResult(String consentString, TCStringParsin } final int tcfPolicyVersion = tcString.getTcfPolicyVersion(); - // disable support for tcf policy version > 5 + // support for tcf policy version > 5 if (tcfPolicyVersion > 5) { - warnings.add("Parsing consent string: %s failed. TCF policy version %d is not supported".formatted( - consentString, tcfPolicyVersion)); - return TCStringParsingResult.of(TCStringEmpty.create(), warnings); + metrics.updateAlertsMetrics(MetricName.general); + + final String message = "Unknown tcfPolicyVersion %s, defaulting to gvlSpecificationVersion=3" + .formatted(tcfPolicyVersion); + UNDEFINED_CORRUPT_CONSENT_LOGGER.warn(message, samplingRate); + warnings.add(message); } return TCStringParsingResult.of(tcString, warnings); diff --git a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListService.java b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListService.java index d0b6057e41a..5e261d9b6b4 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListService.java @@ -2,7 +2,6 @@ import com.iabtcf.decoder.TCString; import io.vertx.core.Future; -import org.prebid.server.exception.PreBidException; import org.prebid.server.privacy.gdpr.vendorlist.proto.Vendor; import java.util.Map; @@ -21,10 +20,6 @@ public VersionedVendorListService(VendorListService vendorListServiceV2, VendorL public Future> forConsent(TCString consent) { final int tcfPolicyVersion = consent.getTcfPolicyVersion(); final int vendorListVersion = consent.getVendorListVersion(); - if (tcfPolicyVersion > 5) { - return Future.failedFuture(new PreBidException( - "Invalid tcf policy version: %d".formatted(tcfPolicyVersion))); - } return tcfPolicyVersion < 4 ? vendorListServiceV2.forVersion(vendorListVersion) diff --git a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java index d9ac686d861..c7cac1ecf64 100644 --- a/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/PrivacyServiceConfiguration.java @@ -164,7 +164,8 @@ TcfDefinerService tcfDefinerService( GeoLocationServiceWrapper geoLocationServiceWrapper, BidderCatalog bidderCatalog, IpAddressHelper ipAddressHelper, - Metrics metrics) { + Metrics metrics, + @Value("${logging.sampling-rate:0.01}") double samplingRate) { final Set eeaCountries = new HashSet<>(Arrays.asList(eeaCountriesAsString.trim().split(","))); @@ -175,7 +176,8 @@ TcfDefinerService tcfDefinerService( geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + samplingRate); } @Bean diff --git a/src/test/java/org/prebid/server/privacy/gdpr/TcfDefinerServiceTest.java b/src/test/java/org/prebid/server/privacy/gdpr/TcfDefinerServiceTest.java index 4b33f28c350..e63ad8f530d 100644 --- a/src/test/java/org/prebid/server/privacy/gdpr/TcfDefinerServiceTest.java +++ b/src/test/java/org/prebid/server/privacy/gdpr/TcfDefinerServiceTest.java @@ -85,7 +85,8 @@ public void setUp() { geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); } @Test @@ -99,7 +100,8 @@ public void resolveTcfContextShouldReturnContextWhenGdprIsDisabled() { geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); // when final Future result = target.resolveTcfContext( @@ -177,7 +179,8 @@ public void resolveTcfContextShouldCheckServiceConfigValueWhenRequestTypeIsUnkno geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); final AccountGdprConfig accountGdprConfig = AccountGdprConfig.builder() .enabledForRequestType(EnabledForRequestType.of(true, true, true, true, true)) @@ -209,7 +212,8 @@ public void resolveTcfContextShouldConsiderTcfVersionOneAsCorruptedVersionTwo() geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); final String vendorConsent = "BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA"; @@ -227,7 +231,7 @@ public void resolveTcfContextShouldConsiderTcfVersionOneAsCorruptedVersionTwo() } @Test - public void resolveTcfContextShouldTreatTcfConsentWithTcfPolicyVersionGreaterThanFourAsCorrupted() { + public void resolveTcfContextShouldEmitWarningOnTcfConsentWithTcfPolicyVersionGreaterThanFive() { // given final GdprConfig gdprConfig = GdprConfig.builder() .enabled(true) @@ -241,7 +245,8 @@ public void resolveTcfContextShouldTreatTcfConsentWithTcfPolicyVersionGreaterTha geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); final String vendorConsent = TCStringEncoder.newBuilder() .version(2) @@ -260,11 +265,13 @@ public void resolveTcfContextShouldTreatTcfConsentWithTcfPolicyVersionGreaterTha null); // then - final String expectedWarning = "Parsing consent string: %s failed. TCF policy version 6 is not supported" - .formatted(vendorConsent); + final String expectedWarning = "Unknown tcfPolicyVersion 6, defaulting to gvlSpecificationVersion=3"; assertThat(result).isSucceeded(); - assertThat(result.result().getConsent()).isInstanceOf(TCStringEmpty.class); + assertThat(result.result().getConsent()) + .extracting(TCString::getVersion, TCString::getTcfPolicyVersion) + .containsExactly(2, 6); assertThat(result.result().getWarnings()).containsExactly(expectedWarning); + verify(metrics).updateAlertsMetrics(eq(MetricName.general)); } @Test @@ -282,7 +289,8 @@ public void resolveTcfContextShouldConsiderPresenceOfConsentStringAsInScope() { geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); final String vendorConsent = "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA"; @@ -323,7 +331,8 @@ public void resolveTcfContextShouldUseEeaListFromAccountConfig() { geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); final String vendorConsent = "CPBCa-mPBCa-mAAAAAENA0CAAEAAAAAAACiQAaQAwAAgAgABoAAAAAA"; @@ -442,7 +451,8 @@ public void resolveTcfContextShouldConsultDefaultValueWhenGeoLookupFailed() { geoLocationServiceWrapper, bidderCatalog, ipAddressHelper, - metrics); + metrics, + 0.01); given(geoLocationServiceWrapper.doLookup(anyString(), any(), any())).willReturn(Future.failedFuture("Bad ip")); diff --git a/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListServiceTest.java b/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListServiceTest.java index 03a538d2f58..c6ae182fabc 100644 --- a/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListServiceTest.java +++ b/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VersionedVendorListServiceTest.java @@ -11,7 +11,6 @@ import java.util.concurrent.ThreadLocalRandom; import static org.mockito.Mockito.verify; -import static org.prebid.server.assertion.FutureAssertion.assertThat; @ExtendWith(MockitoExtension.class) public class VersionedVendorListServiceTest { @@ -46,9 +45,9 @@ public void versionedVendorListServiceShouldTreatTcfPolicyLessThanFourAsVendorLi } @Test - public void versionedVendorListServiceShouldTreatTcfPolicyFourAsVendorListSpecificationThree() { + public void versionedVendorListServiceShouldTreatTcfPolicyGreaterOrEqualFourAsVendorListSpecificationThree() { // given - final int tcfPolicyVersion = ThreadLocalRandom.current().nextInt(4, 6); + final int tcfPolicyVersion = ThreadLocalRandom.current().nextInt(4, 100); final TCString consent = TCStringEncoder.newBuilder() .version(2) .tcfPolicyVersion(tcfPolicyVersion) @@ -61,20 +60,4 @@ public void versionedVendorListServiceShouldTreatTcfPolicyFourAsVendorListSpecif // then verify(vendorListServiceV3).forVersion(12); } - - @Test - public void versionedVendorListServiceShouldTreatTcfPolicyGreaterThanFourAsInvalidVersion() { - // given - final int tcfPolicyVersion = ThreadLocalRandom.current().nextInt(6, 63); - final TCString consent = TCStringEncoder.newBuilder() - .version(2) - .tcfPolicyVersion(tcfPolicyVersion) - .vendorListVersion(12) - .toTCString(); - - // when and then - assertThat(versionedVendorListService.forConsent(consent)) - .isFailed() - .hasMessage("Invalid tcf policy version: " + tcfPolicyVersion); - } } From 85af9b2e755d5c701fad17259a98871b5a3c34cf Mon Sep 17 00:00:00 2001 From: Markiyan Mykush <95693607+marki1an@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:31:43 +0300 Subject: [PATCH 2/2] Test: Update tcf policy version (#3500) --- .../scaffolding/VendorList.groovy | 3 + .../tests/privacy/GdprAmpSpec.groovy | 60 +++++++++++++++++-- .../tests/privacy/GdprAuctionSpec.groovy | 54 +++++++++++++++-- .../tests/privacy/PrivacyBaseSpec.groovy | 2 + .../util/privacy/VendorListConsent.groovy | 3 +- 5 files changed, 112 insertions(+), 10 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/VendorList.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/VendorList.groovy index 3f84faa7c44..343a118f53a 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/VendorList.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/VendorList.groovy @@ -10,6 +10,8 @@ import org.testcontainers.containers.MockServerContainer import static org.mockserver.model.HttpRequest.request import static org.mockserver.model.HttpResponse.response import static org.mockserver.model.HttpStatusCode.OK_200 +import static org.prebid.server.functional.model.mock.services.vendorlist.GvlSpecificationVersion.V2 +import static org.prebid.server.functional.model.mock.services.vendorlist.GvlSpecificationVersion.V3 import static org.prebid.server.functional.model.mock.services.vendorlist.VendorListResponse.Vendor import static org.prebid.server.functional.model.mock.services.vendorlist.VendorListResponse.getDefaultVendorListResponse import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID @@ -46,6 +48,7 @@ class VendorList extends NetworkScaffolding { def prepareEncodeResponseBody = encode(defaultVendorListResponse.tap { it.tcfPolicyVersion = tcfPolicyVersion.vendorListVersion it.vendors = vendors + it.gvlSpecificationVersion = tcfPolicyVersion >= TcfPolicyVersion.TCF_POLICY_V4 ? V3 : V2 }) mockServerClient.when(request().withPath(prepareEndpoint), Times.unlimited(), TimeToLive.unlimited(), -10) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy index 470029c9e02..d4cfc7bbda9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy @@ -26,6 +26,7 @@ import static org.prebid.server.functional.model.config.Purpose.P2 import static org.prebid.server.functional.model.config.Purpose.P4 import static org.prebid.server.functional.model.config.PurposeEnforcement.BASIC import static org.prebid.server.functional.model.config.PurposeEnforcement.NO +import static org.prebid.server.functional.model.mock.services.vendorlist.GvlSpecificationVersion.V3 import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.amp.ConsentType.BOGUS @@ -360,11 +361,12 @@ class GdprAmpSpec extends PrivacyBaseSpec { tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5] } - def "PBS amp with invalid consent.tcfPolicyVersion parameter should reject request and include proper warning"() { - given: "Tcf consent string" - def invalidTcfPolicyVersion = PBSUtils.getRandomNumber(5, 63) + def "PBS amp shouldn't reject request with proper warning and metrics when incoming consent.tcfPolicyVersion have invalid parameter"() { + given: "Tcf consent string with invalid tcf policy version" def tcfConsent = new TcfConsent.Builder() + .setPurposesLITransparency(BASIC_ADS) .setTcfPolicyVersion(invalidTcfPolicyVersion) + .setVendorLegitimateInterest([GENERIC_VENDOR_ID]) .build() and: "AMP request" @@ -377,13 +379,28 @@ class GdprAmpSpec extends PrivacyBaseSpec { def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) storedRequestDao.save(storedRequest) + and: "Flush metrics" + flushMetrics(privacyPbsService) + when: "PBS processes amp request" def response = privacyPbsService.sendAmpRequest(ampRequest) then: "Bid response should contain warning" assert response.ext?.warnings[PREBID]*.code == [999] assert response.ext?.warnings[PREBID]*.message == - ["Parsing consent string: ${tcfConsent} failed. TCF policy version ${invalidTcfPolicyVersion} is not supported" as String] + ["Unknown tcfPolicyVersion ${invalidTcfPolicyVersion}, defaulting to gvlSpecificationVersion=3" as String] + + and: "Alerts.general metrics should be populated" + def metrics = privacyPbsService.sendCollectedMetricsRequest() + assert metrics["alerts.general"] == 1 + + and: "Bidder should be called" + assert bidder.getBidderRequest(ampStoredRequest.id) + + where: + invalidTcfPolicyVersion << [MIN_INVALID_TCF_POLICY_VERSION, + PBSUtils.getRandomNumber(MIN_INVALID_TCF_POLICY_VERSION, MAX_INVALID_TCF_POLICY_VERSION), + MAX_INVALID_TCF_POLICY_VERSION] } def "PBS amp should emit the same error without a second GVL list request if a retry is too soon for the exponential-backoff"() { @@ -634,4 +651,39 @@ class GdprAmpSpec extends PrivacyBaseSpec { assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] } + + def "PBS amp should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() { + given: "Tcf consent setup" + def tcfConsent = new TcfConsent.Builder() + .setPurposesLITransparency(BASIC_ADS) + .setTcfPolicyVersion(tcfPolicyVersion.value) + .setVendorListVersion(tcfPolicyVersion.vendorListVersion) + .setVendorLegitimateInterest([GENERIC_VENDOR_ID]) + .build() + + and: "AMP request" + def ampRequest = getGdprAmpRequest(tcfConsent) + + and: "Default stored request" + def ampStoredRequest = BidRequest.defaultStoredRequest + + and: "Stored request in DB" + def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) + storedRequestDao.save(storedRequest) + + and: "Set vendor list response" + vendorListResponse.setResponse(tcfPolicyVersion) + + when: "PBS processes amp request" + privacyPbsService.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) + assert vendorList.gvlSpecificationVersion == V3 + + where: + tcfPolicyVersion << [TCF_POLICY_V4, TCF_POLICY_V5] + } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAuctionSpec.groovy index 72cd60c2b32..c4a21342ab9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAuctionSpec.groovy @@ -6,7 +6,6 @@ import org.prebid.server.functional.model.config.AccountGdprConfig import org.prebid.server.functional.model.config.PurposeConfig import org.prebid.server.functional.model.config.PurposeEnforcement import org.prebid.server.functional.model.request.auction.DistributionChannel -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 @@ -25,6 +24,7 @@ import static org.prebid.server.functional.model.config.Purpose.P1 import static org.prebid.server.functional.model.config.Purpose.P2 import static org.prebid.server.functional.model.config.Purpose.P4 import static org.prebid.server.functional.model.config.PurposeEnforcement.NO +import static org.prebid.server.functional.model.mock.services.vendorlist.GvlSpecificationVersion.V3 import static org.prebid.server.functional.model.pricefloors.Country.BULGARIA import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA @@ -314,11 +314,12 @@ class GdprAuctionSpec extends PrivacyBaseSpec { tcfPolicyVersion << [TCF_POLICY_V2, TCF_POLICY_V4, TCF_POLICY_V5] } - def "PBS auction should reject request with proper warning when incoming consent.tcfPolicyVersion have invalid parameter"() { - given: "Tcf consent string" - def invalidTcfPolicyVersion = PBSUtils.getRandomNumber(5, 63) + def "PBS auction shouldn't reject request with proper warning and metrics when incoming consent.tcfPolicyVersion have invalid parameter"() { + given: "Tcf consent string with invalid tcf policy version" def tcfConsent = new TcfConsent.Builder() + .setPurposesLITransparency(BASIC_ADS) .setTcfPolicyVersion(invalidTcfPolicyVersion) + .setVendorLegitimateInterest([GENERIC_VENDOR_ID]) .build() and: "Bid request" @@ -333,7 +334,22 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "Bid response should contain warning" assert response.ext?.warnings[ErrorType.PREBID]*.code == [999] assert response.ext?.warnings[ErrorType.PREBID]*.message == - ["Parsing consent string: ${tcfConsent} failed. TCF policy version ${invalidTcfPolicyVersion} is not supported" as String] + ["Unknown tcfPolicyVersion ${invalidTcfPolicyVersion}, defaulting to gvlSpecificationVersion=3" as String] + + and: "Alerts.general metrics should be populated" + def metrics = privacyPbsService.sendCollectedMetricsRequest() + assert metrics["alerts.general"] == 1 + + and: "Bid response should contain seatBid" + assert response.seatbid.size() == 1 + + and: "Bidder should be called" + assert bidder.getBidderRequest(bidRequest.id) + + where: + invalidTcfPolicyVersion << [MIN_INVALID_TCF_POLICY_VERSION, + PBSUtils.getRandomNumber(MIN_INVALID_TCF_POLICY_VERSION, MAX_INVALID_TCF_POLICY_VERSION), + MAX_INVALID_TCF_POLICY_VERSION] } def "PBS auction should emit the same error without a second GVL list request if a retry is too soon for the exponential-backoff"() { @@ -761,4 +777,32 @@ class GdprAuctionSpec extends PrivacyBaseSpec { assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] } + + def "PBS auction should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() { + given: "Tcf consent setup" + def tcfConsent = new TcfConsent.Builder() + .setPurposesLITransparency(BASIC_ADS) + .setTcfPolicyVersion(tcfPolicyVersion.value) + .setVendorListVersion(tcfPolicyVersion.vendorListVersion) + .setVendorLegitimateInterest([GENERIC_VENDOR_ID]) + .build() + + and: "Bid request" + def bidRequest = getGdprBidRequest(tcfConsent) + + and: "Set vendor list response" + vendorListResponse.setResponse(tcfPolicyVersion) + + when: "PBS processes auction request" + privacyPbsService.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) + assert vendorList.gvlSpecificationVersion == V3 + + where: + tcfPolicyVersion << [TCF_POLICY_V4, TCF_POLICY_V5] + } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy index 7e5774829bd..145a33336f9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy @@ -103,6 +103,8 @@ abstract class PrivacyBaseSpec extends BaseSpec { protected static final String VALID_VALUE_FOR_GPC_HEADER = "1" protected static final GppConsent SIMPLE_GPC_DISALLOW_LOGIC = new UsNatV1Consent.Builder().setGpc(true).build() protected static final VendorList vendorListResponse = new VendorList(networkServiceContainer) + 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 + diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/VendorListConsent.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/VendorListConsent.groovy index 6cdb42568ed..4ea50effbce 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/VendorListConsent.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/VendorListConsent.groovy @@ -1,11 +1,12 @@ package org.prebid.server.functional.util.privacy import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import org.prebid.server.functional.model.mock.services.vendorlist.GvlSpecificationVersion @JsonIgnoreProperties(ignoreUnknown = true) class VendorListConsent { Integer vendorListVersion Integer tcfPolicyVersion - Integer gvlSpecificationVersion + GvlSpecificationVersion gvlSpecificationVersion }