Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.prebid.server.functional.tests.module.optabletargeting

import org.apache.commons.codec.binary.Base64
import org.prebid.server.functional.model.config.AccountConfig
import org.prebid.server.functional.model.config.AccountHooksConfiguration
import org.prebid.server.functional.model.config.IdentifierType
Expand Down Expand Up @@ -135,7 +136,8 @@ 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()
def targetingResultSizeText = new String(Base64.encodeBase64(encode(targetingResult).bytes)).size()
assert metrics[METRIC_CREATIVE_SIZE_TEXT] == PBSUtils.roundToTens(targetingResultSizeText)
assert metrics[METRIC_CREATIVE_WRITE_OK] == okInitialValue + 1

and: "PBS should include histogram metric"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import org.prebid.server.functional.model.config.AccountHooksConfiguration
import org.prebid.server.functional.model.config.PbRequestCorrectionConfig
import org.prebid.server.functional.model.config.PbsModulesConfig
import org.prebid.server.functional.model.db.Account
import org.prebid.server.functional.model.request.auction.BidRequest
import org.prebid.server.functional.model.request.auction.AppExt
import org.prebid.server.functional.model.request.auction.AppPrebid
import org.prebid.server.functional.model.request.auction.BidRequest
import org.prebid.server.functional.model.request.auction.Device
import org.prebid.server.functional.model.request.auction.Imp
import org.prebid.server.functional.model.request.auction.OperationState
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import static org.prebid.server.functional.model.request.auction.TraceLevel.VERB
import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer
import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID

@Retry //TODO remove in 3.34+
abstract class RuleEngineBaseSpec extends ModuleBaseSpec {

protected static final List<BidderName> MULTI_BID_ADAPTERS = [GENERIC, OPENX, AMX].sort()
Expand Down Expand Up @@ -97,7 +96,6 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec {

protected static BidRequest getDefaultBidRequestWithMultiplyBidders(DistributionChannel distributionChannel = SITE) {
BidRequest.getDefaultBidRequest(distributionChannel).tap {
it.tmax = 5_000 // prevents timeout issues on slow pipelines
it.imp[0].ext.prebid.bidder.amx = new Amx()
it.imp[0].ext.prebid.bidder.openx = Openx.defaultOpenx
it.imp[0].ext.prebid.bidder.generic = new Generic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import static org.prebid.server.functional.model.config.RuleEngineFunction.GPP_S
import static org.prebid.server.functional.model.config.RuleEngineFunction.GPP_SID_IN
import static org.prebid.server.functional.model.config.RuleEngineFunction.TCF_IN_SCOPE
import static org.prebid.server.functional.model.config.RuleEngineFunction.USER_FPD_AVAILABLE
import static org.prebid.server.functional.model.request.GppSectionId.TCF_EU_V2
import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP
import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS
import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE
Expand Down Expand Up @@ -538,7 +539,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec {
def "PBS should exclude bidder when gppSidAvailable match with condition"() {
given: "Default bid request with multiply bidder"
def bidRequest = getDefaultBidRequestWithMultiplyBidders().tap {
regs = new Regs(gppSid: [PBSUtils.getRandomEnum(GppSectionId).getIntValue()])
regs = new Regs(gppSid: [PBSUtils.getRandomEnum(GppSectionId, [TCF_EU_V2]).getIntValue()])
}

and: "Account with rule engine config"
Expand Down Expand Up @@ -641,7 +642,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec {

and: "Default bid request with multiply bidders"
def bidRequest = getDefaultBidRequestWithMultiplyBidders().tap {
regs = new Regs(gdpr: 0, gppSid: [PBSUtils.getRandomEnum(GppSectionId, [GppSectionId.TCF_EU_V2]).getIntValue()])
regs = new Regs(gdpr: 0, gppSid: [PBSUtils.getRandomEnum(GppSectionId, [TCF_EU_V2]).getIntValue()])
}

and: "Account with rule engine config"
Expand Down Expand Up @@ -745,7 +746,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec {
assert seatNonBid.nonBid[0].statusCode == REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE

where:
gppSectionId << GppSectionId.values() - GppSectionId.TCF_EU_V2
gppSectionId << GppSectionId.values() - TCF_EU_V2
}

def "PBS shouldn't exclude bidder when gppSidIn not match with condition"() {
Expand Down Expand Up @@ -789,7 +790,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec {
assert !getAnalyticResults(bidResponse)

where:
gppSectionId << GppSectionId.values() - GppSectionId.TCF_EU_V2
gppSectionId << GppSectionId.values() - TCF_EU_V2
}

def "PBS should exclude bidder when tcfInScope match with condition"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -601,13 +598,9 @@ 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 $bidId of bidder generic: changing media type to banner"
assert pbsServiceWithResponseCorrectionModule.isContainLogsByValue(responseCorrectionLog)

and: "Response should contain seatBid"
assert response.seatbid.size() == 1
Expand Down
23 changes: 12 additions & 11 deletions src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class PBSUtils implements ObjectMapperWrapper {
number.setScale(decimalPlaces, RoundingMode.HALF_EVEN)
}

static Integer roundToTens(Integer number) {
Math.ceil(number / 10) * 10
}

static String getRandomString(int stringLength = 20) {
RandomStringUtils.randomAlphanumeric(stringLength)
}
Expand Down Expand Up @@ -144,24 +148,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) {
Expand Down