Skip to content

Commit

Permalink
Update after review
Browse files Browse the repository at this point in the history
  • Loading branch information
marki1an committed Mar 20, 2024
1 parent 634a014 commit 3caa5ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class VendorList extends NetworkScaffolding {
void setResponse(TcfPolicyVersion tcfPolicyVersion = TCF_POLICY_V2,
Delay delay = null,
Map<Integer, Vendor> vendors = [(GENERIC_VENDOR_ID): Vendor.getDefaultVendor(GENERIC_VENDOR_ID)]) {
def prepareEndpoint = endpoint.replace("{TCF_POLICY}", "v" + tcfPolicyVersion.vendorListVersion)
def prepareEndpoint = endpoint.replace("{TCF_POLICY}", tcfPolicyVersion.vendorListVersion.toString())
def prepareEncodeResponseBody = encode(defaultVendorListResponse.tap {
it.tcfPolicyVersion = tcfPolicyVersion.vendorListVersion
it.vendors = vendors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class GdprAmpSpec extends PrivacyBaseSpec {
privacyPbsService.sendAmpRequest(ampRequest)

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = "/app/prebid-server/data/vendorlist-v${tcfPolicyVersion.vendorListVersion}/${tcfPolicyVersion.vendorListVersion}.json"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
assert vendorList.tcfPolicyVersion == tcfPolicyVersion.vendorListVersion
Expand Down Expand Up @@ -371,7 +371,7 @@ class GdprAmpSpec extends PrivacyBaseSpec {
["Parsing consent string: ${tcfConsent} failed. TCF policy version ${invalidTcfPolicyVersion} is not supported" as String]
}

def "PBS amp should try to fetch vendor list by exponential backoff and emit error when vendor list response is absent"() {
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"
def startTime = Instant.now()

Expand All @@ -397,13 +397,13 @@ class GdprAmpSpec extends PrivacyBaseSpec {
vendorListResponse.reset()

and: "Set vendor list response with delay"
vendorListResponse.setResponse(tcfPolicyVersion, Delay.seconds(3))
vendorListResponse.setResponse(tcfPolicyVersion, Delay.seconds(EXPONENTIAL_BACKOFF_MAX_DELAY + 3))

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

then: "PBS shouldn't fetch vendor list"
def vendorListPath = "/app/prebid-server/data/vendorlist-v${tcfPolicyVersion.vendorListVersion}/${tcfPolicyVersion.vendorListVersion}.json"
def vendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
assert !privacyPbsService.isFileExist(vendorListPath)

and: "Logs should contain proper vendor list version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
privacyPbsService.sendAuctionRequest(bidRequest)

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = "/app/prebid-server/data/vendorlist-v${tcfPolicyVersion.vendorListVersion}/${tcfPolicyVersion.vendorListVersion}.json"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
PBSUtils.waitUntil { privacyPbsService.isFileExist(properVendorListPath) }
def vendorList = privacyPbsService.getValueFromContainer(properVendorListPath, VendorListConsent.class)
assert vendorList.tcfPolicyVersion == tcfPolicyVersion.vendorListVersion
Expand Down Expand Up @@ -315,7 +315,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
["Parsing consent string: ${tcfConsent} failed. TCF policy version ${invalidTcfPolicyVersion} is not supported" as String]
}

def "PBS auction should try to fetch vendor list by exponential backoff and emit error when vendor list response is absent"() {
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"
def startTime = Instant.now()

Expand All @@ -334,13 +334,13 @@ class GdprAuctionSpec extends PrivacyBaseSpec {
vendorListResponse.reset()

and: "Set vendor list response with delay"
vendorListResponse.setResponse(tcfPolicyVersion, Delay.seconds(3))
vendorListResponse.setResponse(tcfPolicyVersion, Delay.seconds(EXPONENTIAL_BACKOFF_MAX_DELAY + 3))

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

then: "Used vendor list have proper specification version of GVL"
def properVendorListPath = "/app/prebid-server/data/vendorlist-v${tcfPolicyVersion.vendorListVersion}/${tcfPolicyVersion.vendorListVersion}.json"
def properVendorListPath = VENDOR_LIST_PATH.replace("{VendorVersion}", tcfPolicyVersion.vendorListVersion.toString())
assert !privacyPbsService.isFileExist(properVendorListPath)

and: "Logs should contain proper vendor list version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ import static org.prebid.server.functional.util.privacy.TcfConsent.TcfPolicyVers
abstract class PrivacyBaseSpec extends BaseSpec {

private static final int GEO_PRECISION = 2
@Shared
protected final PrebidServerService privacyPbsService = pbsServiceFactory.getService(GDPR_VENDOR_LIST_CONFIG +
GENERIC_COOKIE_SYNC_CONFIG + RETRY_POLICY_EXPONENTIAL_CONFIG +
["adapters.generic.meta-info.vendor-id": GENERIC_VENDOR_ID as String,
"gdpr.host-vendor-id" : GENERIC_VENDOR_ID as String,
"adapters.generic.ccpa-enforced" : "true"])

protected static final Map<String, String> GENERIC_COOKIE_SYNC_CONFIG = ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : "$networkServiceContainer.rootUri/generic-usersync".toString(),
"adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": false.toString()]
Expand All @@ -72,8 +66,8 @@ abstract class PrivacyBaseSpec extends BaseSpec {
"gdpr.vendorlist.v3.http-endpoint-template": "$networkServiceContainer.rootUri/v3/vendor-list.json".toString()]
protected static final Map<String, String> SETTING_CONFIG = ["settings.enforce-valid-account": 'true']
protected static final Map<String, String> GENERIC_VENDOR_CONFIG = ["adapters.generic.meta-info.vendor-id": GENERIC_VENDOR_ID as String,
"gdpr.host-vendor-id" : GENERIC_VENDOR_ID as String,
"adapters.generic.ccpa-enforced" : "true"]
"gdpr.host-vendor-id" : GENERIC_VENDOR_ID as String,
"adapters.generic.ccpa-enforced" : "true"]

@Shared
protected static final int PURPOSES_ONLY_GVL_VERSION = PBSUtils.getRandomNumber(0, 4095)
Expand All @@ -84,25 +78,29 @@ abstract class PrivacyBaseSpec extends BaseSpec {
@Shared
protected static final int PURPOSES_AND_LEG_INT_PURPOSES_GVL_VERSION = PBSUtils.getRandomNumberWithExclusion([PURPOSES_ONLY_GVL_VERSION, LEG_INT_PURPOSES_ONLY_GVL_VERSION, LEG_INT_AND_FLEXIBLE_PURPOSES_GVL_VERSION], 0, 4095)

static final Map<String, String> RETRY_POLICY_EXPONENTIAL_CONFIG = [
protected static final int EXPONENTIAL_BACKOFF_MAX_DELAY = 1

private static final Map<String, String> RETRY_POLICY_EXPONENTIAL_CONFIG = [
"gdpr.vendorlist.v2.retry-policy.exponential-backoff.delay-millis" : 1 as String,
"gdpr.vendorlist.v2.retry-policy.exponential-backoff.max-delay-millis": 1 as String,
"gdpr.vendorlist.v2.retry-policy.exponential-backoff.max-delay-millis": EXPONENTIAL_BACKOFF_MAX_DELAY as String,
"gdpr.vendorlist.v2.retry-policy.exponential-backoff.factor" : Long.MAX_VALUE as String,
"gdpr.vendorlist.v3.retry-policy.exponential-backoff.delay-millis" : 1 as String,
"gdpr.vendorlist.v3.retry-policy.exponential-backoff.max-delay-millis": 1 as String,
"gdpr.vendorlist.v3.retry-policy.exponential-backoff.max-delay-millis": EXPONENTIAL_BACKOFF_MAX_DELAY as String,
"gdpr.vendorlist.v3.retry-policy.exponential-backoff.factor" : Long.MAX_VALUE as String]
private static final Map<String, String> SETTING_CONFIG = ["settings.enforce-valid-account": 'true']

private static final PbsPgConfig pgConfig = new PbsPgConfig(networkServiceContainer)

protected static final Map<String, String> PBS_CONFIG = OPENX_CONFIG + OPENX_COOKIE_SYNC_CONFIG +
GENERIC_COOKIE_SYNC_CONFIG + pgConfig.properties + GDPR_VENDOR_LIST_CONFIG + SETTING_CONFIG + GENERIC_VENDOR_CONFIG
protected static final String VENDOR_LIST_PATH = "/app/prebid-server/data/vendorlist-v{VendorVersion}/{VendorVersion}.json"
protected static final String VALID_VALUE_FOR_GPC_HEADER = "1"
protected static final GppConsent SIMPLE_GPC_DISALLOW_LOGIC = new UspNatV1Consent.Builder().setGpc(true).build()
protected static final VendorList vendorListResponse = new VendorList(networkServiceContainer)

@Shared
protected final PrebidServerService privacyPbsService = pbsServiceFactory.getService(GDPR_VENDOR_LIST_CONFIG +
GENERIC_COOKIE_SYNC_CONFIG + GENERIC_VENDOR_CONFIG)
GENERIC_COOKIE_SYNC_CONFIG + GENERIC_VENDOR_CONFIG + RETRY_POLICY_EXPONENTIAL_CONFIG)

protected static final Map<String, String> PBS_CONFIG = OPENX_CONFIG + OPENX_COOKIE_SYNC_CONFIG +
GENERIC_COOKIE_SYNC_CONFIG + pgConfig.properties + GDPR_VENDOR_LIST_CONFIG + SETTING_CONFIG + GENERIC_VENDOR_CONFIG

@Shared
protected final PrebidServerService activityPbsService = pbsServiceFactory.getService(PBS_CONFIG)
Expand Down

0 comments on commit 3caa5ec

Please sign in to comment.