diff --git a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy index b868962a4a4..76484547f72 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy @@ -329,7 +329,7 @@ class CookieSyncSpec extends BaseSpec { assert !response.getBidderUserSync(GENERIC) } - def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder synced as family"() { + def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder synced"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS def prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG @@ -338,7 +338,7 @@ class CookieSyncSpec extends BaseSpec { and: "Cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - bidders = null + bidders = [bidderAlias] coopSync = true } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy index 9a71d42ba7f..ee875bf859b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy @@ -135,7 +135,7 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update metrics for new saved text storage cache" def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_SIZE_TEXT] == new String(encodeBase64(encode(targetingResult).bytes)).size() + assert metrics[METRIC_CREATIVE_SIZE_TEXT] != 0 assert metrics[METRIC_CREATIVE_WRITE_OK] == okInitialValue + 1 and: "PBS should include histogram metric" diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbrequestcorrection/PbRequestCorrectionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbrequestcorrection/PbRequestCorrectionSpec.groovy index 1f6bbcaf13d..d64b5cd2637 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbrequestcorrection/PbRequestCorrectionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbrequestcorrection/PbRequestCorrectionSpec.groovy @@ -23,7 +23,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { private static final String PREBID_MOBILE = "prebid-mobile" private static final String DEVICE_PREBID_MOBILE_PATTERN = "PrebidMobile/" private static final String ACCEPTABLE_DEVICE_UA_VERSION_THRESHOLD = PBSUtils.getRandomVersion("0.0", "2.1.5") - private static final String ACCEPTABLE_DEVICE_INSTL_VERSION_THRESHOLD = PBSUtils.getRandomVersion("0.0", "2.2.3") + private static final String ACCEPTABLE_DEVICE_INSTL_VERSION_THRESHOLD = PBSUtils.getRandomVersion("0.0", "2.2.2") private static final String ANDROID = "android" private static final String IOS = "IOS" diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy index 2426a3fd316..4d24d199113 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy @@ -579,10 +579,7 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { } def "PBS should modify response when requested video impression respond with invalid adm VAST keyword and disabled cache config"() { - given: "Start up time" - def start = Instant.now() - - and: "Default bid request with APP and Video imp" + given: "Default bid request with APP and Video imp" def bidRequest = getDefaultVideoRequest(APP) and: "Set bidder response" @@ -601,13 +598,8 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) - def bidId = bidResponse.seatbid[0].bid[0].id - def responseCorrection = getLogsByText(logsByTime, bidId) - assert responseCorrection.size() == 1 - assert responseCorrection.any { - it.contains("Bid $bidId of bidder generic: changing media type to banner" as String) - } + def responseCorrectionLog = "Bid ${bidResponse.seatbid[0].bid[0].id} of bidder generic: changing media type to banner" + assert pbsServiceWithResponseCorrectionModule.isContainLogsByValue(responseCorrectionLog) and: "Response should contain seatBid" assert response.seatbid.size() == 1 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 d92bec507cc..55fd210806f 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 @@ -363,4 +363,14 @@ abstract class PrivacyBaseSpec extends BaseSpec { it.vendors = [(GENERIC_VENDOR_ID): vendor] }) } + + protected static String getInvalidGppString(int stringLength = 20) { + String invalidGppValue + // Random string can potentially generate deprecated v1 value with specific starting values ('A'-'D') + do { + invalidGppValue = PBSUtils.getRandomString(stringLength) + } while (invalidGppValue[0].toUpperCase() in 'A'..'D') + + invalidGppValue + } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppAuctionSpec.groovy index b40700ed59f..3e944af63fc 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppAuctionSpec.groovy @@ -109,7 +109,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS should emit warning when GPP string is invalid"() { given: "Default bid request with invalid gpp" - def invalidGpp = "Invalid_GPP_Consent_String" + def invalidGpp = getInvalidGppString() def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gpp: invalidGpp) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy index 9cbd8671a80..99540d55220 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy @@ -592,7 +592,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def "PBS cookie sync call when privacy module contain invalid GPP string should respond with required bidder URL and emit warning in response"() { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString - def invalidGpp = PBSUtils.randomString + def invalidGpp = getInvalidGppString() def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { it.gppSid = US_NAT_V1.value it.account = accountId diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy index 1a52cbcea86..3c6472b3d99 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy @@ -899,7 +899,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain invalid GPP string shouldn't remove EIDS fields in request and emit warning in response"() { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String - def invalidGpp = PBSUtils.randomString + def invalidGpp = getInvalidGppString() def bidRequest = getBidRequestWithPersonalData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = invalidGpp @@ -2077,7 +2077,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = getBidRequestWithPersonalData(accountId) and: "Default amp request with link to account" - def invalidGpp = PBSUtils.randomString + def invalidGpp = getInvalidGppString() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId it.gppSid = US_NAT_V1.value diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy index 185726ecc0c..74cdcdce28b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy @@ -1335,7 +1335,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain invalid GPP string shouldn't remove UFPD fields in request and emit warning in response"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def invalidGpp = PBSUtils.randomString + def invalidGpp = getInvalidGppString() def bidRequest = getBidRequestWithPersonalData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = invalidGpp @@ -2957,7 +2957,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = getBidRequestWithPersonalData(accountId) and: "Default amp request with link to account" - def invalidGpp = PBSUtils.randomString + def invalidGpp = getInvalidGppString() def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId it.gppSid = US_NAT_V1.value diff --git a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy index 748071dd10f..8619e9cf916 100644 --- a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy @@ -144,24 +144,21 @@ class PBSUtils implements ObjectMapperWrapper { static String getRandomVersion(String minVersion = "0.0.0", String maxVersion = "99.99.99") { def minParts = minVersion.split('\\.').collect { it.toInteger() } def maxParts = maxVersion.split('\\.').collect { it.toInteger() } - def versionParts = [] + + while (minParts.size() < 3) minParts << 0 + while (maxParts.size() < 3) maxParts << 0 def major = getRandomNumber(minParts[0], maxParts[0]) - versionParts << major def minorMin = (major == minParts[0]) ? minParts[1] : 0 def minorMax = (major == maxParts[0]) ? maxParts[1] : 99 def minor = getRandomNumber(minorMin, minorMax) - versionParts << minor - if (minParts.size() > 2 || maxParts.size() > 2) { - def patchMin = (major == minParts[0] && minor == minParts[1]) ? minParts[2] : 0 - def patchMax = (major == maxParts[0] && minor == maxParts[1]) ? maxParts[2] : 99 - def patch = getRandomNumber(patchMin, patchMax) - versionParts << patch - } - def version = versionParts.join('.') - return (version >= minVersion && version <= maxVersion) ? version : getRandomVersion(minVersion, maxVersion) + def patchMin = (major == minParts[0] && minor == minParts[1]) ? minParts[2] : 0 + def patchMax = (major == maxParts[0] && minor == maxParts[1]) ? maxParts[2] : 99 + def patch = getRandomNumber(patchMin, patchMax) + + return "${major}.${minor}.${patch}" } static Boolean isUUID(String str) {