Skip to content

Commit 2e601ed

Browse files
marki1anLightwood13
authored andcommitted
Test: Allow duplicate cookie family names (#4360)
1 parent 2138989 commit 2e601ed

1 file changed

Lines changed: 73 additions & 10 deletions

File tree

src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import static org.prebid.server.functional.model.bidder.BidderName.ALIAS_CAMEL_C
2020
import static org.prebid.server.functional.model.bidder.BidderName.APPNEXUS
2121
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC
2222
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC_CAMEL_CASE
23+
import static org.prebid.server.functional.model.bidder.BidderName.GRID
2324
import static org.prebid.server.functional.model.bidder.BidderName.OPENX
25+
import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS
2426
import static org.prebid.server.functional.model.bidder.BidderName.RUBICON
2527
import static org.prebid.server.functional.model.bidder.BidderName.UNKNOWN
2628
import static org.prebid.server.functional.model.bidder.BidderName.WILDCARD
@@ -38,21 +40,50 @@ class SetUidSpec extends BaseSpec {
3840
private static final boolean CORS_SUPPORT = false
3941
private static final Integer RANDOM_EXPIRE_DAY = PBSUtils.getRandomNumber(1, 10)
4042
private static final String USER_SYNC_URL = "$networkServiceContainer.rootUri/generic-usersync"
41-
private static final Map<String, String> PBS_CONFIG =
42-
["host-cookie.max-cookie-size-bytes" : MAX_COOKIE_SIZE as String,
43-
"adapters.${RUBICON.value}.enabled" : "true",
44-
"adapters.${RUBICON.value}.usersync.cookie-family-name" : RUBICON.value,
45-
"adapters.${OPENX.value}.enabled" : "true",
46-
"adapters.${OPENX.value}.usersync.cookie-family-name" : OPENX.value,
47-
"adapters.${APPNEXUS.value}.enabled" : "true",
48-
"adapters.${APPNEXUS.value}.usersync.cookie-family-name" : APPNEXUS.value,
49-
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL,
50-
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.support-cors": CORS_SUPPORT.toString()]
43+
private static final String GENERIC_COOKIE_FAMILY_NAME = GENERIC.value
44+
private static final String VENDOR_ID = PBSUtils.randomNumber as String
5145
private static final Map<String, String> UID_COOKIES_CONFIG = ['setuid.number-of-uid-cookies': MAX_NUMBER_OF_UID_COOKIES.toString()]
5246
private static final Map<String, String> GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true",
5347
"adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()]
5448
private static final String TCF_ERROR_MESSAGE = "The gdpr_consent param prevents cookies from being saved"
5549
private static final int UNAVAILABLE_FOR_LEGAL_REASONS_CODE = 451
50+
private static final Map<String, String> PBS_CONFIG =
51+
["host-cookie.max-cookie-size-bytes" : MAX_COOKIE_SIZE as String,
52+
53+
"adapters.${RUBICON.value}.enabled" : "true",
54+
"adapters.${RUBICON.value}.usersync.cookie-family-name" : RUBICON.value,
55+
56+
"adapters.${OPENX.value}.enabled" : "true",
57+
"adapters.${OPENX.value}.usersync.cookie-family-name" : OPENX.value,
58+
59+
"adapters.${APPNEXUS.value}.enabled" : "true",
60+
"adapters.${APPNEXUS.value}.usersync.cookie-family-name" : APPNEXUS.value,
61+
62+
"adapters.${GENERIC.value}.meta-info.vendor-id" : VENDOR_ID,
63+
"adapters.${GENERIC.value}.usersync.cookie-family-name" : GENERIC_COOKIE_FAMILY_NAME,
64+
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL,
65+
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.support-cors" : CORS_SUPPORT.toString(),
66+
67+
"adapters.${GRID.value}.enabled" : "true",
68+
"adapters.${GRID.value}.meta-info.vendor-id" : VENDOR_ID,
69+
"adapters.${GRID.value}.usersync.cookie-family-name" : GENERIC_COOKIE_FAMILY_NAME,
70+
"adapters.${GRID.value}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL,
71+
"adapters.${GRID.value}.usersync.${USER_SYNC_TYPE.value}.support-cors" : CORS_SUPPORT.toString(),
72+
"adapters.${GRID.value}.usersync.${USER_SYNC_TYPE.value}.uid-macro" : "",
73+
74+
"adapters.${GENERIC}.aliases.${ALIAS}.enabled" : "true",
75+
"adapters.${GENERIC}.aliases.${ALIAS}.endpoint" : "$networkServiceContainer.rootUri/auction".toString(),
76+
"adapters.${GENERIC}.aliases.${ALIAS}.meta-info.vendor-id" : VENDOR_ID,
77+
"adapters.${GENERIC}.aliases.${ALIAS}.usersync.cookie-family-name" : GENERIC_COOKIE_FAMILY_NAME,
78+
"adapters.${GENERIC}.aliases.${ALIAS}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL,
79+
"adapters.${GENERIC}.aliases.${ALIAS}.usersync.${USER_SYNC_TYPE.value}.support-cors" : CORS_SUPPORT.toString(),
80+
81+
"adapters.${GENERIC}.aliases.${OPENX_ALIAS}.enabled" : "true",
82+
"adapters.${GENERIC}.aliases.${OPENX_ALIAS}.endpoint" : "$networkServiceContainer.rootUri/auction".toString(),
83+
"adapters.${GENERIC}.aliases.${OPENX_ALIAS}.meta-info.vendor-id" : VENDOR_ID,
84+
"adapters.${GENERIC}.aliases.${OPENX_ALIAS}.usersync.cookie-family-name" : GENERIC_COOKIE_FAMILY_NAME,
85+
"adapters.${GENERIC}.aliases.${OPENX_ALIAS}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL,
86+
"adapters.${GENERIC}.aliases.${OPENX_ALIAS}.usersync.${USER_SYNC_TYPE.value}.support-cors": CORS_SUPPORT.toString()]
5687

5788
@Shared
5889
PrebidServerService singleCookiesPbsService = pbsServiceFactory.getService(PBS_CONFIG + GENERIC_ALIAS_CONFIG)
@@ -513,6 +544,38 @@ class SetUidSpec extends BaseSpec {
513544
assert getSetUidsHeaders(response, true).size() == MAX_NUMBER_OF_UID_COOKIES
514545
}
515546

547+
def "PBS shouldn't failed with error when adapters has same user sync and vendor id config"() {
548+
given: "Default set uid request"
549+
def request = SetuidRequest.defaultSetuidRequest
550+
551+
and: "Default uids cookie generic and adtrgtme"
552+
def genericUidsCookie = UidsCookie.getDefaultUidsCookie(GENERIC)
553+
def gridUidsCookie = UidsCookie.getDefaultUidsCookie(GRID)
554+
555+
when: "PBS processes auction request"
556+
def response = singleCookiesPbsService.sendSetUidRequest(request, [gridUidsCookie, genericUidsCookie])
557+
558+
then: "Response should contain requested tempUIDs"
559+
assert response.uidsCookie.tempUIDs[GENERIC]
560+
assert response.uidsCookie.tempUIDs[GRID]
561+
}
562+
563+
def "PBS shouldn't failed with error when alias adapters has same user sync and vendor id config"() {
564+
given: "Default set uid request"
565+
def request = SetuidRequest.defaultSetuidRequest
566+
567+
and: "Default uids cookie generic alias and opnex alias"
568+
def genericAliasUidsCookie = UidsCookie.getDefaultUidsCookie(ALIAS)
569+
def genericOpenxAliasUidsCookie = UidsCookie.getDefaultUidsCookie(OPENX_ALIAS)
570+
571+
when: "PBS processes auction request"
572+
def response = singleCookiesPbsService.sendSetUidRequest(request, [genericAliasUidsCookie, genericOpenxAliasUidsCookie])
573+
574+
then: "Response should contain requested tempUIDs"
575+
assert response.uidsCookie.tempUIDs[ALIAS]
576+
assert response.uidsCookie.tempUIDs[OPENX_ALIAS]
577+
}
578+
516579
List<String> getSetUidsHeaders(SetuidResponse response, boolean includeEmpty = false) {
517580
response.headers.get("Set-Cookie").findAll { cookie ->
518581
includeEmpty || !(cookie =~ /\buids\d*=\s*;/)

0 commit comments

Comments
 (0)