From c6ddf01a460ef3dd16161db698ff635ee086a831 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Sun, 5 Jan 2025 20:09:27 +0200 Subject: [PATCH 01/25] Refactoring functional tests --- .../model/config/AdminConfig.groovy | 1 - .../model/config/EndpointExecutionPlan.groovy | 19 ++- .../model/config/ExecutionGroup.groovy | 8 +- .../model/config/ExecutionPlan.groovy | 9 +- ...{AbTest.groovy => ModularityAbTest.groovy} | 6 +- .../config/ModuleHookImplementation.groovy | 1 - .../model/{ => config}/ModuleName.groovy | 6 +- .../functional/model/config/Stage.groovy | 4 + .../model/config/StageExecutionPlan.groovy | 10 +- .../model/request/auction/UserExtData.groovy | 8 +- .../response/auction/AnalyticResult.groovy | 5 +- .../model/response/auction/ModuleValue.groovy | 2 +- .../response/auction/OpenxBidResponse.groovy | 1 - .../testcontainers/scaffolding/Bidder.groovy | 4 +- .../scaffolding/FloorsProvider.groovy | 2 +- .../scaffolding/PrebidCache.groovy | 2 +- .../server/functional/tests/AmpFpdSpec.groovy | 16 +-- .../functional/tests/AnalyticsSpec.groovy | 1 - .../server/functional/tests/BaseSpec.groovy | 6 + .../tests/BidExpResponseSpec.groovy | 7 -- .../tests/BidderInsensitiveCaseSpec.groovy | 4 +- .../tests/StoredResponseSpec.groovy | 2 +- .../functional/tests/TargetingSpec.groovy | 5 +- .../tests/module/AbTestingModuleSpec.groovy | 116 ++++++++++-------- .../tests/module/GeneralModuleSpec.groovy | 83 +++++++------ .../tests/module/ModuleBaseSpec.groovy | 77 +++++++----- .../AnalyticsTagsModuleSpec.groovy | 19 ++- .../ortb2blocking/Ortb2BlockingSpec.groovy | 98 ++++++--------- .../PbRequestCorrectionSpec.groovy | 46 ++++--- .../ResponseCorrectionSpec.groovy | 71 +++++------ .../richmedia/RichMediaFilterSpec.groovy | 97 ++++++++------- .../tests/privacy/ActivityTraceLogSpec.groovy | 4 +- .../functional/tests/privacy/CoppaSpec.groovy | 4 +- .../tests/privacy/GdprAmpSpec.groovy | 2 +- .../tests/privacy/GdprAuctionSpec.groovy | 2 +- .../GppTransmitUfpdActivitiesSpec.groovy | 36 +++--- .../functional/tests/privacy/LmtSpec.groovy | 4 +- .../tests/privacy/PrivacyBaseSpec.groovy | 2 +- .../tests/prometheus/PrometheusSpec.groovy | 6 +- .../functional/tests/storage/AmpS3Spec.groovy | 6 - .../tests/storage/AuctionS3Spec.groovy | 2 +- .../tests/storage/StorageBaseSpec.groovy | 1 - .../server/functional/util/HttpUtil.groovy | 1 - .../util/privacy/model/State.groovy | 3 +- 44 files changed, 426 insertions(+), 383 deletions(-) rename src/test/groovy/org/prebid/server/functional/model/config/{AbTest.groovy => ModularityAbTest.groovy} (84%) rename src/test/groovy/org/prebid/server/functional/model/{ => config}/ModuleName.groovy (66%) diff --git a/src/test/groovy/org/prebid/server/functional/model/config/AdminConfig.groovy b/src/test/groovy/org/prebid/server/functional/model/config/AdminConfig.groovy index 755a47bcbaa..6b0b82f6015 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/AdminConfig.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/AdminConfig.groovy @@ -3,7 +3,6 @@ package org.prebid.server.functional.model.config import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.ToString -import org.prebid.server.functional.model.ModuleName @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy) diff --git a/src/test/groovy/org/prebid/server/functional/model/config/EndpointExecutionPlan.groovy b/src/test/groovy/org/prebid/server/functional/model/config/EndpointExecutionPlan.groovy index 9ded40849d0..94856f2e85c 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/EndpointExecutionPlan.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/EndpointExecutionPlan.groovy @@ -1,7 +1,6 @@ package org.prebid.server.functional.model.config import groovy.transform.ToString -import org.prebid.server.functional.model.ModuleName @ToString(includeNames = true, ignoreNulls = true) class EndpointExecutionPlan { @@ -9,8 +8,9 @@ class EndpointExecutionPlan { Map stages static EndpointExecutionPlan getModuleEndpointExecutionPlan(ModuleName name, List stages) { - new EndpointExecutionPlan(stages: stages.collectEntries { - it -> [(it): StageExecutionPlan.getModuleStageExecutionPlan(name, it)] } as Map) + new EndpointExecutionPlan(stages: stages.collectEntries { + it -> [(it): StageExecutionPlan.getModuleStageExecutionPlan(name, it)] + } as Map) } static EndpointExecutionPlan getModulesEndpointExecutionPlan(Map> modulesStages) { @@ -24,4 +24,17 @@ class EndpointExecutionPlan { } as Map ) } + + static EndpointExecutionPlan getModuleEndpointExecutionPlan(List modulesHooks) { + Map stages = [:] + modulesHooks.each { moduleHook -> + def stage = Stage.forValue(moduleHook) + if (!stages.containsKey(stage)) { + stages[stage] = StageExecutionPlan.getModuleStageExecutionPlan([moduleHook]) + } else { + stages[stage].addGroup(moduleHook) + } + } + new EndpointExecutionPlan(stages: stages) + } } diff --git a/src/test/groovy/org/prebid/server/functional/model/config/ExecutionGroup.groovy b/src/test/groovy/org/prebid/server/functional/model/config/ExecutionGroup.groovy index 09e95d7753d..7a480e43028 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/ExecutionGroup.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/ExecutionGroup.groovy @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.ToString -import org.prebid.server.functional.model.ModuleName @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy) @@ -16,6 +15,13 @@ class ExecutionGroup { @JsonProperty("hook_sequence") List hookSequenceSnakeCase + static ExecutionGroup getModuleExecutionGroup(ModuleHookImplementation moduleHook) { + new ExecutionGroup().tap { + timeout = 100 + hookSequence = [new HookId(moduleCode: ModuleName.forValue(moduleHook).code, hookImplCode: moduleHook.code)] + } + } + static ExecutionGroup getModuleExecutionGroup(ModuleName name, Stage stage) { new ExecutionGroup().tap { timeout = 100 diff --git a/src/test/groovy/org/prebid/server/functional/model/config/ExecutionPlan.groovy b/src/test/groovy/org/prebid/server/functional/model/config/ExecutionPlan.groovy index 653f8c8cbea..a651afc424e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/ExecutionPlan.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/ExecutionPlan.groovy @@ -3,15 +3,20 @@ package org.prebid.server.functional.model.config import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.ToString -import org.prebid.server.functional.model.ModuleName + +import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) class ExecutionPlan { - List abTests + List abTests Map endpoints + static ExecutionPlan getSingleEndpointExecutionPlan(List moduleHook, Endpoint endpoint = OPENRTB2_AUCTION) { + new ExecutionPlan(endpoints: [(endpoint): EndpointExecutionPlan.getModuleEndpointExecutionPlan(moduleHook)]) + } + static ExecutionPlan getSingleEndpointExecutionPlan(Endpoint endpoint, ModuleName moduleName, List stage) { new ExecutionPlan(endpoints: [(endpoint): EndpointExecutionPlan.getModuleEndpointExecutionPlan(moduleName, stage)]) } diff --git a/src/test/groovy/org/prebid/server/functional/model/config/AbTest.groovy b/src/test/groovy/org/prebid/server/functional/model/config/ModularityAbTest.groovy similarity index 84% rename from src/test/groovy/org/prebid/server/functional/model/config/AbTest.groovy rename to src/test/groovy/org/prebid/server/functional/model/config/ModularityAbTest.groovy index baa19a80db4..8bb2cae77e1 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/AbTest.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/ModularityAbTest.groovy @@ -7,7 +7,7 @@ import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy) -class AbTest { +class ModularityAbTest { Boolean enabled String moduleCode @@ -21,8 +21,8 @@ class AbTest { @JsonProperty("log_analytics_tag") Boolean logAnalyticsTagSnakeCase - static AbTest getDefault(String moduleCode, List accounts = null) { - new AbTest(enabled: true, + static ModularityAbTest getDefault(String moduleCode, List accounts = null) { + new ModularityAbTest(enabled: true, moduleCode: moduleCode, accounts: accounts, percentActive: 0, diff --git a/src/test/groovy/org/prebid/server/functional/model/config/ModuleHookImplementation.groovy b/src/test/groovy/org/prebid/server/functional/model/config/ModuleHookImplementation.groovy index 247bdea4353..0959ccb6c19 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/ModuleHookImplementation.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/ModuleHookImplementation.groovy @@ -1,7 +1,6 @@ package org.prebid.server.functional.model.config import com.fasterxml.jackson.annotation.JsonValue -import org.prebid.server.functional.model.ModuleName //TODO remove if module hooks implementation codes will become consistent enum ModuleHookImplementation { diff --git a/src/test/groovy/org/prebid/server/functional/model/ModuleName.groovy b/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy similarity index 66% rename from src/test/groovy/org/prebid/server/functional/model/ModuleName.groovy rename to src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy index 2bc06ab7144..67ca94c833d 100644 --- a/src/test/groovy/org/prebid/server/functional/model/ModuleName.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy @@ -1,4 +1,4 @@ -package org.prebid.server.functional.model +package org.prebid.server.functional.model.config import com.fasterxml.jackson.annotation.JsonValue @@ -15,4 +15,8 @@ enum ModuleName { ModuleName(String code) { this.code = code } + + static ModuleName forValue(ModuleHookImplementation moduleHook) { + values().find { moduleHook.code.contains(it.code) } + } } diff --git a/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy b/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy index 178f22552ae..3cc450219d9 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy @@ -24,6 +24,10 @@ enum Stage { this.metricValue = metricValue } + static Stage forValue(ModuleHookImplementation moduleHook) { + values().find { moduleHook.code.contains(it.value) } + } + @Override String toString() { value diff --git a/src/test/groovy/org/prebid/server/functional/model/config/StageExecutionPlan.groovy b/src/test/groovy/org/prebid/server/functional/model/config/StageExecutionPlan.groovy index b2fab91c200..81c4a8538ee 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/StageExecutionPlan.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/StageExecutionPlan.groovy @@ -1,7 +1,6 @@ package org.prebid.server.functional.model.config import groovy.transform.ToString -import org.prebid.server.functional.model.ModuleName @ToString(includeNames = true, ignoreNulls = true) class StageExecutionPlan { @@ -11,4 +10,13 @@ class StageExecutionPlan { static StageExecutionPlan getModuleStageExecutionPlan(ModuleName name, Stage stage) { new StageExecutionPlan(groups: [ExecutionGroup.getModuleExecutionGroup(name, stage)]) } + + static StageExecutionPlan getModuleStageExecutionPlan(List modulesHooks) { + new StageExecutionPlan(groups: modulesHooks.collect { ExecutionGroup.getModuleExecutionGroup(it) }) + } + + StageExecutionPlan addGroup(ModuleHookImplementation moduleHook) { + (groups ?: (groups = [])).add(ExecutionGroup.getModuleExecutionGroup(moduleHook)) + this + } } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy index cb28895f37c..ad7cdf63390 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy @@ -7,15 +7,15 @@ import org.prebid.server.functional.util.PBSUtils class UserExtData { List keywords - String buyeruid - List buyeruids + String buyerUid + List buyerUids Geo geo static UserExtData getFPDUserExtData() { new UserExtData().tap { keywords = [PBSUtils.randomString] - buyeruid = PBSUtils.randomString - buyeruids = [PBSUtils.randomString] + buyerUid = PBSUtils.randomString + buyerUids = [PBSUtils.randomString] } } } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy index 7976ae24c2f..136fbc47e5e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.EqualsAndHashCode import groovy.transform.ToString -import org.prebid.server.functional.model.request.auction.FetchStatus import org.prebid.server.functional.model.request.auction.Imp import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS @@ -15,12 +14,12 @@ import static org.prebid.server.functional.model.request.auction.FetchStatus.SUC class AnalyticResult { String name - FetchStatus status + String status List results static AnalyticResult buildFromImp(Imp imp) { def appliedTo = new AppliedTo(impIds: [imp.id], bidders: [imp.ext.prebid.bidder.configuredBidders.first()]) def impResult = new ImpResult(status: 'success-block', values: new ModuleValue(richmediaFormat: 'mraid'), appliedTo: appliedTo) - new AnalyticResult(name: 'reject-richmedia', status: SUCCESS, results: [impResult]) + new AnalyticResult(name: 'reject-richmedia', status: SUCCESS.value, results: [impResult]) } } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/ModuleValue.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/ModuleValue.groovy index 9a1e9d1b440..800f5a808bb 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/ModuleValue.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/ModuleValue.groovy @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.EqualsAndHashCode import groovy.transform.ToString -import org.prebid.server.functional.model.ModuleName +import org.prebid.server.functional.model.config.ModuleName @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy) diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/OpenxBidResponse.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/OpenxBidResponse.groovy index 2ba60b226c1..b5d5289d5a6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/OpenxBidResponse.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/OpenxBidResponse.groovy @@ -1,6 +1,5 @@ package org.prebid.server.functional.model.response.auction - import groovy.transform.ToString import org.prebid.server.functional.model.request.auction.BidRequest diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy index ff0b9f3b4f7..a0d1d4d8973 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy @@ -36,7 +36,7 @@ class Bidder extends NetworkScaffolding { request().withPath(AUCTION_ENDPOINT) } - HttpRequest getRequest(String bidRequestId, String requestMatchPath) { + static HttpRequest getRequest(String bidRequestId, String requestMatchPath) { request().withPath(AUCTION_ENDPOINT) .withBody(jsonPath("\$[?(@.$requestMatchPath == '$bidRequestId')]")) } @@ -68,7 +68,7 @@ class Bidder extends NetworkScaffolding { return getLastRecordedRequestHeaders(bidRequestId) } - private String getBodyByRequest(HttpRequest request) { + private static String getBodyByRequest(HttpRequest request) { def requestString = request.bodyAsString def jsonNode = toJsonNode(requestString) def id = jsonNode.get("id").asText() diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/FloorsProvider.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/FloorsProvider.groovy index 77c18b09088..a5393fa64b4 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/FloorsProvider.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/FloorsProvider.groovy @@ -37,7 +37,7 @@ class FloorsProvider extends NetworkScaffolding { : HttpResponse.notFoundResponse()} } - private String getDefaultResponse() { + private static String getDefaultResponse() { encode(PriceFloorData.priceFloorData) } } diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/PrebidCache.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/PrebidCache.groovy index 224f7c8b228..9396535b231 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/PrebidCache.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/PrebidCache.groovy @@ -76,7 +76,7 @@ class PrebidCache extends NetworkScaffolding { .withBody(jsonPath("\$.puts[?(@.value =~/^.*$payload.*\$/)]")) } - private String getBodyByRequest(HttpRequest request) { + private static String getBodyByRequest(HttpRequest request) { def requestString = request.bodyAsString def jsonNode = toJsonNode(requestString) def putsSize = jsonNode.get("puts").size() diff --git a/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy index 762c55fe879..9c52631656d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy @@ -74,8 +74,8 @@ class AmpFpdSpec extends BaseSpec { ampStoredRequest.user.geo.zip == user.geo.zip ampStoredRequest.user.geo.country == user.geo.country ampStoredRequest.user.ext.data.keywords == user.ext.data.keywords - ampStoredRequest.user.ext.data.buyeruid == user.ext.data.buyeruid - ampStoredRequest.user.ext.data.buyeruids == user.ext.data.buyeruids + ampStoredRequest.user.ext.data.buyerUid == user.ext.data.buyerUid + ampStoredRequest.user.ext.data.buyerUids == user.ext.data.buyerUids } and: "Bidder request shouldn't contain imp[0].ext.rp" @@ -195,8 +195,8 @@ class AmpFpdSpec extends BaseSpec { ortb2.user.gender == user.gender ortb2.user.keywords == user.keywords ortb2.user.ext.data.keywords == user.ext.data.keywords - ortb2.user.ext.data.buyeruid == user.ext.data.buyeruid - ortb2.user.ext.data.buyeruids == user.ext.data.buyeruids + ortb2.user.ext.data.buyerUid == user.ext.data.buyerUid + ortb2.user.ext.data.buyerUids == user.ext.data.buyerUids } and: "Bidder request shouldn't contain imp[0].ext.rp" @@ -289,8 +289,8 @@ class AmpFpdSpec extends BaseSpec { ampStoredRequest.user.geo.zip == user.geo.zip ampStoredRequest.user.geo.country == user.geo.country ampStoredRequest.user.ext.data.keywords == user.ext.data.keywords - ampStoredRequest.user.ext.data.buyeruid == user.ext.data.buyeruid - ampStoredRequest.user.ext.data.buyeruids == user.ext.data.buyeruids + ampStoredRequest.user.ext.data.buyerUid == user.ext.data.buyerUid + ampStoredRequest.user.ext.data.buyerUids == user.ext.data.buyerUids } } @@ -367,8 +367,8 @@ class AmpFpdSpec extends BaseSpec { ortb2.user.gender == user.gender ortb2.user.keywords == user.keywords ortb2.user.ext.data.keywords == user.ext.data.keywords - ortb2.user.ext.data.buyeruid == user.ext.data.buyeruid - ortb2.user.ext.data.buyeruids == user.ext.data.buyeruids + ortb2.user.ext.data.buyerUid == user.ext.data.buyerUid + ortb2.user.ext.data.buyerUids == user.ext.data.buyerUids } and: "Bidder request shouldn't contain imp[0].ext.rp" diff --git a/src/test/groovy/org/prebid/server/functional/tests/AnalyticsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AnalyticsSpec.groovy index b113f649834..7d7d4469624 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AnalyticsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AnalyticsSpec.groovy @@ -28,7 +28,6 @@ class AnalyticsSpec extends BaseSpec { ENABLED_DEBUG_LOG_MODE + ['analytics.log.enabled' : 'true', 'analytics.global.adapters': '']) - @Shared PubStackAnalytics analytics = new PubStackAnalytics(Dependencies.networkServiceContainer).tap { it.setResponse(PubStackResponse.getDefaultPubStackResponse(SCOPE_ID, Dependencies.networkServiceContainer.rootUri)) diff --git a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy index fcb735d7186..3a5957d01cc 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy @@ -42,6 +42,12 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper { private static final String DEFAULT_CACHE_DIRECTORY = "/app/prebid-server/data" protected static final Map GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true", "adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + protected static final Map EMPTY_CACHE_TTL_CONFIG = ["cache.default-ttl-seconds.banner": "", + "cache.default-ttl-seconds.video" : "", + "cache.default-ttl-seconds.native": "", + "cache.default-ttl-seconds.audio" : ""] + protected static final Map EMPTY_CACHE_TTL_HOST_CONFIG = ["cache.banner-ttl-seconds": "", + "cache.video-ttl-seconds" : ""] protected final PrebidServerService defaultPbsService = pbsServiceFactory.getService([:]) diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy index 6ca55f4b7bc..74ac930fa9d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy @@ -29,17 +29,10 @@ class BidExpResponseSpec extends BaseSpec { "cache.default-ttl-seconds.video" : VIDEO_TTL_DEFAULT_CACHE as String, "cache.default-ttl-seconds.native": NATIVE_TTL_DEFAULT_CACHE as String, "cache.default-ttl-seconds.audio" : AUDIO_TTL_DEFAULT_CACHE as String] - private static final Map EMPTY_CACHE_TTL_CONFIG = ["cache.default-ttl-seconds.banner": "", - "cache.default-ttl-seconds.video" : "", - "cache.default-ttl-seconds.native": "", - "cache.default-ttl-seconds.audio" : ""] - private static final Map EMPTY_CACHE_TTL_HOST_CONFIG = ["cache.banner-ttl-seconds": "", - "cache.video-ttl-seconds" : ""] private static def pbsOnlyHostCacheTtlService = pbsServiceFactory.getService(CACHE_TTL_HOST_CONFIG + EMPTY_CACHE_TTL_CONFIG) private static def pbsEmptyTtlService = pbsServiceFactory.getService(EMPTY_CACHE_TTL_CONFIG + EMPTY_CACHE_TTL_HOST_CONFIG) private static def pbsHostAndDefaultCacheTtlService = pbsServiceFactory.getService(CACHE_TTL_HOST_CONFIG + DEFAULT_CACHE_TTL_CONFIG) - def "PBS auction should resolve bid.exp from response that is set by the bidder’s adapter"() { given: "Default basicResponse with exp" def bidResponseExp = PBSUtils.randomNumber diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy index f2fb2803f1f..36f5332b7f5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy @@ -109,8 +109,8 @@ class BidderInsensitiveCaseSpec extends BaseSpec { ortb2.user.gender == user.gender ortb2.user.keywords == user.keywords ortb2.user.ext.data.keywords == user.ext.data.keywords - ortb2.user.ext.data.buyeruid == user.ext.data.buyeruid - ortb2.user.ext.data.buyeruids == user.ext.data.buyeruids + ortb2.user.ext.data.buyerUid == user.ext.data.buyerUid + ortb2.user.ext.data.buyerUids == user.ext.data.buyerUids } and: "Bidder request shouldn't contain imp[0].ext.rp" diff --git a/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy index 767c4b8e544..467402dc331 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy @@ -18,7 +18,7 @@ import static org.prebid.server.functional.model.bidder.BidderName.GENERIC class StoredResponseSpec extends BaseSpec { - private final PrebidServerService pbsService = pbsServiceFactory.getService(["cache.default-ttl-seconds.banner": ""]) + private final PrebidServerService pbsService = pbsServiceFactory.getService(EMPTY_CACHE_TTL_CONFIG) @PendingFeature def "PBS should not fail auction with storedAuctionResponse when request bidder params doesn't satisfy json-schema"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy index e24d22b4b8f..9cf3e9a6da9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy @@ -476,7 +476,7 @@ class TargetingSpec extends BaseSpec { and: "Create and save stored response into DB" def storedBidResponse = BidResponse.getDefaultBidResponse(ampStoredRequest).tap { - seatbid[0].bid[0].price = max.plus(1) + seatbid[0].bid[0].price = max + 1 } def storedResponse = new StoredResponse(responseId: storedBidResponseId, storedBidResponse: storedBidResponse) storedResponseDao.save(storedResponse) @@ -509,7 +509,7 @@ class TargetingSpec extends BaseSpec { and: "Create and save stored response into DB" def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { - seatbid[0].bid[0].price = max.plus(1) + seatbid[0].bid[0].price = max + 1 } def storedResponse = new StoredResponse(responseId: storedBidResponseId, storedBidResponse: storedBidResponse) storedResponseDao.save(storedResponse) @@ -1301,7 +1301,6 @@ class TargetingSpec extends BaseSpec { def storedRequest = StoredRequest.getStoredRequest(ampRequest, ampStoredRequest) storedRequestDao.save(storedRequest) - and: "Account in the DB" def account = createAccountWithPriceGranularity(ampRequest.account, PBSUtils.getRandomEnum(PriceGranularityType)) accountDao.save(account) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index 9ca353e0088..e7b2f8ded52 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -1,7 +1,7 @@ package org.prebid.server.functional.tests.module -import org.prebid.server.functional.model.ModuleName -import org.prebid.server.functional.model.config.AbTest +import org.prebid.server.functional.model.config.ModuleName +import org.prebid.server.functional.model.config.ModularityAbTest import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.ExecutionPlan @@ -15,7 +15,7 @@ import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.ModuleName.PB_RESPONSE_CORRECTION +import static org.prebid.server.functional.model.config.ModuleName.PB_RESPONSE_CORRECTION import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_BIDDER_REQUEST import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_RAW_BIDDER_RESPONSE @@ -45,11 +45,19 @@ class AbTestingModuleSpec extends ModuleBaseSpec { private final static Map> RESPONSE_STAGES = [(ALL_PROCESSED_BID_RESPONSES): [PB_RESPONSE_CORRECTION]] private final static Map> MODULES_STAGES = ORTB_STAGES + RESPONSE_STAGES - private final static Map MULTI_MODULE_CONFIG = getResponseCorrectionConfig() + getOrtb2BlockingSettings() + + private final static Map MULTI_MODULE_CONFIG = getModuleBaseSettings(PB_RESPONSE_CORRECTION) + getModuleBaseSettings(ModuleName.ORTB2_BLOCKING) + ['hooks.host-execution-plan': null] - private final static PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings()) - private final static PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG) + + private static PrebidServerService ortbModulePbsService + + def setupSpec() { + ortbModulePbsService = pbsServiceFactory.getService(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) + } + + def cleanupSpec() { + pbsServiceFactory.removeContainer(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) + } def "PBS shouldn't apply a/b test config when config of ab test is disabled"() { given: "Default bid request with verbose trace" @@ -59,7 +67,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { flushMetrics(ortbModulePbsService) and: "Save account with ab test config" - def abTest = AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + def abTest = ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { enabled = false } def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { @@ -95,7 +103,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def "PBS shouldn't apply valid a/b test config when module is disabled"() { given: "PBS service with disabled module config" - def pbsConfig = getOrtb2BlockingSettings(false) + def pbsConfig = getModuleBaseSettings(ModuleName.ORTB2_BLOCKING, false) def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" @@ -106,7 +114,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code)] + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code)] } def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(executionPlan: executionPlan)) def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) @@ -149,7 +157,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(moduleName)] + abTests = [ModularityAbTest.getDefault(moduleName)] } def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(executionPlan: executionPlan)) def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) @@ -190,10 +198,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { flushMetrics(pbsServiceWithMultipleModules) and: "Save account with ab test config" - def ortb2AbTestConfig = AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + def ortb2AbTestConfig = ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { it.percentActive = MAX_PERCENT_AB } - def richMediaAbTestConfig = AbTest.getDefault(PB_RESPONSE_CORRECTION.code).tap { + def richMediaAbTestConfig = ModularityAbTest.getDefault(PB_RESPONSE_CORRECTION.code).tap { it.percentActive = MAX_PERCENT_AB } def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { @@ -213,7 +221,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].sort() + it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -224,7 +232,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.RUN].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -251,10 +259,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { flushMetrics(pbsServiceWithMultipleModules) and: "Save account with ab test config" - def ortb2AbTestConfig = AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + def ortb2AbTestConfig = ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { it.percentActive = MIN_PERCENT_AB } - def richMediaAbTestConfig = AbTest.getDefault(PB_RESPONSE_CORRECTION.code).tap { + def richMediaAbTestConfig = ModularityAbTest.getDefault(PB_RESPONSE_CORRECTION.code).tap { it.percentActive = MIN_PERCENT_AB } def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { @@ -274,7 +282,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -285,7 +293,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -312,10 +320,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { flushMetrics(pbsServiceWithMultipleModules) and: "Save account with ab test config" - def ortb2AbTestConfig = AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + def ortb2AbTestConfig = ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { it.percentActive = MIN_PERCENT_AB } - def richMediaAbTestConfig = AbTest.getDefault(PB_RESPONSE_CORRECTION.code).tap { + def richMediaAbTestConfig = ModularityAbTest.getDefault(PB_RESPONSE_CORRECTION.code).tap { it.percentActive = MAX_PERCENT_AB } def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { @@ -335,7 +343,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -346,7 +354,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.RUN].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -372,7 +380,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, [PBSUtils.randomNumber]).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, [PBSUtils.randomNumber]).tap { percentActive = MIN_PERCENT_AB }] } @@ -389,7 +397,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -409,7 +417,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { it.percentActive = percentActive it.percentActiveSnakeCase = percentActiveSnakeCase }] @@ -427,7 +435,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].sort() + it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -458,7 +466,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { it.percentActive = percentActive it.percentActiveSnakeCase = percentActiveSnakeCase }] @@ -476,7 +484,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -501,7 +509,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { it.percentActive = percentActive it.percentActiveSnakeCase = percentActiveSnakeCase }] @@ -523,7 +531,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -548,7 +556,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { it.percentActive = percentActive it.percentActiveSnakeCase = percentActiveSnakeCase }] @@ -571,7 +579,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].sort() + it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -601,7 +609,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { percentActive = MIN_PERCENT_AB it.logAnalyticsTag = logAnalyticsTag it.logAnalyticsTagSnakeCase = logAnalyticsTagSnakeCase @@ -620,7 +628,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -646,7 +654,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { percentActive = MIN_PERCENT_AB it.logAnalyticsTag = logAnalyticsTag it.logAnalyticsTagSnakeCase = logAnalyticsTagSnakeCase @@ -689,7 +697,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { percentActive = MAX_PERCENT_AB it.logAnalyticsTag = logAnalyticsTag it.logAnalyticsTagSnakeCase = logAnalyticsTagSnakeCase @@ -737,7 +745,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { percentActive = PBSUtils.getRandomNumber(MIN_PERCENT_AB, MAX_PERCENT_AB) }] } @@ -764,10 +772,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { } } - def "PBS should apply a/b test config from host config when accounts is not specified when account config and default account doesn't include a/b test config"() { + def "PBS should apply a/b test config from host config when accounts is not specified"() { given: "PBS service with specific ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, accouns).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, accouns).tap { percentActive = MIN_PERCENT_AB }] } @@ -790,7 +798,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -827,7 +835,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { given: "PBS service with specific ab test config" def accountId = PBSUtils.randomNumber def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, [PBSUtils.randomNumber, accountId]).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, [PBSUtils.randomNumber, accountId]).tap { percentActive = MIN_PERCENT_AB }] } @@ -853,7 +861,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -886,10 +894,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def "PBS should apply a/b test config from host config for specific account and general config when account config and default account doesn't include a/b test config"() { given: "PBS service with specific ab test config" def accountId = PBSUtils.randomNumber - def ortb2AbTestConfig = AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, []).tap { + def ortb2AbTestConfig = ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, []).tap { it.percentActive = MIN_PERCENT_AB } - def richMediaAbTestConfig = AbTest.getDefault(PB_RESPONSE_CORRECTION.code, [accountId]).tap { + def richMediaAbTestConfig = ModularityAbTest.getDefault(PB_RESPONSE_CORRECTION.code, [accountId]).tap { it.percentActive = MIN_PERCENT_AB } def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { @@ -917,7 +925,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -928,7 +936,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -953,7 +961,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def "PBS shouldn't apply a/b test config from host config for non specified accounts when account config and default account doesn't include a/b test config"() { given: "PBS service with specific ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, [PBSUtils.randomNumber]).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code, [PBSUtils.randomNumber]).tap { percentActive = MIN_PERCENT_AB }] } @@ -977,7 +985,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten() == [ORTB2_BLOCKING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SUCCESS_ALLOW].value it.analyticsTags.activities.results.values.module.flatten().every { it == null } } @@ -1015,7 +1023,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def "PBS should prioritise a/b test config from default account and only specified module when host and default account contains a/b test configs"() { given: "PBS service with specific ab test config" def accountExecutionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { percentActive = MIN_PERCENT_AB }] } @@ -1024,7 +1032,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { } def hostExecutionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code)] + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code)] } def pbsConfig = MULTI_MODULE_CONFIG + ['hooks.host-execution-plan': encode(hostExecutionPlan)] + ["settings.default-account-config": encode(defaultAccountConfigSettings)] @@ -1046,7 +1054,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS, SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION, NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING, AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED, FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -1078,7 +1086,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def "PBS should prioritise a/b test config from account over default account and only specified module when specific account and default account contains a/b test configs"() { given: "PBS service with specific ab test config" - def accountExecutionPlan = new ExecutionPlan(abTests: [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code)]) + def accountExecutionPlan = new ExecutionPlan(abTests: [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code)]) def defaultAccountConfigSettings = AccountConfig.defaultAccountConfig.tap { hooks = new AccountHooksConfiguration(executionPlan: accountExecutionPlan) } @@ -1095,7 +1103,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Save account with ab test config" def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES).tap { - abTests = [AbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { + abTests = [ModularityAbTest.getDefault(ModuleName.ORTB2_BLOCKING.code).tap { percentActive = MIN_PERCENT_AB }] } @@ -1115,7 +1123,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] + it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy index 82727b16a56..f3e5c66c18b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy @@ -1,6 +1,6 @@ package org.prebid.server.functional.tests.module -import org.prebid.server.functional.model.ModuleName +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.AdminConfig @@ -14,10 +14,9 @@ import org.prebid.server.functional.model.request.auction.RichmediaFilter import org.prebid.server.functional.model.request.auction.TraceLevel import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.service.PrebidServerService -import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING -import static org.prebid.server.functional.model.ModuleName.PB_RICHMEDIA_FILTER +import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING +import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_BIDDER_REQUEST import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_RAW_BIDDER_RESPONSE @@ -41,12 +40,22 @@ class GeneralModuleSpec extends ModuleBaseSpec { (RAW_BIDDER_RESPONSE): [ORTB2_BLOCKING]] private final static Map> RESPONSE_STAGES = [(ALL_PROCESSED_BID_RESPONSES): [PB_RICHMEDIA_FILTER]] private final static Map> MODULES_STAGES = ORTB_STAGES + RESPONSE_STAGES - private final static Map MULTI_MODULE_CONFIG = getRichMediaFilterSettings(PBSUtils.randomString) + - getOrtb2BlockingSettings() + + private final static Map MULTI_MODULE_CONFIG = getModuleBaseSettings(PB_RICHMEDIA_FILTER) + + getModuleBaseSettings(ORTB2_BLOCKING) + ['hooks.host-execution-plan': encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES))] - private final static PrebidServerService pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG) - private final static PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG) + private static PrebidServerService pbsServiceWithMultipleModule + private static PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke + + def setupSpec() { + pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG) + pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG) + } + + def cleanupSpec() { + pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG) + pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG) + } def "PBS should call all modules and traces response when account config is empty and require-config-to-invoke is disabled"() { given: "Default bid request with verbose trace" @@ -140,7 +149,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { } def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] - def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig) + def pbsServiceWithMultipleModule = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" def bidRequest = defaultBidRequest.tap { @@ -148,10 +157,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { } and: "Flush metrics" - flushMetrics(pbsServiceWithMultipleModules) + flushMetrics(pbsServiceWithMultipleModule) when: "PBS processes auction request" - def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModule.sendAuctionRequest(bidRequest) then: "PBS response should include trace information about called modules" verifyAll(response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() as List) { @@ -161,7 +170,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { } and: "Ortb2blocking module call metrics should be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 @@ -296,7 +305,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { given: "PBS service with module-execution config" def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + [("hooks.admin.module-execution.${ORTB2_BLOCKING.code}".toString()): 'true'] - def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig) + def pbsServiceWithMultipleModule = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" def bidRequest = defaultBidRequest.tap { @@ -304,10 +313,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { } and: "Flush metrics" - flushMetrics(pbsServiceWithMultipleModules) + flushMetrics(pbsServiceWithMultipleModule) when: "PBS processes auction request" - def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModule.sendAuctionRequest(bidRequest) then: "PBS response should include trace information about called modules" verifyAll(response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() as List) { @@ -317,7 +326,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { } and: "Ortb2blocking module call metrics should be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 @@ -331,7 +340,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { given: "PBS service with module-execution config" def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + [("hooks.admin.module-execution.${ORTB2_BLOCKING.code}".toString()): 'false'] - def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig) + def pbsServiceWithMultipleModule = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" def bidRequest = defaultBidRequest.tap { @@ -339,16 +348,16 @@ class GeneralModuleSpec extends ModuleBaseSpec { } and: "Flush metrics" - flushMetrics(pbsServiceWithMultipleModules) + flushMetrics(pbsServiceWithMultipleModule) when: "PBS processes auction request" - def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModule.sendAuctionRequest(bidRequest) then: "PBS response shouldn't include trace information about no-called modules" assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() and: "Ortb2blocking module call metrics shouldn't be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] @@ -364,8 +373,8 @@ class GeneralModuleSpec extends ModuleBaseSpec { hooks = new AccountHooksConfiguration(admin: new AdminConfig(moduleExecution: [(ORTB2_BLOCKING): true])) } def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + - [("hooks.admin.module-execution.${ORTB2_BLOCKING.code}".toString()): 'false'] - def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig) + [("hooks.admin.module-execution.${ORTB2_BLOCKING.code}".toString()): 'false'] + def pbsServiceWithMultipleModule = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" def bidRequest = defaultBidRequest.tap { @@ -378,16 +387,16 @@ class GeneralModuleSpec extends ModuleBaseSpec { accountDao.save(account) and: "Flush metrics" - flushMetrics(pbsServiceWithMultipleModules) + flushMetrics(pbsServiceWithMultipleModule) when: "PBS processes auction request" - def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModule.sendAuctionRequest(bidRequest) then: "PBS response shouldn't include trace information about no-called modules" assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() and: "Ortb2blocking module call metrics shouldn't be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] @@ -403,7 +412,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { hooks = new AccountHooksConfiguration(admin: new AdminConfig(moduleExecution: [(ORTB2_BLOCKING): true])) } def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] - def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig) + def pbsServiceWithMultipleModule = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" def bidRequest = defaultBidRequest.tap { @@ -416,10 +425,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { accountDao.save(account) and: "Flush metrics" - flushMetrics(pbsServiceWithMultipleModules) + flushMetrics(pbsServiceWithMultipleModule) when: "PBS processes auction request" - def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModule.sendAuctionRequest(bidRequest) then: "PBS response should include trace information about called modules" verifyAll(response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() as List) { @@ -429,7 +438,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { } and: "Ortb2blocking module call metrics should be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 @@ -445,7 +454,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { hooks = new AccountHooksConfiguration(admin: new AdminConfig(moduleExecution: [(ORTB2_BLOCKING): moduleExecutionStatus])) } def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] - def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig) + def pbsServiceWithMultipleModule = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" def bidRequest = defaultBidRequest.tap { @@ -458,16 +467,16 @@ class GeneralModuleSpec extends ModuleBaseSpec { accountDao.save(account) and: "Flush metrics" - flushMetrics(pbsServiceWithMultipleModules) + flushMetrics(pbsServiceWithMultipleModule) when: "PBS processes auction request" - def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModule.sendAuctionRequest(bidRequest) then: "PBS response shouldn't include trace information about no-called modules" assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() and: "Ortb2blocking module call metrics shouldn't be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] @@ -490,7 +499,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { hooks = new AccountHooksConfiguration(admin: new AdminConfig(moduleExecution: [(ORTB2_BLOCKING): false])) } def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] - def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig) + def pbsServiceWithMultipleModule = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with verbose trace" def bidRequest = defaultBidRequest.tap { @@ -503,10 +512,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { accountDao.save(account) and: "Flush metrics" - flushMetrics(pbsServiceWithMultipleModules) + flushMetrics(pbsServiceWithMultipleModule) when: "PBS processes auction request" - def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModule.sendAuctionRequest(bidRequest) then: "PBS response should include trace information about called modules" verifyAll(response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() as List) { @@ -516,7 +525,7 @@ class GeneralModuleSpec extends ModuleBaseSpec { } and: "Ortb2blocking module call metrics should be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy index 453de43aa3c..030552c3c24 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy @@ -1,23 +1,51 @@ package org.prebid.server.functional.tests.module +import org.prebid.server.functional.model.config.AccountConfig +import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.Endpoint import org.prebid.server.functional.model.config.ExecutionPlan -import org.prebid.server.functional.model.config.Stage +import org.prebid.server.functional.model.config.ModuleHookImplementation +import org.prebid.server.functional.model.config.ModuleName +import org.prebid.server.functional.model.config.PbsModulesConfig +import org.prebid.server.functional.model.db.Account +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.BaseSpec +import spock.lang.Shared -import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING -import static org.prebid.server.functional.model.ModuleName.PB_REQUEST_CORRECTION -import static org.prebid.server.functional.model.ModuleName.PB_RESPONSE_CORRECTION -import static org.prebid.server.functional.model.ModuleName.PB_RICHMEDIA_FILTER +import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES +import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING +import static org.prebid.server.functional.model.config.ModuleName.PB_REQUEST_CORRECTION +import static org.prebid.server.functional.model.config.ModuleName.PB_RESPONSE_CORRECTION +import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION -import static org.prebid.server.functional.model.config.Stage.ALL_PROCESSED_BID_RESPONSES -import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST +import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer class ModuleBaseSpec extends BaseSpec { + protected static final String WILDCARD = '*' + private static final Map ORTB_ADAPTER_CONFIG = ['adapter-defaults.ortb.multiformat-supported': 'false'] + private static final Map MODIFYING_VAST_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false", + "adapters.generic.modifying-vast-xml-allowed": "false"] + private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true", + "adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + + protected final static Map EXTERNAL_MODULES_CONFIG = getModuleBaseSettings(PB_RICHMEDIA_FILTER) + + getModuleBaseSettings(PB_RESPONSE_CORRECTION) + + getModuleBaseSettings(ORTB2_BLOCKING) + + getModuleBaseSettings(PB_REQUEST_CORRECTION) + + @Shared + protected static PrebidServerService pbsServiceWithMultipleModules + def setupSpec() { prebidCache.setResponse() bidder.setResponse() + pbsServiceWithMultipleModules = pbsServiceFactory.getService( + IX_CONFIG + + ORTB_ADAPTER_CONFIG + + MODIFYING_VAST_CONFIG + + EXTERNAL_MODULES_CONFIG + ) } def cleanupSpec() { @@ -26,38 +54,29 @@ class ModuleBaseSpec extends BaseSpec { repository.removeAllDatabaseData() } - protected static Map getResponseCorrectionConfig(Endpoint endpoint = OPENRTB2_AUCTION) { - ["hooks.${PB_RESPONSE_CORRECTION.code}.enabled": true, - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, [(ALL_PROCESSED_BID_RESPONSES): [PB_RESPONSE_CORRECTION]]))] - .collectEntries { key, value -> [(key.toString()): value.toString()] } + protected static Map getModuleBaseSettings(ModuleName name, boolean isEnabled = true) { + [("hooks.${name.code}.enabled".toString()): isEnabled as String] } protected static Map getRichMediaFilterSettings(String scriptPattern, - Boolean filterMraidEnabled = true, - Endpoint endpoint = OPENRTB2_AUCTION) { - + Boolean filterMraidEnabled = true) { ["hooks.${PB_RICHMEDIA_FILTER.code}.enabled" : true, "hooks.modules.${PB_RICHMEDIA_FILTER.code}.mraid-script-pattern": scriptPattern, "hooks.modules.${PB_RICHMEDIA_FILTER.code}.filter-mraid" : filterMraidEnabled, - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, [(ALL_PROCESSED_BID_RESPONSES): [PB_RICHMEDIA_FILTER]]))] + "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan([PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES]))] .findAll { it.value != null } - .collectEntries { key, value -> [(key.toString()): value.toString()] } + .collectEntries { key, value -> [(key.toString()): value.toString()] + } } - protected static Map getDisabledRichMediaFilterSettings(String scriptPattern, - boolean filterMraidEnabled = true) { - ["hooks.${PB_RICHMEDIA_FILTER.code}.enabled" : false, - "hooks.modules.${PB_RICHMEDIA_FILTER.code}.mraid-script-pattern": scriptPattern, - "hooks.modules.${PB_RICHMEDIA_FILTER.code}.filter-mraid" : filterMraidEnabled] - .collectEntries { key, value -> [(key.toString()): value.toString()] } - } + protected static Account getAccountWithModuleConfig(String accountId, + List modulesHooks, + Endpoint endpoint = OPENRTB2_AUCTION) { - protected static Map getOrtb2BlockingSettings(boolean isEnabled = true) { - ["hooks.${ORTB2_BLOCKING.code}.enabled": isEnabled as String] + def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(modulesHooks, endpoint) + def accountHooksConfig = new AccountHooksConfiguration(executionPlan: executionPlan, modules: new PbsModulesConfig()) + def accountConfig = new AccountConfig(hooks: accountHooksConfig) + new Account(uuid: accountId, config: accountConfig) } - protected static Map getRequestCorrectionSettings(Endpoint endpoint = OPENRTB2_AUCTION, Stage stage = PROCESSED_AUCTION_REQUEST) { - ["hooks.${PB_REQUEST_CORRECTION.code}.enabled": "true", - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, PB_REQUEST_CORRECTION, [stage]))] - } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy index 8a99628b70c..f03a092495d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy @@ -15,12 +15,11 @@ import org.prebid.server.functional.model.request.auction.RichmediaFilter import org.prebid.server.functional.model.request.auction.StoredBidResponse import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ModuleActivityName -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING -import static org.prebid.server.functional.model.ModuleName.PB_RICHMEDIA_FILTER +import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING +import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.model.config.Stage.ALL_PROCESSED_BID_RESPONSES @@ -30,8 +29,6 @@ import static org.prebid.server.functional.model.response.auction.ErrorType.PREB class AnalyticsTagsModuleSpec extends ModuleBaseSpec { - private final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings) - def "PBS should include analytics tag for ortb2-blocking module in response when request and account allow client details"() { given: "Default account with module config" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -46,7 +43,7 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain ext.prebid.analyticsTags with module record" def analyticsTagPrebid = bidResponse.ext.prebid.analytics.tags.first @@ -123,7 +120,7 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { def accountConfig = new AccountConfig(hooks: hooksConfiguration, analytics: new AccountAnalyticsConfig(allowClientDetails: true)) and: "Prebid server with proper default account" - def pbsConfig = ['settings.default-account-config': encode(accountConfig)] + ortb2BlockingSettings + def pbsConfig = ['settings.default-account-config': encode(accountConfig)] + getModuleBaseSettings(ORTB2_BLOCKING) def pbsServiceWithDefaultAccount = pbsServiceFactory.getService(pbsConfig) and: "Bid request with enabled client details" @@ -162,7 +159,7 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { def defaultAccountConfig = new AccountConfig(hooks: defaultHooksConfiguration, analytics: new AccountAnalyticsConfig(allowClientDetails: false)) and: "Prebid server with proper default account" - def pbsConfig = ['settings.default-account-config': encode(defaultAccountConfig)] + ortb2BlockingSettings + def pbsConfig = ['settings.default-account-config': encode(defaultAccountConfig)] + getModuleBaseSettings(ORTB2_BLOCKING) def pbsServiceWithDefaultAccount = pbsServiceFactory.getService(pbsConfig) and: "Bid request with enabled client details" @@ -238,7 +235,7 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should not contain any analytics tag" assert !bidResponse?.ext?.prebid?.analytics?.tags @@ -261,7 +258,7 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should not contain any analytics tag" assert !bidResponse?.ext?.prebid?.analytics?.tags @@ -285,7 +282,7 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should not contain any analytics tag" assert !bidResponse?.ext?.prebid?.analytics?.tags diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy index bb644508090..8061b08d735 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy @@ -3,16 +3,12 @@ package org.prebid.server.functional.tests.module.ortb2blocking import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.bidder.Generic import org.prebid.server.functional.model.config.AccountAuctionConfig -import org.prebid.server.functional.model.config.AccountConfig -import org.prebid.server.functional.model.config.AccountHooksConfiguration -import org.prebid.server.functional.model.config.ExecutionPlan import org.prebid.server.functional.model.config.Ortb2BlockingActionOverride import org.prebid.server.functional.model.config.Ortb2BlockingAttributeConfig import org.prebid.server.functional.model.config.Ortb2BlockingAttribute import org.prebid.server.functional.model.config.Ortb2BlockingConditions import org.prebid.server.functional.model.config.Ortb2BlockingConfig import org.prebid.server.functional.model.config.Ortb2BlockingOverride -import org.prebid.server.functional.model.config.PbsModulesConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.Asset import org.prebid.server.functional.model.request.auction.Audio @@ -30,15 +26,14 @@ import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.model.response.auction.MediaType import org.prebid.server.functional.model.response.auction.SeatBid -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING +import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_BIDDER_REQUEST +import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_RAW_BIDDER_RESPONSE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.IX -import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.AUDIO_BATTR import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BADV import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BAPP @@ -46,23 +41,13 @@ import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.B import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BCAT import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.BTYPE import static org.prebid.server.functional.model.config.Ortb2BlockingAttribute.VIDEO_BATTR -import static org.prebid.server.functional.model.config.Stage.BIDDER_REQUEST -import static org.prebid.server.functional.model.config.Stage.RAW_BIDDER_RESPONSE import static org.prebid.server.functional.model.response.auction.BidRejectionReason.RESPONSE_REJECTED_ADVERTISER_BLOCKED import static org.prebid.server.functional.model.response.auction.MediaType.AUDIO import static org.prebid.server.functional.model.response.auction.MediaType.BANNER import static org.prebid.server.functional.model.response.auction.MediaType.VIDEO -import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer class Ortb2BlockingSpec extends ModuleBaseSpec { - private static final String WILDCARD = '*' - private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true", - "adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - - private final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings + IX_CONFIG + - ['adapter-defaults.ortb.multiformat-supported': 'false']) - def "PBS should send original array ortb2 attribute to bidder when enforce blocking is disabled"() { given: "Default bid request with proper ortb attribute" def bidRequest = getBidRequestForOrtbAttribute(attributeName) @@ -78,7 +63,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should contain proper ortb2 attributes from account config" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -117,7 +102,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes the auction request" - pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should contain proper ortb2 attributes from account config" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -147,7 +132,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request shouldn't contain ortb2 attributes from account config for any media-type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -192,7 +177,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request shouldn't contain ortb2 attributes from account config for any media-type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -238,7 +223,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request shouldn't contain ortb2 attributes from account config for any media-type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -277,7 +262,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain seatNonBid for the called bidder" assert response.ext.prebid.modules.errors.ortb2Blocking["ortb2-blocking-bidder-request"].first @@ -310,7 +295,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain seatNonBid for the called bidder" assert response.ext.prebid.modules.errors.ortb2Blocking["ortb2-blocking-bidder-request"].first @@ -352,7 +337,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response shouldn't contain any seatbid" assert !response.seatbid @@ -392,7 +377,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only allowed seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -458,7 +443,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only allowed seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -496,7 +481,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain proper seatbid" assert getOrtb2Attributes(response.seatbid.first.bid.first, attributeName) == [ortb2Attributes]*.toString() @@ -543,7 +528,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only allowed seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -574,7 +559,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only allowed seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -617,7 +602,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only allowed seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -648,7 +633,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only allowed seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -684,7 +669,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only allowed seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -725,7 +710,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response shouldn't contain any seatbid" assert !response.seatbid.bid.flatten().size() @@ -769,7 +754,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only openx seatbid" assert response.seatbid.size() == 1 @@ -817,7 +802,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only banner seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -867,7 +852,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain banner seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -921,7 +906,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response shouldn't contain any seatbid" assert !response.seatbid.bid.flatten().size() @@ -964,7 +949,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only seatbid with proper deal id" assert response.seatbid.bid.flatten().size() == 1 @@ -1013,7 +998,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should override blocked ortb2 attribute" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1056,7 +1041,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should override blocked ortb2 attribute" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1105,7 +1090,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only ix seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -1142,7 +1127,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain banner seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -1181,7 +1166,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only ix seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -1216,7 +1201,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain banner seatbid" assert response.seatbid.bid.flatten().size() == 1 @@ -1251,7 +1236,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only seatbid with proper deal id" assert response.seatbid.bid.flatten().size() == 1 @@ -1294,7 +1279,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should override blocked ortb2 attribute" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1344,7 +1329,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should override blocked ortb2 attribute" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1387,7 +1372,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should override blocked ortb2 attribute" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1432,7 +1417,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain only seatbid with proper deal id" assert response.seatbid.bid.flatten().size() == 1 @@ -1468,7 +1453,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS request should contain original ortb2 attribute" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1510,7 +1495,7 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes the auction request" - def response = pbsServiceWithEnabledOrtb2Blocking.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS response should contain seatNonBid for the called bidder" assert response.ext.seatnonbid.size() == 1 @@ -1526,12 +1511,9 @@ class Ortb2BlockingSpec extends ModuleBaseSpec { } private static Account getAccountWithOrtb2BlockingConfig(String accountId, Map attributes) { - def blockingConfig = new Ortb2BlockingConfig(attributes: attributes) - def executionPlan = ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, ORTB2_BLOCKING, [BIDDER_REQUEST, RAW_BIDDER_RESPONSE]) - def moduleConfig = new PbsModulesConfig(ortb2Blocking: blockingConfig) - def accountHooksConfig = new AccountHooksConfiguration(executionPlan: executionPlan, modules: moduleConfig) - def accountConfig = new AccountConfig(hooks: accountHooksConfig) - new Account(uuid: accountId, config: accountConfig) + getAccountWithModuleConfig(accountId, [ORTB2_BLOCKING_BIDDER_REQUEST, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE]).tap { + it.config.hooks.modules.ortb2Blocking = new Ortb2BlockingConfig(attributes: attributes) + } } private static BidRequest getBidRequestForOrtbAttribute(Ortb2BlockingAttribute attribute, List attributeValue = null) { 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 68b00bdd0d1..8d76ea8dcd0 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 @@ -11,10 +11,10 @@ import org.prebid.server.functional.model.request.auction.AppPrebid 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 -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils +import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_REQUEST_CORRECTION_PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP import static org.prebid.server.functional.model.request.auction.OperationState.YES @@ -27,8 +27,6 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { private static final String ANDROID = "android" private static final String IOS = "IOS" - private PrebidServerService pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(requestCorrectionSettings) - def "PBS should remove positive instl from imps for android app when request correction is enabled for account"() { given: "Android APP bid request with version lover then version threshold" def prebid = new AppPrebid(source: PBSUtils.getRandomCase(PREBID_MOBILE), version: ACCEPTABLE_DEVICE_INSTL_VERSION_THRESHOLD) @@ -43,7 +41,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request shouldn't contain imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -76,7 +74,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain original imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -104,7 +102,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain original imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -134,7 +132,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain original imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -163,7 +161,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain original imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -185,7 +183,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain original imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -207,7 +205,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain original imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -237,7 +235,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain original imp.instl" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -257,7 +255,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request shouldn't contain device.ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -285,7 +283,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain device.ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -315,7 +313,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain device.ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -344,7 +342,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain device.ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -373,7 +371,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain device.ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -394,7 +392,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain device.ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -415,7 +413,7 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain device.ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -437,18 +435,16 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsServiceWithRequestCorrectionModule.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bidder request should contain request device ua" def bidderRequest = bidder.getBidderRequest(bidRequest.id) assert bidderRequest.device.ua == deviceUa } - private static Account createAccountWithRequestCorrectionConfig(BidRequest bidRequest, - PbRequestCorrectionConfig requestCorrectionConfig) { - def pbsModulesConfig = new PbsModulesConfig(pbRequestCorrection: requestCorrectionConfig) - def accountHooksConfig = new AccountHooksConfiguration(modules: pbsModulesConfig) - def accountConfig = new AccountConfig(hooks: accountHooksConfig) - new Account(uuid: bidRequest.accountId, config: accountConfig) + private static Account createAccountWithRequestCorrectionConfig(BidRequest bidRequest, PbRequestCorrectionConfig requestCorrectionConfig) { + getAccountWithModuleConfig(bidRequest.accountId, [PB_REQUEST_CORRECTION_PROCESSED_AUCTION_REQUEST]).tap { + it.config.hooks.modules.pbRequestCorrection = requestCorrectionConfig + } } } 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 c848c30e2e4..8e5731e7ff5 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 @@ -1,10 +1,7 @@ package org.prebid.server.functional.tests.module.responsecorrenction -import org.prebid.server.functional.model.config.AccountConfig -import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.AppVideoHtml import org.prebid.server.functional.model.config.PbResponseCorrection -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.Imp @@ -13,13 +10,13 @@ import org.prebid.server.functional.model.response.auction.BidExt import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.Meta import org.prebid.server.functional.model.response.auction.Prebid -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils import java.time.Instant import static org.prebid.server.functional.model.bidder.BidderName.GENERIC +import static org.prebid.server.functional.model.config.ModuleHookImplementation.RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES import static org.prebid.server.functional.model.request.auction.BidRequest.getDefaultBidRequest import static org.prebid.server.functional.model.request.auction.BidRequest.getDefaultVideoRequest import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP @@ -32,11 +29,6 @@ import static org.prebid.server.functional.model.response.auction.MediaType.VIDE class ResponseCorrectionSpec extends ModuleBaseSpec { - private final PrebidServerService pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService( - ["adapter-defaults.modifying-vast-xml-allowed": "false", - "adapters.generic.modifying-vast-xml-allowed": "false"] + - responseCorrectionConfig) - private final static int OPTIMAL_MAX_LENGTH = 20 def "PBS shouldn't modify response when in account correction module disabled"() { @@ -57,10 +49,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS shouldn't emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, bidResponse.seatbid[0].bid[0].id).size() == 0 and: "Response should contain seatBid" @@ -100,10 +92,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS shouldn't emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, bidResponse.seatbid[0].bid[0].id).size() == 0 and: "Response should contain seatBid" @@ -142,10 +134,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS shouldn't emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, bidResponse.seatbid[0].bid[0].id).size() == 0 and: "Response should contain seatBid" @@ -177,10 +169,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection[0].contains("Bid $bidId of bidder generic has an JSON ADM, that appears to be native" as String) @@ -216,10 +208,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS shouldn't emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, bidResponse.seatbid[0].bid[0].id).size() == 0 and: "Response should contain seatBid" @@ -259,10 +251,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection[0].contains("Bid $bidId of bidder generic has an JSON ADM, that appears to be native" as String) @@ -300,10 +292,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS shouldn't emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, bidResponse.seatbid[0].bid[0].id).size() == 0 and: "Response should contain seatBid" @@ -337,10 +329,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS shouldn't emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, bidResponse.seatbid[0].bid[0].id).size() == 0 and: "Response should contain seatBid" @@ -384,10 +376,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection.size() == 1 @@ -439,10 +431,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection.size() == 1 @@ -494,10 +486,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection.size() == 1 @@ -542,10 +534,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection.size() == 2 @@ -572,10 +564,13 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { assert !response.ext.warnings } - private static Account accountConfigWithResponseCorrectionModule(BidRequest bidRequest, Boolean enabledResponseCorrection = true, Boolean enabledAppVideoHtml = true) { - def modulesConfig = new PbsModulesConfig(pbResponseCorrection: new PbResponseCorrection( - enabled: enabledResponseCorrection, appVideoHtml: new AppVideoHtml(enabled: enabledAppVideoHtml))) - def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: modulesConfig)) - new Account(uuid: bidRequest.getAccountId(), config: accountConfig) + private static Account accountConfigWithResponseCorrectionModule(BidRequest bidRequest, + Boolean enabledResponseCorrection = true, + Boolean enabledAppVideoHtml = true) { + + getAccountWithModuleConfig(bidRequest.accountId, [RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES]).tap { + it.config.hooks.modules.pbResponseCorrection = new PbResponseCorrection( + enabled: enabledResponseCorrection, appVideoHtml: new AppVideoHtml(enabled: enabledAppVideoHtml)) + } } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy index c49743b275b..1b040cc3ab0 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy @@ -16,8 +16,9 @@ import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils +import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES import static org.prebid.server.functional.model.response.auction.BidRejectionReason.RESPONSE_REJECTED_INVALID_CREATIVE -import static org.prebid.server.functional.model.ModuleName.PB_RICHMEDIA_FILTER +import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.model.config.Stage.ALL_PROCESSED_BID_RESPONSES @@ -27,19 +28,31 @@ class RichMediaFilterSpec extends ModuleBaseSpec { private static final String PATTERN_NAME = PBSUtils.randomString private static final String PATTERN_NAME_ACCOUNT = PBSUtils.randomString - private final PrebidServerService pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME)) - private final PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService( - (getRichMediaFilterSettings(PATTERN_NAME) + ["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap { + private static final Map DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME, false) + private static final Map SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME) + private static final Map SNAKE_SPECIFIC_PATTERN_NAME_CONFIG = (getRichMediaFilterSettings(PATTERN_NAME) + + ["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap { endpoints.values().first().stages.values().first().groups.first.hookSequenceSnakeCase = [new HookId(moduleCodeSnakeCase: PB_RICHMEDIA_FILTER.code, hookImplCodeSnakeCase: "${PB_RICHMEDIA_FILTER.code}-${ALL_PROCESSED_BID_RESPONSES.value}-hook")] - })]) - .collectEntries { key, value -> [(key.toString()): value.toString()] }) - private final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME, false)) + })]).collectEntries { key, value -> [(key.toString()): value.toString()] } - def "PBS should process request without rich media module when host config have empty settings"() { - given: "Prebid server with empty settings for module" - def prebidServerService = pbsServiceFactory.getService(pbsConfig) + private static PrebidServerService pbsServiceWithDisabledMediaFilter + private static PrebidServerService pbsServiceWithEnabledMediaFilter + private static PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy - and: "BidRequest with stored response" + def setupSpec() { + pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG) + } + + def cleanupSpec() { + pbsServiceFactory.removeContainer(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceFactory.removeContainer(SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceFactory.removeContainer(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG) + } + + def "PBS should process request without rich media module when host config have empty settings"() { + given: "BidRequest with stored response" def storedResponseId = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.returnAllBidStatus = true @@ -54,12 +67,12 @@ class RichMediaFilterSpec extends ModuleBaseSpec { def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse) storedResponseDao.save(storedResponse) - and: "Account in the DB" - def account = new Account(uuid: bidRequest.getAccountId()) + and: "Account with enabled richMedia config in the DB" + def account = getAccountWithRichmediaFilter(bidRequest.accountId, filterMraid, mraidScriptPattern) accountDao.save(account) when: "PBS processes auction request" - def response = prebidServerService.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Response header should contain seatbid" assert response.seatbid.size() == 1 @@ -70,14 +83,12 @@ class RichMediaFilterSpec extends ModuleBaseSpec { and: "Response shouldn't contain analytics" assert !getAnalyticResults(response) - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) - where: - pbsConfig << [getRichMediaFilterSettings(PBSUtils.randomString, null), - getRichMediaFilterSettings(null, true), - getRichMediaFilterSettings(null, false), - getRichMediaFilterSettings(null, null)] + filterMraid | mraidScriptPattern + true | PBSUtils.randomString + true | null + false | null + null | null } def "PBS should process request without analytics when adm matches with pattern name and filter set to disabled in host config"() { @@ -97,7 +108,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { storedResponseDao.save(storedResponse) and: "Account in the DB" - def account = new Account(uuid: bidRequest.getAccountId()) + def account = new Account(uuid: bidRequest.accountId) accountDao.save(account) when: "PBS processes auction request" @@ -133,7 +144,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { storedResponseDao.save(storedResponse) and: "Account in the DB" - def account = new Account(uuid: bidRequest.getAccountId()) + def account = new Account(uuid: bidRequest.accountId) accountDao.save(account) when: "PBS processes auction request" @@ -160,7 +171,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { admValue << [PATTERN_NAME, "${PBSUtils.randomString}-${PATTERN_NAME}", "${PATTERN_NAME}.${PBSUtils.randomString}"] } - def "PBS should process request without analytics when adm is #admValue and filter enabled in host config"() { + def "PBS should process request without analytics when adm is #admValue and filter enabled in config"() { given: "BidRequest with stored response" def storedResponseId = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { @@ -177,9 +188,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { storedResponseDao.save(storedResponse) and: "Account with enabled richMedia config in the DB" - def richMediaFilterConfig = new PbsModulesConfig(pbRichmediaFilter: new RichmediaFilter(filterMraid: true)) - def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: richMediaFilterConfig)) - def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) + def account = getAccountWithRichmediaFilter(bidRequest.accountId, true, null) accountDao.save(account) when: "PBS processes auction request" @@ -208,9 +217,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { } and: "Account with enabled richMedia config in the DB" - def richMediaFilterConfig = new PbsModulesConfig(pbRichmediaFilter: new RichmediaFilter(filterMraid: true, mraidScriptPattern: PATTERN_NAME)) - def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: richMediaFilterConfig)) - def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) + def account = getAccountWithRichmediaFilter(bidRequest.accountId, true, PATTERN_NAME) accountDao.save(account) and: "Stored bid response in DB" @@ -254,9 +261,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { } and: "Account with disabled richMedia config in the DB" - def richMediaFilterConfig = new PbsModulesConfig(pbRichmediaFilter: new RichmediaFilter(filterMraid: false, mraidScriptPattern: PATTERN_NAME)) - def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: richMediaFilterConfig)) - def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) + def account = getAccountWithRichmediaFilter(bidRequest.accountId, false, PATTERN_NAME) accountDao.save(account) and: "Stored bid response in DB" @@ -292,9 +297,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { } and: "Account with enabled richMedia config in the DB" - def richMediaFilterConfig = new PbsModulesConfig(pbRichmediaFilter: new RichmediaFilter(filterMraid: true, mraidScriptPattern: PATTERN_NAME_ACCOUNT)) - def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: richMediaFilterConfig)) - def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) + def account = getAccountWithRichmediaFilter(bidRequest.accountId, true, PATTERN_NAME_ACCOUNT) accountDao.save(account) and: "Stored bid response in DB" @@ -335,9 +338,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { } and: "Account with enabled richMedia config in the DB" - def richMediaFilterConfig = new PbsModulesConfig(pbRichmediaFilter: new RichmediaFilter(filterMraid: true, mraidScriptPattern: PATTERN_NAME_ACCOUNT)) - def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: richMediaFilterConfig)) - def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) + def account = getAccountWithRichmediaFilter(bidRequest.accountId, true, PATTERN_NAME_ACCOUNT) accountDao.save(account) and: "Stored bid response in DB" @@ -362,7 +363,10 @@ class RichMediaFilterSpec extends ModuleBaseSpec { def "PBS should process any request without analytics and errors when pb-richmedia-filter hook is disabled"() { given: "PBS with disabled pb-richmedia-filter hook" - def pbsServiceWithDisabledMediaFilterHook = pbsServiceFactory.getService(getDisabledRichMediaFilterSettings(PATTERN_NAME)) + def pbsConfig = getRichMediaFilterSettings(PATTERN_NAME) + + getModuleBaseSettings(PB_RICHMEDIA_FILTER, false) + + ["hooks.host-execution-plan": null] + def pbsServiceWithDisabledMediaFilterHook = pbsServiceFactory.getService(pbsConfig) and: "BidRequest with stored response" def storedResponseId = PBSUtils.randomNumber @@ -375,7 +379,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { and: "Account with enabled richMedia config in the DB" def richMediaFilterConfig = new PbsModulesConfig(pbRichmediaFilter: new RichmediaFilter(filterMraid: true, mraidScriptPattern: PATTERN_NAME_ACCOUNT)) def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: richMediaFilterConfig)) - def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig) + def account = new Account(uuid: bidRequest.accountId, config: accountConfig) accountDao.save(account) and: "Stored bid response in DB" @@ -397,6 +401,9 @@ class RichMediaFilterSpec extends ModuleBaseSpec { and: "Response shouldn't contain analytics" assert !getAnalyticResults(response) + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: admValue << [PATTERN_NAME, PATTERN_NAME_ACCOUNT] } @@ -418,7 +425,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { storedResponseDao.save(storedResponse) and: "Account in the DB" - def account = new Account(uuid: bidRequest.getAccountId()) + def account = new Account(uuid: bidRequest.accountId) accountDao.save(account) when: "PBS processes auction request" @@ -450,4 +457,10 @@ class RichMediaFilterSpec extends ModuleBaseSpec { ?.outcomes?.first()?.groups?.first() ?.invocationResults?.first()?.analyticsTags?.activities } + + private static Account getAccountWithRichmediaFilter(String accountId, Boolean filterMraid, String mraidScriptPattern) { + getAccountWithModuleConfig(accountId, [PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES]).tap { + it.config.hooks.modules.pbRichmediaFilter = new RichmediaFilter(filterMraid: filterMraid, mraidScriptPattern: mraidScriptPattern) + } + } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy index e0c3b279200..b3f732d7a2f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/ActivityTraceLogSpec.groovy @@ -398,8 +398,8 @@ class ActivityTraceLogSpec extends PrivacyBaseSpec { allow << [false, true] } - private List getActivityByName(List activityInfrastructures, - ActivityType activity) { + private static List getActivityByName(List activityInfrastructures, + ActivityType activity) { def firstIndex = activityInfrastructures.findLastIndexOf { it -> it.activity == activity } def lastIndex = activityInfrastructures.findIndexOf { it -> it.activity == activity } activityInfrastructures[new IntRange(true, firstIndex, lastIndex)] diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy index 134aa10c9a4..f93a014f058 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy @@ -192,7 +192,7 @@ class CoppaSpec extends PrivacyBaseSpec { bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.lat == bidRequest.user.geo.lat bidderRequest.user.geo.lon == bidRequest.user.geo.lon - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Metrics processed across activities shouldn't be updated" @@ -396,7 +396,7 @@ class CoppaSpec extends PrivacyBaseSpec { bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequest.user.geo.lon == ampStoredRequest.user.geo.lon - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Metrics processed across activities shouldn't be updated" 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 771fac9bd84..6876668470d 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 @@ -647,7 +647,7 @@ class GdprAmpSpec extends PrivacyBaseSpec { bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequest.user.geo.lon == ampStoredRequest.user.geo.lon - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Metrics processed across activities shouldn't be updated" 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 351875e5f90..a7fb7795397 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 @@ -768,7 +768,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.lat == bidRequest.user.geo.lat bidderRequest.user.geo.lon == bidRequest.user.geo.lon - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Metrics processed across activities shouldn't be updated" diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index bbb019d515d..38f45160b6c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -124,7 +124,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -302,7 +302,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -397,7 +397,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -519,7 +519,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -649,7 +649,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -767,7 +767,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.zip == bidRequest.user.geo.zip - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1213,7 +1213,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1269,7 +1269,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1324,7 +1324,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1410,7 +1410,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1700,7 +1700,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1903,7 +1903,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2075,7 +2075,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2505,7 +2505,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2569,7 +2569,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2633,7 +2633,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2737,7 +2737,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3088,7 +3088,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { it.user.yob = PBSUtils.randomNumber it.user.gender = PBSUtils.randomString it.user.geo = Geo.FPDGeo - it.user.ext = new UserExt(data: new UserExtData(buyeruid: PBSUtils.randomString)) + it.user.ext = new UserExt(data: new UserExtData(buyerUid: PBSUtils.randomString)) it.regs.ext ?= new RegsExt() } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy index 4966fe43ddf..4f13b59ff9c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy @@ -517,7 +517,7 @@ class LmtSpec extends PrivacyBaseSpec { bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.lat == bidRequest.user.geo.lat bidderRequest.user.geo.lon == bidRequest.user.geo.lon - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Metrics processed across activities shouldn't be updated" @@ -656,7 +656,7 @@ class LmtSpec extends PrivacyBaseSpec { bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo.lat == ampStoredRequest.user.geo.lat bidderRequest.user.geo.lon == ampStoredRequest.user.geo.lon - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Metrics processed across activities shouldn't be updated" 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 d4cbf17e2dd..f8c43d6ed9a 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 @@ -172,7 +172,7 @@ abstract class PrivacyBaseSpec extends BaseSpec { yob = PBSUtils.randomNumber gender = PBSUtils.randomString geo = Geo.FPDGeo - ext = new UserExt(data: new UserExtData(buyeruid: PBSUtils.randomString)) + ext = new UserExt(data: new UserExtData(buyerUid: PBSUtils.randomString)) } } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy index 538705e3b68..b7cdcc3c4f1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy @@ -122,17 +122,17 @@ class PrometheusSpec extends BaseSpec { serviceFailedToStartTimeoutMs) } - private Map getBasePrometheusConfig() { + private static Map getBasePrometheusConfig() { ["metrics.prometheus.enabled": "true", "metrics.prometheus.port" : PROMETHEUS_PORT as String] } - private Map getNamespaceSubsystemConfig(String namespace, String subsystem) { + private static Map getNamespaceSubsystemConfig(String namespace, String subsystem) { ["metrics.prometheus.namespace": namespace, "metrics.prometheus.subsystem": subsystem] } - private String normalizeMetricName(String metricName) { + private static String normalizeMetricName(String metricName) { metricName.replace(".", "_") .replace("-", "_") } diff --git a/src/test/groovy/org/prebid/server/functional/tests/storage/AmpS3Spec.groovy b/src/test/groovy/org/prebid/server/functional/tests/storage/AmpS3Spec.groovy index e6dda6b407c..08f2ef25aed 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/storage/AmpS3Spec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/storage/AmpS3Spec.groovy @@ -78,12 +78,6 @@ class AmpS3Spec extends StorageBaseSpec { account = PBSUtils.randomNumber as String } - and: "Default stored request" - def ampStoredRequest = BidRequest.defaultStoredRequest.tap { - site = Site.defaultSite - setAccountId(ampRequest.account) - } - and: "Stored request in S3 service" s3Service.uploadFile(DEFAULT_BUCKET, INVALID_FILE_BODY, "${S3Service.DEFAULT_REQUEST_DIR}/${ampRequest.tagId}.json") diff --git a/src/test/groovy/org/prebid/server/functional/tests/storage/AuctionS3Spec.groovy b/src/test/groovy/org/prebid/server/functional/tests/storage/AuctionS3Spec.groovy index 51d39dd5af9..cc7eb6ad188 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/storage/AuctionS3Spec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/storage/AuctionS3Spec.groovy @@ -53,7 +53,7 @@ class AuctionS3Spec extends StorageBaseSpec { } and: "Save storedImp with different impId into S3 service" - def secureStoredRequest = PBSUtils.getRandomNumber(0, 1) + def secureStoredRequest = PBSUtils.getRandomEnum(SecurityLevel) def storedImp = StoredImp.getStoredImp(bidRequest).tap { impId = PBSUtils.randomString impData = Imp.defaultImpression.tap { diff --git a/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy index 583d6d97e06..2b1e37736fb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy @@ -51,6 +51,5 @@ class StorageBaseSpec extends BaseSpec { 'settings.database.stored-responses-query' : null ].asImmutable() as Map - protected PrebidServerService s3StoragePbsService = PbsServiceFactory.getService(s3StorageConfig + mySqlDisabledConfig) } diff --git a/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy b/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy index c1f60516abf..1417bdb4558 100644 --- a/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/HttpUtil.groovy @@ -7,7 +7,6 @@ import static java.nio.charset.StandardCharsets.UTF_8 class HttpUtil implements ObjectMapperWrapper { - public static final String ACCEPT_HEADER = "Authorization" public static final String CONTENT_TYPE_HEADER = "Content-Type" public static final String COOKIE_HEADER = "cookie" diff --git a/src/test/groovy/org/prebid/server/functional/util/privacy/model/State.groovy b/src/test/groovy/org/prebid/server/functional/util/privacy/model/State.groovy index 9af51dceea3..1e56f4a4d88 100644 --- a/src/test/groovy/org/prebid/server/functional/util/privacy/model/State.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/privacy/model/State.groovy @@ -8,8 +8,7 @@ enum State { //USA states ALABAMA("AL"), ALASKA("AK"), ARIZONA("AZ"); - - final String abbreviation; + final String abbreviation State(String abbreviation) { this.abbreviation = abbreviation From ec3b6a23bf6e83164a3098952b2d35dbd656336e Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Thu, 16 Jan 2025 19:50:27 +0200 Subject: [PATCH 02/25] Refactoring functional tests --- .../org/prebid/server/functional/model/config/Stage.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy b/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy index 3cc450219d9..ba787025f28 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy @@ -25,7 +25,11 @@ enum Stage { } static Stage forValue(ModuleHookImplementation moduleHook) { - values().find { moduleHook.code.contains(it.value) } + values() + .collect { [stage: it, matchLength: moduleHook.code.indexOf(it.value) >= 0 ? it.value.length() : -1] } + .findAll { it.matchLength > 0 } + .max { it.matchLength } + ?.stage } @Override From a31c436b9bb58ee26023b535cb89d9d958b30809 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Tue, 4 Feb 2025 20:10:02 +0200 Subject: [PATCH 03/25] Resolve conflicts --- .../tests/module/AbTestingModuleSpec.groovy | 5 ++--- .../module/ortb2blocking/Ortb2BlockingSpec.groovy | 12 ------------ .../PbRequestCorrectionSpec.groovy | 6 ------ .../ResponseCorrectionSpec.groovy | 9 --------- .../module/richmedia/RichMediaFilterSpec.groovy | 13 ++++++++++--- 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index c1a0794b8b4..8325eaacdee 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -48,12 +48,11 @@ class AbTestingModuleSpec extends ModuleBaseSpec { private final static Map MULTI_MODULE_CONFIG = getModuleBaseSettings(PB_RESPONSE_CORRECTION) + getModuleBaseSettings(ModuleName.ORTB2_BLOCKING) + ['hooks.host-execution-plan': null] - private static final PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings()) + private static final PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) private static final PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG) def cleanupSpec() { - pbsServiceFactory.removeContainer(getOrtb2BlockingSettings()) - pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG) + pbsServiceFactory.removeContainer(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) } def "PBS shouldn't apply a/b test config when config of ab test is disabled"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy index 4317cb23f3b..8061b08d735 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy @@ -48,18 +48,6 @@ import static org.prebid.server.functional.model.response.auction.MediaType.VIDE class Ortb2BlockingSpec extends ModuleBaseSpec { - private static final String WILDCARD = '*' - private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true", - "adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - private static final Map PBS_CONFIG = getOrtb2BlockingSettings() + IX_CONFIG + - ['adapter-defaults.ortb.multiformat-supported': 'false'] - - private static final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(PBS_CONFIG) - - def cleanupSpec() { - pbsServiceFactory.removeContainer(PBS_CONFIG) - } - def "PBS should send original array ortb2 attribute to bidder when enforce blocking is disabled"() { given: "Default bid request with proper ortb attribute" def bidRequest = getBidRequestForOrtbAttribute(attributeName) 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 d7e997dadcb..8d76ea8dcd0 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 @@ -27,12 +27,6 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { private static final String ANDROID = "android" private static final String IOS = "IOS" - private static final PrebidServerService pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(getRequestCorrectionSettings()) - - def cleanupSpec() { - pbsServiceFactory.removeContainer(getRequestCorrectionSettings()) - } - def "PBS should remove positive instl from imps for android app when request correction is enabled for account"() { given: "Android APP bid request with version lover then version threshold" def prebid = new AppPrebid(source: PBSUtils.getRandomCase(PREBID_MOBILE), version: ACCEPTABLE_DEVICE_INSTL_VERSION_THRESHOLD) 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 d4e2cc929c1..8e5731e7ff5 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 @@ -30,15 +30,6 @@ import static org.prebid.server.functional.model.response.auction.MediaType.VIDE class ResponseCorrectionSpec extends ModuleBaseSpec { private final static int OPTIMAL_MAX_LENGTH = 20 - private static final Map PBS_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false", - "adapters.generic.modifying-vast-xml-allowed": "false"] + - getResponseCorrectionConfig() - - private static final PrebidServerService pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService(PBS_CONFIG) - - def cleanupSpec() { - pbsServiceFactory.removeContainer(PBS_CONFIG) - } def "PBS shouldn't modify response when in account correction module disabled"() { given: "Start up time" diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy index fed9f8a095d..c42267767f6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy @@ -35,9 +35,16 @@ class RichMediaFilterSpec extends ModuleBaseSpec { endpoints.values().first().stages.values().first().groups.first.hookSequenceSnakeCase = [new HookId(moduleCodeSnakeCase: PB_RICHMEDIA_FILTER.code, hookImplCodeSnakeCase: "${PB_RICHMEDIA_FILTER.code}-${ALL_PROCESSED_BID_RESPONSES.value}-hook")] })]).collectEntries { key, value -> [(key.toString()): value.toString()] } - private static final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) - private static final PrebidServerService pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG) - private static final PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG) + private static PrebidServerService pbsServiceWithDisabledMediaFilter + private static PrebidServerService pbsServiceWithEnabledMediaFilter + private static PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy + + + def setupSpec() { + pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG) + } def cleanupSpec() { pbsServiceFactory.removeContainer(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) From ed705d0788622588cbfee0d31df1390c00921b36 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Wed, 5 Feb 2025 20:06:56 +0200 Subject: [PATCH 04/25] update clean up for tests --- .../server/functional/tests/AliasSpec.groovy | 7 +- .../functional/tests/AuctionSpec.groovy | 33 +- .../tests/BidExpResponseSpec.groovy | 7 + .../tests/BidderInsensitiveCaseSpec.groovy | 17 +- .../server/functional/tests/CacheSpec.groovy | 12 +- .../functional/tests/CookieSyncSpec.groovy | 305 ++++++++++++------ .../functional/tests/CurrencySpec.groovy | 5 + .../server/functional/tests/DebugSpec.groovy | 51 ++- .../server/functional/tests/EidsSpec.groovy | 18 +- .../tests/FilterMultiFormatSpec.groovy | 147 +++------ .../server/functional/tests/GeoSpec.groovy | 1 + .../functional/tests/HttpSettingsSpec.groovy | 5 + .../functional/tests/ImpRequestSpec.groovy | 7 +- .../functional/tests/MetricsSpec.groovy | 7 +- .../functional/tests/OrtbConverterSpec.groovy | 12 +- .../server/functional/tests/SchainSpec.groovy | 26 +- .../functional/tests/SeatNonBidSpec.groovy | 21 +- .../tests/StoredResponseSpec.groovy | 6 +- .../functional/tests/TargetingSpec.groovy | 66 ++-- .../functional/tests/TimeoutSpec.groovy | 13 +- .../functional/tests/TopicsHeaderSpec.groovy | 9 +- .../server/functional/tests/UUIDSpec.groovy | 142 ++++---- .../functional/tests/UserSyncSpec.groovy | 107 +++--- .../tests/module/AbTestingModuleSpec.groovy | 1 - .../AnalyticsTagsModuleSpec.groovy | 3 + .../pricefloors/PriceFloorsBaseSpec.groovy | 5 + .../PriceFloorsCurrencySpec.groovy | 12 +- .../PriceFloorsEnforcementSpec.groovy | 28 +- .../PriceFloorsFetchingSpec.groovy | 20 +- .../pricefloors/PriceFloorsRulesSpec.groovy | 18 +- .../PriceFloorsSignalingSpec.groovy | 16 +- .../tests/prometheus/PrometheusSpec.groovy | 19 +- .../tests/storage/AccountS3Spec.groovy | 14 +- .../tests/storage/StorageBaseSpec.groovy | 2 +- 34 files changed, 712 insertions(+), 450 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/AliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AliasSpec.groovy index 1ead8c32708..6748b5332d8 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AliasSpec.groovy @@ -79,8 +79,8 @@ class AliasSpec extends BaseSpec { def "PBS should apply compression type for bidder alias when adapters.BIDDER.endpoint-compression = gzip"() { given: "PBS with adapter configuration" def compressionType = GZIP.value - def pbsService = pbsServiceFactory.getService( - ["adapters.generic.endpoint-compression": compressionType]) + def pbsConfig = ["adapters.generic.endpoint-compression": compressionType] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with alias" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -94,6 +94,9 @@ class AliasSpec extends BaseSpec { then: "Bidder request should contain header Content-Encoding = gzip" assert response.ext?.debug?.httpcalls?.get(ALIAS.value)?.requestHeaders?.first() ?.get(CONTENT_ENCODING_HEADER)?.first() == compressionType + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should return an error when GVL Id alias refers to unknown bidder alias"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy index f9b9688d4da..edf2e8f25d6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy @@ -181,9 +181,11 @@ class AuctionSpec extends BaseSpec { def "PBS should populate buyeruid from uids cookie when buyeruids with appropriate bidder but without value present in request"() { given: "PBS config" - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, - "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, + "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) + and: "Bid request with buyeruids" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -200,13 +202,17 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the uids cookie" def bidderRequest = bidder.getBidderRequest(bidRequest.id) assert bidderRequest?.user?.buyeruid == uidsCookie.tempUIDs[GENERIC].uid + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate buyeruid from uids cookie when buyeruids with appropriate bidder but without value present in request"() { given: "PBS config" - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, - "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, + "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request with buyeruids" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -222,6 +228,9 @@ class AuctionSpec extends BaseSpec { then: "Bidder request shouldn't contain buyeruid from the uids cookie" def bidderRequest = bidder.getBidderRequest(bidRequest.id) assert !bidderRequest.user.buyeruid + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should take precedence buyeruids whenever present valid uid cookie"() { @@ -269,10 +278,11 @@ class AuctionSpec extends BaseSpec { def "PBS shouldn't populate buyeruid from cookie name config when host cookie family not matched with requested cookie-family-name"() { given: "PBS config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + GENERIC_CONFIG - + ["host-cookie.family" : APPNEXUS.value, - "host-cookie.cookie-name" : cookieName, - "adapters.generic.usersync.cookie-family-name": GENERIC.value]) + def pbsConfig = PBS_CONFIG + GENERIC_CONFIG + + ["host-cookie.family" : APPNEXUS.value, + "host-cookie.cookie-name" : cookieName, + "adapters.generic.usersync.cookie-family-name": GENERIC.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request" def bidRequest = BidRequest.defaultBidRequest @@ -287,6 +297,9 @@ class AuctionSpec extends BaseSpec { then: "Bidder request shouldn't contain buyeruid from cookieName" def bidderRequest = bidder.getBidderRequest(bidRequest.id) assert !bidderRequest.user + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate buyeruid from cookie when cookie-name in cookie and config are diferent"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy index 74ac930fa9d..18be37c5dcc 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.config.AccountAuctionConfig import org.prebid.server.functional.model.config.AccountConfig +import org.prebid.server.functional.model.config.ModuleName 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.Imp @@ -33,6 +34,12 @@ class BidExpResponseSpec extends BaseSpec { private static def pbsEmptyTtlService = pbsServiceFactory.getService(EMPTY_CACHE_TTL_CONFIG + EMPTY_CACHE_TTL_HOST_CONFIG) private static def pbsHostAndDefaultCacheTtlService = pbsServiceFactory.getService(CACHE_TTL_HOST_CONFIG + DEFAULT_CACHE_TTL_CONFIG) + def cleanupSpec() { + pbsServiceFactory.removeContainer(CACHE_TTL_HOST_CONFIG + EMPTY_CACHE_TTL_CONFIG) + pbsServiceFactory.removeContainer(EMPTY_CACHE_TTL_CONFIG + EMPTY_CACHE_TTL_HOST_CONFIG) + pbsServiceFactory.removeContainer(CACHE_TTL_HOST_CONFIG + DEFAULT_CACHE_TTL_CONFIG) + } + def "PBS auction should resolve bid.exp from response that is set by the bidder’s adapter"() { given: "Default basicResponse with exp" def bidResponseExp = PBSUtils.randomNumber diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy index 36f5332b7f5..a6dc63f08f8 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy @@ -282,9 +282,9 @@ class BidderInsensitiveCaseSpec extends BaseSpec { def "PBS should respond errors with same bidder name which bidder name came in request with another case strategy"() { given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - ["adapter-defaults.enabled": "false", - "adapters.generic.enabled": "false"]) + def pbsConfig = ["adapter-defaults.enabled": "false", + "adapters.generic.enabled": "false"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -299,13 +299,15 @@ class BidderInsensitiveCaseSpec extends BaseSpec { then: "Response should contain error" assert response.ext?.errors[ErrorType.GENERIC_CAMEL_CASE]*.code == [2] + + } def "PBS should respond warnings with same bidder name which bidder name came in request with another case strategy"() { given: "Pbs config" - def pbsService = pbsServiceFactory.getService( - ["auction.filter-imp-media-type.enabled" : "true", - "adapters.generic.meta-info.app-media-types": ""]) + def pbsConfig = ["auction.filter-imp-media-type.enabled" : "true", + "adapters.generic.meta-info.app-media-types": ""] + def pbsService = pbsServiceFactory.getService(pbsConfig) def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { imp[0].ext.prebid.bidder.tap { @@ -324,6 +326,9 @@ class BidderInsensitiveCaseSpec extends BaseSpec { assert response.ext?.warnings[ErrorType.GENERIC_CAMEL_CASE]*.code == [2] assert response.ext?.warnings[ErrorType.GENERIC_CAMEL_CASE]*.message == ["Bidder does not support any media types."] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should respond responsetimemillis with same bidder name which bidder name came in request with another case strategy"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy index 4f8dcf7675e..109f90fbeb1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy @@ -97,7 +97,8 @@ class CacheSpec extends BaseSpec { def "PBS should cache bids without api-key header when targeting is specified and api-key-secured disabled"() { given: "Pbs config with disabled api-key-secured and pbc.api.key" def apiKey = PBSUtils.randomString - def pbsService = pbsServiceFactory.getService(['pbc.api.key': apiKey, 'cache.api-key-secured': 'false']) + def pbsConfig = ['pbc.api.key': apiKey, 'cache.api-key-secured': 'false'] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.defaultBidRequest @@ -113,12 +114,16 @@ class CacheSpec extends BaseSpec { and: "PBS call shouldn't include api-key" assert !prebidCache.getRequestHeaders(bidRequest.imp[0].id)[PBS_API_HEADER] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should cache bids with api-key header when targeting is specified and api-key-secured enabled"() { given: "Pbs config with api-key-secured and pbc.api.key" def apiKey = PBSUtils.randomString - def pbsService = pbsServiceFactory.getService(['pbc.api.key': apiKey, 'cache.api-key-secured': 'true']) + def pbsConfig = ['pbc.api.key': apiKey, 'cache.api-key-secured': 'true'] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.defaultBidRequest @@ -134,6 +139,9 @@ class CacheSpec extends BaseSpec { and: "PBS call should include api-key" assert prebidCache.getRequestHeaders(bidRequest.imp[0].id)[PBS_API_HEADER] == [apiKey] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should not cache bids when targeting isn't specified"() { 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 29542fd8326..3429ffc0342 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy @@ -99,12 +99,17 @@ class CookieSyncSpec extends BaseSpec { private final PrebidServerService prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) + def cleanupSpec() { + pbsServiceFactory.removeContainer(PBS_CONFIG) + } + def "PBS cookie sync request should replace synced as family bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG + APPNEXUS_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null]) + def pbsConfig = GENERIC_CONFIG + APPNEXUS_CONFIG + +["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def requestLimit = 2 @@ -127,12 +132,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(GENERIC) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace bidder without config and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG - + ["adapters.${BOGUS.value}.enabled": "true"]) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + ["adapters.${BOGUS.value}.enabled": "true"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default Cookie sync request" def requestLimit = 2 @@ -155,11 +163,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace unknown bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request" def requestLimit = 2 @@ -182,12 +194,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace disabled bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG - + ["adapters.${GENERIC.value}.enabled": "false",]) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + ["adapters.${GENERIC.value}.enabled": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default Cookie sync request" def requestLimit = 2 @@ -210,11 +225,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace filtered bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request" def requestLimit = 2 @@ -238,12 +257,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder disabled"() { given: "PBS bidder config " - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.enabled": "false"]) + def pbsConfig = PBS_CONFIG + ["adapters.${GENERIC.value}.enabled": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -256,12 +278,15 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't return error" assert !response.getBidderUserSync(GENERIC) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder without sync config"() { given: "PBS bidder config without cookie family name" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.usersync.cookie-family-name": null]) + def pbsConfig = ["adapters.${GENERIC.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -274,6 +299,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't return error" assert !response.getBidderUserSync(GENERIC) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder family already in uids cookie"() { @@ -294,9 +322,10 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder synced as family"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null,]) + def pbsConfig = GENERIC_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -309,6 +338,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't return error" assert !response.getBidderUserSync(bidderAlias) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder with gdpr"() { @@ -341,8 +373,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder with ccpa"() { given: "PBS bidder config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${bidderName.value}.ccpa-enforced": "true"] + GENERIC_CONFIG) + def pbsConfig = ["adapters.${bidderName.value}.ccpa-enforced": "true"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with account and privacy" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -364,6 +396,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain error" def bidderStatus = response.getBidderUserSync(bidderName) assert bidderStatus.error == "Rejected by CCPA" + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder filtered"() { @@ -420,8 +455,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request should reflect error even when response is full by PBS config limit"() { given: "PBS config with expanded limit" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with coop-sync and without bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -442,6 +477,9 @@ class CookieSyncSpec extends BaseSpec { assert bogusBidderStatus?.error == "Unsupported bidder" assert bogusBidderStatus?.noCookie == null assert bogusBidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should reflect error even when response is full by request limit"() { @@ -525,8 +563,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync should be able to define cookie family name"() { given: "PBS bidder config with defined cookie family name" def bidder = BOGUS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value]) + def pbsConfig = PBS_CONFIG + ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -544,13 +582,17 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.userSync?.type == USER_SYNC_TYPE assert bidderStatus?.userSync?.supportCORS == CORS_SUPPORT assert bidderStatus?.noCookie == true + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync should be able to read custom cookie family name from uids cookie"() { given: "PBS bidder config with defined cookie family name" def bidder = BOGUS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + - ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -568,6 +610,9 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus.error == "Already in sync" assert bidderStatus?.userSync == null assert bidderStatus?.noCookie == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with unknown bidder respond with an error for that bidder"() { @@ -599,8 +644,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request with bidder without cookie family name should emit an error"() { given: "PBS bidder config without cookie family name" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.usersync.cookie-family-name": null]) + def pbsConfig = ["adapters.${GENERIC.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -613,12 +658,15 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "No sync config" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with disabled bidder should emit an error"() { given: "PBS config with disabled bidder" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.enabled": "false"]) + def pbsConfig = ["adapters.${GENERIC.value}.enabled": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -631,13 +679,16 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "Disabled bidder" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with enabled coop-sync should sync all enabled bidders"() { given: "PBS config with expanded limit" def countOfEnabledBidders = 3 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": countOfEnabledBidders.toString()] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": countOfEnabledBidders.toString()] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with coop-sync and without bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -650,14 +701,18 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain all 3 enabled bidders" assert response.bidderStatus.size() == countOfEnabledBidders + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with alias bidder should sync as the source bidder when alias doesn't override cookie-family-name"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -677,14 +732,18 @@ class CookieSyncSpec extends BaseSpec { assert mainBidderStatus?.userSync?.type == USER_SYNC_TYPE assert mainBidderStatus?.userSync?.supportCORS == CORS_SUPPORT assert mainBidderStatus?.noCookie == true + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with alias bidder should sync independently when alias provide cookie-family-name"() { given: "PBS config with alias bidder with cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": bidderAlias.value]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": bidderAlias.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -702,14 +761,17 @@ class CookieSyncSpec extends BaseSpec { assert it.userSync?.supportCORS == CORS_SUPPORT assert it.noCookie == true } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie should return bidder sync with host cookie uid when there is no uids cookie"() { given: "PBS bidders config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : GENERIC.value, - "host-cookie.cookie-name": cookieName] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : GENERIC.value, + "host-cookie.cookie-name": cookieName] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def uidsCookie = UidsCookie.defaultUidsCookie @@ -727,14 +789,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain uid from cookies" def bidderStatus = response.getBidderUserSync(GENERIC) assert HttpUtil.decodeUrl(bidderStatus.userSync?.url).contains("uid=${uid}") + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie should return bidder sync with host cookie uid when uids are different"() { given: "PBS bidders config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : GENERIC.value, - "host-cookie.cookie-name": cookieName] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : GENERIC.value, + "host-cookie.cookie-name": cookieName] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def uidsCookie = UidsCookie.defaultUidsCookie.tap { @@ -754,14 +819,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain uid from cookies" def bidderStatus = response.getBidderUserSync(GENERIC) assert HttpUtil.decodeUrl(bidderStatus.userSync?.url).contains("uid=${hostCookieUid}") + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie should return an error when host cookie uid matches uids cookie uid for bidder"() { given: "PBS bidders config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : GENERIC.value, - "host-cookie.cookie-name": cookieName] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : GENERIC.value, + "host-cookie.cookie-name": cookieName] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -783,13 +851,16 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "Already in sync" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie shouldn't return bidder sync when host cookie doesn't match requested bidder"() { given: "PBS bidders config" - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : PBSUtils.randomString, - "host-cookie.cookie-name": PBSUtils.randomString] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : PBSUtils.randomString, + "host-cookie.cookie-name": PBSUtils.randomString] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -814,9 +885,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request with host cookie shouldn't return bidder sync when host cookie doesn't have configured name"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : bidderName.value, - "host-cookie.cookie-name": null] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : bidderName.value, + "host-cookie.cookie-name": null] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def uidsCookie = UidsCookie.defaultUidsCookie @@ -832,6 +903,9 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "Already in sync" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync without cookie-sync.default-limit config and with cookie sync account config limit should use limit from request"() { @@ -860,8 +934,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.default-limit config should use limit from cookie sync account config"() { given: "PBS bidders config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "2"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": "2"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def accountId = PBSUtils.randomNumber @@ -883,12 +957,15 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain one synced bidder" assert response.bidderStatus.size() == accountDefaultLimit + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.default-limit config should use limit from request"() { given: "PBS config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "2"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": "2"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def requestLimit = 1 @@ -903,13 +980,16 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain only two synced bidder" assert response.bidderStatus.size() == requestLimit + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.default-limit config should use limit from PBS config"() { given: "PBS config" def defaultLimit = 1 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": defaultLimit.toString()] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": defaultLimit.toString()] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -922,14 +1002,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain only one synced bidder" assert response.bidderStatus.size() == defaultLimit + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.max-limit should use max-limit from PBS config"() { given: "PBS bidders config" def maxLimit = 2 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.max-limit" : maxLimit.toString(), - "cookie-sync.default-limit": "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.max-limit" : maxLimit.toString(), + "cookie-sync.default-limit": "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -943,13 +1026,16 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain only one synced bidder" assert response.bidderStatus.size() == maxLimit + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.max-limit should use max-limit from cookie sync account config"() { given: "PBS bidders config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "1", - "cookie-sync.max-limit" : "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": "1", + "cookie-sync.max-limit" : "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def accountId = PBSUtils.randomNumber @@ -981,9 +1067,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.pri and enabled coop-sync in config should sync bidder which present in cookie-sync.pri config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.coop-sync.default": "true", - "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.coop-sync.default": "true", + "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -998,14 +1084,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.pri and disabled coop-sync in config shouldn't sync bidder which present in cookie-sync.pir config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.coop-sync.default": "false", - "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.coop-sync.default": "false", + "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1046,13 +1135,13 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't contain generic bidder which present in cookie-sync.pri config" assert !response.getBidderUserSync(bidderName) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync should sync bidder by limit value"() { - given: "PBS config with bidders usersync config" - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) - - and: "Default cookie sync request with 2 bidders and limit of 1" + given: "Default cookie sync request with 2 bidders and limit of 1" def limit = 1 def bidders = [GENERIC, RUBICON] def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1174,9 +1263,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.pri and enabled coop sync should sync bidder which present in cookie-sync.pri"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with coop-sync" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1191,14 +1280,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with pri and enabled coop sync in cookie sync account should sync bidder which present in pir account config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : "null", - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : "null", + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber @@ -1221,14 +1313,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with coop-sync.default config and pri in cookie sync account should sync bidder which present in pir account config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : "null", - "cookie-sync.coop-sync.default": "true"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : "null", + "cookie-sync.coop-sync.default": "true"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber @@ -1251,14 +1346,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.pri and enabled coop sync in account should sync bidder which present in cookie-sync.pir config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber @@ -1281,14 +1379,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.pri and disabled coop-sync in request shouldn't sync bidder which present in cookie-sync.pri config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1301,6 +1402,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't contain generic bidder" assert !response.getBidderUserSync(bidderName) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with filter setting should reject bidder sync"() { @@ -1348,8 +1452,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with ccpa should reject bidder sync"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.ccpa-enforced": "true"] + GENERIC_CONFIG) + def pbsConfig = ["adapters.${GENERIC.value}.ccpa-enforced": "true"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Flush metrics" flushMetrics(prebidServerService) @@ -1372,14 +1476,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain error" def bidderStatus = response.getBidderUserSync(GENERIC) assert bidderStatus.error == "Rejected by CCPA" + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync should emit error when requested bidder rejected by limit"() { given: "PBS config with bidders usersync config" def limit = 1 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.max-limit" : limit as String, - "cookie-sync.default-limit": limit as String] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.max-limit" : limit as String, + "cookie-sync.default-limit": limit as String] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 2 bidders" def bidders = [GENERIC, RUBICON] @@ -1398,13 +1505,16 @@ class CookieSyncSpec extends BaseSpec { def rejectedBidderUserSyncs = getRejectedBidderUserSyncs(response) assert rejectedBidderUserSyncs.size() == bidders.size() - limit assert rejectedBidderUserSyncs.every { it.value == "limit reached" } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync shouldn't emit error limit reached when bidder coop-synced"() { given: "PBS config with bidders usersync config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.max-limit" : "1", - "cookie-sync.default-limit": "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.max-limit" : "1", + "cookie-sync.default-limit": "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1417,6 +1527,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't contain generic bidder" assert !response.getBidderUserSync(GENERIC) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should successful pass when request body empty"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy index df5bba70028..86aeb7fdb0a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.Currency +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.mock.services.currencyconversion.CurrencyConversionRatesResponse import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.response.auction.BidResponse @@ -32,6 +33,10 @@ class CurrencySpec extends BaseSpec { } private static final PrebidServerService pbsService = pbsServiceFactory.getService(externalCurrencyConverterConfig) + def cleanupSpec() { + pbsServiceFactory.removeContainer(externalCurrencyConverterConfig) + } + def "PBS should return currency rates"() { when: "PBS processes bidders params request" def response = pbsService.withWarmup().sendCurrencyRatesRequest() diff --git a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy index ea169ad00ee..22dd16b2b9a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy @@ -14,6 +14,7 @@ import org.prebid.server.functional.model.request.auction.StoredBidResponse import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature @@ -33,6 +34,14 @@ class DebugSpec extends BaseSpec { private static final String ACCOUNT_DEBUG_REQUESTS_METRIC = "account.%s.debug_requests" private static final String REQUEST_OK_WEB_METRICS = "requests.ok.openrtb2-web" + private static final PrebidServerService enabledDebugPbsService = pbsServiceFactory.getService("adapters.generic.debug.allow": "true") + private static final PrebidServerService disabledDebugPbsService = pbsServiceFactory.getService("adapters.generic.debug.allow": "false") + + def cleanupSpec() { + pbsServiceFactory.removeContainer("adapters.generic.debug.allow": "true") + pbsServiceFactory.removeContainer("adapters.generic.debug.allow": "false") + } + def "PBS should return debug information and emit metrics when debug flag is #debug and test flag is #test"() { given: "Default BidRequest with test flag" def bidRequest = BidRequest.defaultBidRequest @@ -92,15 +101,12 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = false"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "false"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = disabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug?.httpcalls @@ -112,15 +118,12 @@ class DebugSpec extends BaseSpec { } def "PBS should return debug information when bidder-level setting debug.allowed = true"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "true"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = enabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should contain ext.debug" assert response.ext?.debug?.httpcalls[GENERIC.value] @@ -130,10 +133,7 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = false is overridden by account-level setting debug-allowed = false"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "false"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED @@ -142,7 +142,7 @@ class DebugSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = disabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug @@ -160,10 +160,7 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = false is overridden by account-level setting debug-allowed = true"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "false"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED @@ -172,7 +169,7 @@ class DebugSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = disabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug?.httpcalls @@ -189,10 +186,7 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = true is overridden by account-level setting debug-allowed = false"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "true"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED @@ -202,7 +196,7 @@ class DebugSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = enabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug @@ -230,7 +224,7 @@ class DebugSpec extends BaseSpec { def "PBS should return debug information when bidder-level setting debug.allowed = #debugAllowedConfig and account-level setting debug-allowed = #debugAllowedAccount is overridden by x-pbs-debug-override header"() { given: "PBS with debug configuration" - def pbsService = pbsServiceFactory.getService(pbdConfig) + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest @@ -250,8 +244,11 @@ class DebugSpec extends BaseSpec { and: "Response should not contain ext.warnings" assert !response.ext?.warnings + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: - debugAllowedConfig | debugAllowedAccount | pbdConfig + debugAllowedConfig | debugAllowedAccount | pbsConfig false | true | ["debug.override-token" : overrideToken, "adapters.generic.debug.allow": "false"] true | false | ["debug.override-token" : overrideToken, diff --git a/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy index 46b0ff2a5aa..b4d266cd456 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy @@ -159,9 +159,9 @@ class EidsSpec extends BaseSpec { def "PBs eid permissions should affect only specified on source"() { given: "PBs with openx bidder" - def pbsService = pbsServiceFactory.getService( - ["adapters.openx.enabled" : "true", - "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()]) + def pbsConfig = ["adapters.openx.enabled" : "true", + "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with eidpremissions and openx bidder" def eidSource = PBSUtils.randomString @@ -186,13 +186,16 @@ class EidsSpec extends BaseSpec { and: "Openx bidder should contain two eids" assert bidderRequests[OPENX.value].user.eids.sort().last.sort() == eids.sort() + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBs eid permissions for non existing source should not stop auction"() { given: "PBs with openx bidder" - def pbsService = pbsServiceFactory.getService( - ["adapters.openx.enabled" : "true", - "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()]) + def pbsConfig = ["adapters.openx.enabled" : "true", + "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with eidpremissions and openx bidder" def firstEid = new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)]) @@ -215,6 +218,9 @@ class EidsSpec extends BaseSpec { bidderRequests.user.eids.each { assert it.sort() == [secondEid, firstEid].sort() } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBs missing bidders in eid permissions should throw an error"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy index 1d36b8beadc..7640a98bead 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy @@ -20,12 +20,25 @@ import static org.prebid.server.functional.model.response.auction.MediaType.NULL class FilterMultiFormatSpec extends BaseSpec { - def "PBS should respond with all requested media types when default adapters multi format is true in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "true") + private static final Map ENABLED_MULTI_FORMAT = ["adapter-defaults.ortb.multiformat-supported": "true"] + private static final Map DISABLED_MULTI_FORMAT = ["adapter-defaults.ortb.multiformat-supported": "false"] + private static final Map DISABLED_MULTI_FORMAT_DEFAULT = [ + "adapter-defaults.ortb.multiformat-supported": "false", + "adapters.generic.ortb.multiformat-supported": "false" + ] + + private static def enabledMultiFormatPbsService = pbsServiceFactory.getService(ENABLED_MULTI_FORMAT) + private static def disabledMultiFormatPbsService = pbsServiceFactory.getService(DISABLED_MULTI_FORMAT) + private static def disabledMultiFormatDefaultPbsService = pbsServiceFactory.getService(DISABLED_MULTI_FORMAT_DEFAULT) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(ENABLED_MULTI_FORMAT) + pbsServiceFactory.removeContainer(DISABLED_MULTI_FORMAT) + pbsServiceFactory.removeContainer(DISABLED_MULTI_FORMAT_DEFAULT) + } - and: "Default bid request with banner and audio type" + def "PBS should respond with all requested media types when default adapters multi format is true in config and preferred media type specified at account level"() { + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -37,7 +50,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -46,11 +59,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with all requested media types when default adapters multi format is true in config and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "true") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -58,7 +67,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -73,11 +82,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when default adapters multi format is false in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -89,7 +94,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -98,11 +103,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when default adapters multi format is false in config and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -110,7 +111,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -125,11 +126,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with all requested media type when multi format is true in config and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "true") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -137,7 +134,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -152,11 +149,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with all requested media type when multi format is true in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "true") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -168,7 +161,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -177,11 +170,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when multi format is false in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -193,7 +182,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -202,11 +191,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when multi format is false in config and preferred media type preferred at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -214,7 +199,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -229,11 +214,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with warning and don't make a bidder call when multi format at request and preferred media type specified at account level with non requested media type"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type" + given: "Default bid request with audio and nativeObj type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -246,7 +227,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS shouldn't make bidder request" assert !bidder.getBidderRequests(bidRequest.id) @@ -258,11 +239,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with warning and don't make a bidder call when multi format at request and preferred media type specified at request level with non requested media type"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" + given: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -271,7 +248,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS shouldn't make bidder request" assert !bidder.getBidderRequests(bidRequest.id) @@ -289,11 +266,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type" + given: "Default bid request with audio and nativeObj type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -305,7 +278,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" def bidderRequests = bidder.getBidderRequests(bidRequest.id) @@ -316,11 +289,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" + given: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -328,7 +297,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" def bidderRequests = bidder.getBidderRequests(bidRequest.id) @@ -345,11 +314,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and multi format is false and preferred media type specified at request level with null"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.getDefaultBanner() imp[0].audio = Audio.defaultAudio @@ -357,7 +322,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -373,11 +338,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and multi format is false and preferred media type specified at account level with null"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.getDefaultBanner() imp[0].audio = Audio.defaultAudio @@ -389,7 +350,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -399,12 +360,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with preferred media type that specified in request when preferred media type specified in both places"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false", - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -417,7 +373,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatDefaultPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -432,12 +388,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should not preferred media type specified at request level when it's alias bidder"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false", - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with alias" + given: "Default bid request with alias" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].tap { banner = Banner.defaultBanner @@ -459,7 +410,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatDefaultPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain preferred media type from account config" def bidderRequest = bidder.getBidderRequest(bidRequest.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy index 3d19d9d878d..808d16ccb04 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy @@ -23,6 +23,7 @@ import static org.prebid.server.functional.util.privacy.model.State.QUEBEC class GeoSpec extends BaseSpec { + // TODO refactor containers for this spec private static final String GEO_LOCATION_REQUESTS = "geolocation_requests" private static final String GEO_LOCATION_FAIL = "geolocation_fail" private static final String GEO_LOCATION_SUCCESSFUL = "geolocation_successful" diff --git a/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy index 2c6d1556a81..3ebed4dce5e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.UidsCookie +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.mock.services.httpsettings.HttpAccountsResponse import org.prebid.server.functional.model.request.amp.AmpRequest @@ -29,6 +30,10 @@ class HttpSettingsSpec extends BaseSpec { @Shared PrebidServerService prebidServerService = pbsServiceFactory.getService(PbsConfig.httpSettingsConfig) + def cleanupSpec() { + pbsServiceFactory.removeContainer(PbsConfig.httpSettingsConfig) + } + def "PBS should take account information from http data source on auction request"() { given: "Get basic BidRequest with generic bidder and set gdpr = 1" def bidRequest = BidRequest.defaultBidRequest diff --git a/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy index 4cc3b728449..a3c85e640ba 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.bidder.Generic import org.prebid.server.functional.model.bidder.Openx +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.StoredImp import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp @@ -24,9 +25,13 @@ import static org.prebid.server.functional.testcontainers.Dependencies.getNetwor class ImpRequestSpec extends BaseSpec { - private final PrebidServerService defaultPbsServiceWithAlias = pbsServiceFactory.getService(GENERIC_ALIAS_CONFIG) + private static final PrebidServerService defaultPbsServiceWithAlias = pbsServiceFactory.getService(GENERIC_ALIAS_CONFIG) private static final String EMPTY_ID = "" + def cleanupSpec() { + pbsServiceFactory.removeContainer(GENERIC_ALIAS_CONFIG) + } + def "PBS should update imp fields when imp.ext.prebid.imp contain bidder information"() { given: "Default basic BidRequest" def extPmp = Pmp.defaultPmp diff --git a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy index 92ef175681e..02d43469d67 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountMetricsConfig +import org.prebid.server.functional.model.config.ModuleName 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.Dooh @@ -17,13 +18,17 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class MetricsSpec extends BaseSpec { - private final PrebidServerService softPrebidService = pbsServiceFactory.getService(['auction.strict-app-site-dooh': 'false']) + private static final PrebidServerService softPrebidService = pbsServiceFactory.getService(['auction.strict-app-site-dooh': 'false']) def setup() { flushMetrics(defaultPbsService) flushMetrics(softPrebidService) } + def cleanupSpec() { + pbsServiceFactory.removeContainer(['auction.strict-app-site-dooh': 'false']) + } + def "PBS should not populate account metric when verbosity level is none"() { given: "Default basic BidRequest with generic bidder" def bidRequest = BidRequest.defaultBidRequest diff --git a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy index 21bb80df135..213aeacf64d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.auction.Audio import org.prebid.server.functional.model.request.auction.BidRequest @@ -36,11 +37,18 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class OrtbConverterSpec extends BaseSpec { private final static String ORTB_PROPERTY_VERSION = "adapters.generic.ortb-version" + private static final Map ORTB_2_6 = [(ORTB_PROPERTY_VERSION): "2.6"] + private static final Map ORTB_2_5 = [(ORTB_PROPERTY_VERSION): "2.5"] @Shared - PrebidServerService prebidServerServiceWithNewOrtb = pbsServiceFactory.getService([(ORTB_PROPERTY_VERSION): "2.6"]) + PrebidServerService prebidServerServiceWithNewOrtb = pbsServiceFactory.getService(ORTB_2_6) @Shared - PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService([(ORTB_PROPERTY_VERSION): "2.5"]) + PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService(ORTB_2_5) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(ORTB_2_5) + pbsServiceFactory.removeContainer(ORTB_2_6) + } def "PBS shouldn't move regs.{gdpr,usPrivacy} to regs.ext.{gdpr,usPrivacy} when adapter support ortb 2.6"() { given: "Default bid request with regs object" diff --git a/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy index db67f6ce397..1f0994c912d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy @@ -23,8 +23,18 @@ class SchainSpec extends BaseSpec { rid = PBSUtils.randomString } + private static final Map SCHAIN_NODE_CONFIG = ["auction.host-schain-node": encode(GLOBAL_SUPPLY_SCHAIN_NODE)] + private static final Map ORTB_2_5_CONFIG = ["adapters.generic.ortb-version": "2.5"] + + @Shared + PrebidServerService prebidServerService = pbsServiceFactory.getService(SCHAIN_NODE_CONFIG) @Shared - PrebidServerService prebidServerService = pbsServiceFactory.getService(["auction.host-schain-node": encode(GLOBAL_SUPPLY_SCHAIN_NODE)]) + PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService(ORTB_2_5_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(SCHAIN_NODE_CONFIG) + pbsServiceFactory.removeContainer(ORTB_2_5_CONFIG) + } def "Global schain node should be appended when only ext.prebid.schains exists"() { given: "Basic bid request" @@ -158,10 +168,7 @@ class SchainSpec extends BaseSpec { } def "PBS should use source.ext.schain when ext.prebid.schains.bidder isn't requested"() { - given: "Pbs config" - def defaultPbsService = pbsServiceFactory.getService([("adapters.generic.ortb-version"): "2.5"]) - - and: "Default basic BidRequest with schain obj" + given: "Default basic BidRequest with schain obj" def supplyChain = SupplyChain.defaultSupplyChain def bidRequest = BidRequest.defaultBidRequest.tap { source = new Source(ext: new SourceExt(schain: supplyChain)) @@ -169,7 +176,7 @@ class SchainSpec extends BaseSpec { } when: "PBS processes auction request" - defaultPbsService.sendAuctionRequest(bidRequest) + prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) then: "Bidder request should contain requested source.ext.schain" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -178,10 +185,7 @@ class SchainSpec extends BaseSpec { } def "PBS should use ext.prebid.schains.schain instead of source.ext.chain when ext.prebid.schains.bidder is requested"() { - given: "Pbs config" - def defaultPbsService = pbsServiceFactory.getService([("adapters.generic.ortb-version"): "2.5"]) - - and: "Default basic BidRequest with schain obj" + given: "Default basic BidRequest with schain obj" def supplyChain = SupplyChain.defaultSupplyChain def bidRequest = BidRequest.defaultBidRequest.tap { source = new Source(ext: new SourceExt(schain: SupplyChain.defaultSupplyChain)) @@ -189,7 +193,7 @@ class SchainSpec extends BaseSpec { } when: "PBS processes auction request" - defaultPbsService.sendAuctionRequest(bidRequest) + prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) then: "Bidder request should contain requested ext.prebid.schains[*].schain" def bidderRequest = bidder.getBidderRequest(bidRequest.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy index f6b02f22e76..c738b5b6573 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy @@ -145,7 +145,8 @@ class SeatNonBidSpec extends BaseSpec { def "PBS should populate seatNonBid when returnAllBidStatus=true and requested bidder responded with not secure status code"() { given: "PBS with secure-markup enforcement" - def pbsService = pbsServiceFactory.getService(["auction.validations.secure-markup": ENFORCE.value]) + def pbsConfig = ["auction.validations.secure-markup": ENFORCE.value] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "A bid request with secure and returnAllBidStatus flags set" def bidRequest = requestWithAllBidStatus.tap { @@ -175,6 +176,9 @@ class SeatNonBidSpec extends BaseSpec { and: "PBS response shouldn't contain seatBid" assert !response.seatbid + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate seatNonBid when returnAllBidStatus=true and bidder successfully bids"() { @@ -256,7 +260,8 @@ class SeatNonBidSpec extends BaseSpec { def "PBS should populate seatNonBid when bidder is rejected due to timeout"() { given: "PBS config with min and max time-out" def timeout = 50 - def pbsService = pbsServiceFactory.getService(["auction.biddertmax.min": timeout as String]) + def pbsConfig = ["auction.biddertmax.min": timeout as String] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with max timeout" def bidRequest = requestWithAllBidStatus.tap { @@ -280,13 +285,16 @@ class SeatNonBidSpec extends BaseSpec { assert seatNonBid.seat == GENERIC.value assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id assert seatNonBid.nonBid[0].statusCode == ERROR_TIMED_OUT + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should populate seatNonBid when filter-imp-media-type=true and imp doesn't contain supported media type"() { given: "Pbs config" - def pbsService = pbsServiceFactory.getService( - ["auction.filter-imp-media-type.enabled" : "true", - "adapters.generic.meta-info.site-media-types": "banner"]) + def pbsConfig = ["auction.filter-imp-media-type.enabled" : "true", + "adapters.generic.meta-info.site-media-types": "banner"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with banner" def bidRequest = BidRequest.defaultVideoRequest.tap { @@ -307,6 +315,9 @@ class SeatNonBidSpec extends BaseSpec { and: "seatbid should be empty" assert response.seatbid.isEmpty() + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate seatNonBid when returnAllBidStatus=true and storedAuctionResponse present"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy index 467402dc331..1ec48d08096 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy @@ -18,7 +18,11 @@ import static org.prebid.server.functional.model.bidder.BidderName.GENERIC class StoredResponseSpec extends BaseSpec { - private final PrebidServerService pbsService = pbsServiceFactory.getService(EMPTY_CACHE_TTL_CONFIG) + private static final PrebidServerService pbsService = pbsServiceFactory.getService(EMPTY_CACHE_TTL_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(EMPTY_CACHE_TTL_CONFIG) + } @PendingFeature def "PBS should not fail auction with storedAuctionResponse when request bidder params doesn't satisfy json-schema"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy index 9cf3e9a6da9..1b1d0cff359 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy @@ -409,6 +409,9 @@ class TargetingSpec extends BaseSpec { .every(list -> list .every(map -> map.keySet() .every(key -> key.length() <= targetingLength))) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should truncate targeting corresponding to value in account config when in account define truncate target attr"() { @@ -867,8 +870,8 @@ class TargetingSpec extends BaseSpec { def "PBS amp should use long account targeting prefix when settings.targeting.truncate-attr-chars override"() { given: "PBS config with setting.targeting" def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": prefixMaxChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -893,13 +896,16 @@ class TargetingSpec extends BaseSpec { def targeting = ampResponse.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS amp should use long request targeting prefix when settings.targeting.truncate-attr-chars override"() { given: "PBS config with setting.targeting" def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": prefixMaxChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -921,13 +927,16 @@ class TargetingSpec extends BaseSpec { def targeting = ampResponse.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should use long request targeting prefix when settings.targeting.truncate-attr-chars override"() { given: "PBS config with setting.targeting" def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": prefixMaxChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request with prefix" def prefix = PBSUtils.getRandomString(prefixMaxChars - TARGETING_PREFIX_LENGTH) @@ -942,13 +951,16 @@ class TargetingSpec extends BaseSpec { def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should use long account targeting prefix when settings.targeting.truncate-attr-chars override"() { given: "PBS config with setting.targeting" def prefixMaxChars = PBSUtils.getRandomNumber(35, MAX_TRUNCATE_ATTR_CHARS) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": prefixMaxChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": prefixMaxChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request with empty targeting" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -968,13 +980,16 @@ class TargetingSpec extends BaseSpec { def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS amp should ignore and add a warning to ext.warnings when value of the account prefix is longer then settings.targeting.truncate-attr-chars"() { given: "PBS config with setting.targeting" def targetingChars = PBSUtils.getRandomNumber(2, 10) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": targetingChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -999,13 +1014,16 @@ class TargetingSpec extends BaseSpec { assert ampResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + "Decrease custom prefix length or increase truncateattrchars by " + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS amp should ignore and add a warning to ext.warnings when value of the request prefix is longer then settings.targeting.truncate-attr-chars"() { given: "PBS config with setting.targeting" def targetingChars = PBSUtils.getRandomNumber(2, 10) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": targetingChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default AmpRequest" def ampRequest = AmpRequest.defaultAmpRequest @@ -1027,13 +1045,16 @@ class TargetingSpec extends BaseSpec { assert ampResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + "Decrease custom prefix length or increase truncateattrchars by " + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should ignore and add a warning to ext.warnings when value of the request prefix is longer then settings.targeting.truncate-attr-chars"() { given: "PBS config with setting.targeting" def targetingChars = PBSUtils.getRandomNumber(2, 10) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": targetingChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request with prefix" def prefixSize = targetingChars + 1 @@ -1052,13 +1073,16 @@ class TargetingSpec extends BaseSpec { assert bidResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + "Decrease custom prefix length or increase truncateattrchars by " + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should ignore and add a warning to ext.warnings when value of the account prefix is longer then settings.targeting.truncate-attr-chars"() { given: "PBS config with setting.targeting" def targetingChars = PBSUtils.getRandomNumber(2, 10) - def prebidServerService = pbsServiceFactory.getService( - ["settings.targeting.truncate-attr-chars": targetingChars as String]) + def pbsConfig = ["settings.targeting.truncate-attr-chars": targetingChars as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -1081,6 +1105,9 @@ class TargetingSpec extends BaseSpec { assert bidResponse.ext?.warnings[TARGETING]*.message == ["Key prefix value is dropped to default. " + "Decrease custom prefix length or increase truncateattrchars by " + "${prefix.length() + TARGETING_PREFIX_LENGTH - targetingChars}"] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS amp should apply data from query to ext.prebid.amp.data"() { @@ -1246,8 +1273,8 @@ class TargetingSpec extends BaseSpec { def priceGranularity = PBSUtils.getRandomEnum(PriceGranularityType, [UNKNOWN]) def accountAuctionConfig = new AccountAuctionConfig(priceGranularity: priceGranularity) def accountConfig = new AccountConfig(status: ACTIVE, auction: accountAuctionConfig) - def pbsService = pbsServiceFactory.getService( - ["settings.default-account-config": encode(accountConfig)]) + def pbsConfig = ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -1260,6 +1287,9 @@ class TargetingSpec extends BaseSpec { then: "BidderRequest should include price granularity from account config" def bidderRequest = bidder.getBidderRequest(bidRequest.id) assert bidderRequest?.ext?.prebid?.targeting?.priceGranularity == PriceGranularity.getDefault(priceGranularity) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should include include default price granularity when original request and account config doesn't contain price granularity"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy index cff45989db1..fe246682e8b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy @@ -24,6 +24,10 @@ class TimeoutSpec extends BaseSpec { @Shared PrebidServerService prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) + def cleanupSpec() { + pbsServiceFactory.removeContainer(PBS_CONFIG) + } + def "PBS should apply timeout from stored request when it's not specified in the auction request"() { given: "Default basic BidRequest with generic bidder" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -287,9 +291,9 @@ class TimeoutSpec extends BaseSpec { def "PBS should choose min timeout form config for bidder request when in request value lowest that in auction.biddertmax.min"() { given: "PBS config with percent" def minBidderTmax = PBSUtils.getRandomNumber(MIN_TIMEOUT, MAX_TIMEOUT) - def prebidServerService = pbsServiceFactory.getService( - ["auction.biddertmax.min": minBidderTmax as String, - "auction.biddertmax.max": MAX_TIMEOUT as String]) + def pbsConfig = ["auction.biddertmax.min": minBidderTmax as String, + "auction.biddertmax.max": MAX_TIMEOUT as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest" def timeout = PBSUtils.getRandomNumber(0, minBidderTmax) @@ -306,6 +310,9 @@ class TimeoutSpec extends BaseSpec { and: "PBS response should contain tmax from request" assert bidResponse?.ext?.tmaxrequest == timeout as Long + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should change timeout for bidder due to percent in auction.biddertmax.percent"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy index ea2bbebb67e..279d408ef83 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy @@ -15,8 +15,13 @@ class TopicsHeaderSpec extends BaseSpec { private static final DEFAULT_SEGTAX_VALUE = 599 private static final PRIVACY_SENDBOX_DOMAIN = "privacy-sandbox-domain" - private final PrebidServerService prebidServerServiceWithTopicsDomain - = pbsServiceFactory.getService(["auction.privacysandbox.topicsdomain": PRIVACY_SENDBOX_DOMAIN]) + private static final Map TOPICS_DOMAIN_CONFIG = ["auction.privacysandbox.topicsdomain": PRIVACY_SENDBOX_DOMAIN] + + private static final PrebidServerService prebidServerServiceWithTopicsDomain = pbsServiceFactory.getService(TOPICS_DOMAIN_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(TOPICS_DOMAIN_CONFIG) + } def "PBS should populate user.data when Sec-Browsing-Topics header present in request"() { given: "Default basic BidRequest with generic bidder" diff --git a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy index eb988ac130b..107fadb70b5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.request.auction.Source +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP @@ -14,20 +15,34 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class UUIDSpec extends BaseSpec { - def "PBS auction should generate UUID for APP BidRequest id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) + private static final Map STORED_REQUEST_ID_GEN_ENABLED_CONFIG = [ + "settings.generate-storedrequest-bidrequest-id": "true" + ] - and: "Flush metrics" - flushMetrics(pbsService) + private static final Map STORED_REQUEST_ID_GEN_DISABLED_CONFIG = [ + "settings.generate-storedrequest-bidrequest-id": "false" + ] + + private static final PrebidServerService storedRequestIdGenEnabledService = pbsServiceFactory.getService(STORED_REQUEST_ID_GEN_ENABLED_CONFIG) + + private static final PrebidServerService storedRequestIdGenDisabledService = pbsServiceFactory.getService(STORED_REQUEST_ID_GEN_DISABLED_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(STORED_REQUEST_ID_GEN_ENABLED_CONFIG) + pbsServiceFactory.removeContainer(STORED_REQUEST_ID_GEN_DISABLED_CONFIG) + } - and: "Default bid request with stored request and id" + def "PBS auction should generate UUID for APP BidRequest id and merge StoredRequest when bidRequestId = #bidRequestId"() { + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { id = bidRequestId ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(pbsService) + and: "Save storedRequest into DB with cur and id" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(id: PBSUtils.randomString, cur: currencies) @@ -49,10 +64,10 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.id != bidRequestId where: - bidRequestId | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + bidRequestId | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } def "PBS auction shouldn't generate UUID for BidRequest id when BidRequest doesn't have APP"() { @@ -81,11 +96,8 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.id == bidRequestId } - def "PBS amp should generate UUID for BidRequest id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Default AMP request with custom Id" + def "PBS amp should generate UUID for BidRequest id and merge StoredRequest when bidRequestId = #bidRequestId"() { + given: "Default AMP request with custom Id" def ampRequest = AmpRequest.defaultAmpRequest.tap { tagId = bidRequestId } @@ -106,25 +118,22 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.id != bidRequestId where: - bidRequestId | generateBidRequestId - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + bidRequestId | pbsService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } - def "PBS auction should generate UUID for source.tid and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Flush metrics" - flushMetrics(pbsService) - - and: "Default bid request with stored request and id" + def "PBS auction should generate UUID for source.tid and merge StoredRequest when sourceTid= #sourceTid"() { + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { source = new Source(tid: sourceTid) ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(pbsService) + and: "Save storedRequest into DB with cur and source.tid" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(cur: currencies, source: new Source(tid: PBSUtils.randomString)) @@ -146,17 +155,14 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.source.tid != sourceTid where: - sourceTid | generateBidRequestId - null | "false" - "{{UUID}}" | "false" - PBSUtils.randomString | "true" + sourceTid | pbsService + null | storedRequestIdGenDisabledService + "{{UUID}}" | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService } - def "PBS amp should generate UUID for source.tid id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Default AMP request with custom Id" + def "PBS amp should generate UUID for source.tid id and merge StoredRequest when sourceTid = #sourceTid"() { + given: "Default AMP request with custom Id" def ampRequest = AmpRequest.defaultAmpRequest and: "Default StoredBidRequest" @@ -177,26 +183,23 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.source.tid != sourceTid where: - sourceTid | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + sourceTid | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } - def "PBS auction should generate UUID for imp[].ext.tid and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Flush metrics" - flushMetrics(pbsService) - - and: "Default bid request with stored request and id" + def "PBS auction should generate UUID for imp[].ext.tid and merge StoredRequest when impExtTid = #impExtTid"() { + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { imp[0].ext.tid = impExtTid ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(pbsService) + and: "Save storedRequest into DB with cur and source.tid" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(cur: currencies) @@ -218,17 +221,14 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.imp[0].ext.tid != impExtTid where: - impExtTid | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + impExtTid | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } - def "PBS amp should generate UUID for imp[].ext.tid id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Default AMP request with custom Id" + def "PBS amp should generate UUID for imp[].ext.tid id and merge StoredRequest when impExtTid = #impExtTid"() { + given: "Default AMP request with custom Id" def ampRequest = AmpRequest.defaultAmpRequest and: "Default StoredBidRequest" @@ -249,17 +249,14 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.imp[0].ext.tid != impExtTid where: - impExtTid | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + impExtTid | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } def "PBS should generate UUID for empty imp[].id when generate-storedrequest-bidrequest-id = true"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": "true"]) - - and: "Default bid request with stored request and id" + given: "Default bid request with stored request and id" def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { imp[1] = Imp.defaultImpression.tap { it.id = null @@ -267,7 +264,7 @@ class UUIDSpec extends BaseSpec { } when: "Requesting PBS auction" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = storedRequestIdGenEnabledService.sendAuctionRequest(bidRequest) then: "BidResponse should generate UUID for imp[].id" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -275,13 +272,7 @@ class UUIDSpec extends BaseSpec { } def "PBS auction should re-assign UUID for all imp[].id and merge StoredRequest when imp[].id not different and generate-storedrequest-bidrequest-id = true"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": "true"]) - - and: "Flush metrics" - flushMetrics(pbsService) - - and: "Default bid request with stored request and id" + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { def imp = Imp.defaultImpression.tap { @@ -292,6 +283,9 @@ class UUIDSpec extends BaseSpec { ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(storedRequestIdGenEnabledService) + and: "Save storedRequest into DB with cur and source.tid" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(cur: currencies) @@ -299,10 +293,10 @@ class UUIDSpec extends BaseSpec { storedRequestDao.save(storedRequest) when: "Requesting PBS auction" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = storedRequestIdGenEnabledService.sendAuctionRequest(bidRequest) then: "Metric stored_requests_found should be updated" - def metrics = pbsService.sendCollectedMetricsRequest() + def metrics = storedRequestIdGenEnabledService.sendCollectedMetricsRequest() assert metrics["stored_requests_found"] == 1 and: "BidResponse should be merged with stored request" diff --git a/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy index b4111e551fb..ee17f1f8ebb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.HttpUtil import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -12,14 +13,32 @@ import static org.prebid.server.functional.testcontainers.Dependencies.networkSe class UserSyncSpec extends BaseSpec { - private static final Map GENERIC_USERSYNC_CONFIG = ["adapters.${GENERIC.value}.usersync.${IFRAME.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.${GENERIC.value}.usersync.${IFRAME.value}.support-cors": "false"] + private static final Map BASE_USERSYNC_CONFIG = [ + "adapters.${GENERIC.value}.usersync.${IFRAME.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.${GENERIC.value}.usersync.${IFRAME.value}.support-cors": "false" + ] + + private static final Map USERSYNC_DISABLED_CONFIG = BASE_USERSYNC_CONFIG + [ + "adapters.${GENERIC.value}.usersync.enabled": "false" + ] + + private static final Map USERSYNC_ENABLED_CONFIG = BASE_USERSYNC_CONFIG + [ + "adapters.${GENERIC.value}.usersync.enabled": "true" + ] + + private static final PrebidServerService userSyncDisabledService = pbsServiceFactory.getService(USERSYNC_DISABLED_CONFIG) + private static final PrebidServerService userSyncEnabledService = pbsServiceFactory.getService(USERSYNC_ENABLED_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(USERSYNC_DISABLED_CONFIG) + pbsServiceFactory.removeContainer(USERSYNC_ENABLED_CONFIG) + } def "PBS should return usersync url with '#formatParam' format parameter for #userSyncFormat when format-override absent"() { given: "Pbs config with usersync.#userSyncFormat" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"]) + def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default CookieSyncRequest" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -32,18 +51,21 @@ class UserSyncSpec extends BaseSpec { assert bidderStatus?.userSync?.type == userSyncFormat assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "f") == formatParam + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: - userSyncFormat || formatParam - REDIRECT || PIXEL.name - IFRAME || BLANK.name + userSyncFormat | formatParam + REDIRECT | PIXEL.name + IFRAME | BLANK.name } def "PBS should return overridden usersync url format for #userSyncFormat usersync when format-override is #formatOverride"() { given: "Pbs config with usersync.#userSyncFormat and iframe.format-override: #formatOverride" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.generic.usersync.${userSyncFormat.value}.support-cors" : "false", - "adapters.generic.usersync.${userSyncFormat.value}.format-override": formatOverride.value]) + def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.generic.usersync.${userSyncFormat.value}.support-cors" : "false", + "adapters.generic.usersync.${userSyncFormat.value}.format-override": formatOverride.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default CookieSyncRequest" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -56,20 +78,23 @@ class UserSyncSpec extends BaseSpec { assert bidderStatus?.userSync?.type == userSyncFormat assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "f") == formatOverride.name + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: - userSyncFormat || formatOverride - REDIRECT || BLANK - REDIRECT || PIXEL - IFRAME || BLANK - IFRAME || PIXEL + userSyncFormat | formatOverride + REDIRECT | BLANK + REDIRECT | PIXEL + IFRAME | BLANK + IFRAME | PIXEL } def "PBS should return empty uid in usersync url when uid macro is not present in config"() { given: "Pbs config with usersync.#userSyncFormat.url" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false", - "adapters.generic.usersync.${userSyncFormat.value}.uid-macro" : null]) + def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false", + "adapters.generic.usersync.${userSyncFormat.value}.uid-macro" : null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default CookieSyncRequest" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -81,13 +106,16 @@ class UserSyncSpec extends BaseSpec { def bidderStatus = response.getBidderUserSync(GENERIC) assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "uid").isEmpty() + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: userSyncFormat << [REDIRECT, IFRAME] } def "PBS cookie sync should sync bidder by default when bidder.usersync.enabled not overridden"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG) + def prebidServerService = pbsServiceFactory.getService(BASE_USERSYNC_CONFIG) and: "Default Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -98,18 +126,17 @@ class UserSyncSpec extends BaseSpec { then: "Response should contain synced bidder" assert response.getBidderUserSync(GENERIC) assert response.bidderStatus.size() == 1 + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(BASE_USERSYNC_CONFIG) } def "PBS cookie sync should sync bidder when bidder.usersync.enabled=true"() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "true"]) - - and: "Default Cookie sync request" + given: "Default Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncEnabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain synced bidder" assert response.getBidderUserSync(GENERIC) @@ -117,15 +144,11 @@ class UserSyncSpec extends BaseSpec { } def "PBS cookie sync shouldn't sync bidder and emit error when bidder.usersync.enabled=false"() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "false"]) - - and: "Default Cookie sync request" + given: "Default Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncDisabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain bidder with error" def bidderStatus = response.getBidderUserSync(GENERIC) @@ -135,18 +158,14 @@ class UserSyncSpec extends BaseSpec { } def "PBS cookie sync shouldn't coop-sync bidder when coop-sync=true and bidder.usersync.enabled=false "() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "false"]) - - and: "Cookie sync request without bidders and coop-sync=true" + given: "Cookie sync request without bidders and coop-sync=true" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { bidders = null coopSync = true } when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncDisabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain bidder with error" def bidderStatus = response.getBidderUserSync(GENERIC) @@ -156,18 +175,14 @@ class UserSyncSpec extends BaseSpec { } def "PBS cookie sync should coop-sync bidder when coop-sync=true and bidder.usersync.enabled=true "() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "true"]) - - and: "Cookie sync request without bidders and coop-sync=true" + given: "Cookie sync request without bidders and coop-sync=true" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { bidders = null coopSync = true } when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncEnabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain bidder" assert response.getBidderUserSync(GENERIC) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index 8325eaacdee..a62bf021514 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -49,7 +49,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { ['hooks.host-execution-plan': null] private static final PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) - private static final PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG) def cleanupSpec() { pbsServiceFactory.removeContainer(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy index 54386c65cbe..ece53e033c9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy @@ -112,6 +112,9 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(getRichMediaFilterSettings(PATTERN_NAME)) } def "PBS should include analytics tag in response when request and default account allow client details"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy index 8b3f5d936bd..da563ab7251 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy @@ -5,6 +5,7 @@ import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountAuctionConfig import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountPriceFloorsConfig +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.PriceFloorsFetch import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.pricefloors.Country @@ -51,6 +52,10 @@ abstract class PriceFloorsBaseSpec extends BaseSpec { floorsProvider.setResponse() } + def cleanupSpec() { + pbsServiceFactory.removeContainer(FLOORS_CONFIG + GENERIC_ALIAS_CONFIG) + } + protected static AccountConfig getDefaultAccountConfigSettings() { def fetch = new PriceFloorsFetch(enabled: false, timeoutMs: 5000, diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy index 69d8dce297d..4dad6b2f4bb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests.pricefloors import org.prebid.server.functional.model.Currency import org.prebid.server.functional.model.config.AccountPriceFloorsConfig +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.PriceFloorsFetch import org.prebid.server.functional.model.mock.services.currencyconversion.CurrencyConversionRatesResponse import org.prebid.server.functional.model.pricefloors.PriceFloorData @@ -43,6 +44,10 @@ class PriceFloorsCurrencySpec extends PriceFloorsBaseSpec { private final PrebidServerService currencyFloorsPbsService = pbsServiceFactory.getService(FLOORS_CONFIG + CURRENCY_CONVERTER_CONFIG) + def cleanupSpec() { + pbsServiceFactory.removeContainer(FLOORS_CONFIG + CURRENCY_CONVERTER_CONFIG) + } + def "PBS should update bidFloor, bidFloorCur for signalling when request.cur is specified"() { given: "Default BidRequest with cur" def bidRequest = bidRequestWithFloors.tap { @@ -166,8 +171,8 @@ class PriceFloorsCurrencySpec extends PriceFloorsBaseSpec { def "PBS should not update bidFloor, bidFloorCur for signalling when currency conversion is not available"() { given: "Pbs config with disabled conversion" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["currency-converter.external-rates.enabled": "false"]) + def pbsConfig = FLOORS_CONFIG + ["currency-converter.external-rates.enabled": "false"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "BidRequest with floorMinCur" def requestFloorCur = USD @@ -226,6 +231,9 @@ class PriceFloorsCurrencySpec extends PriceFloorsBaseSpec { ext?.prebid?.floors?.location == FETCH ext?.prebid?.floors?.fetchStatus == SUCCESS } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should forward bidFloor and bidFloorCur for signalling when they come in the bid request"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy index 4d47947670a..7729159a3af 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy @@ -787,8 +787,8 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { enforceDealFloorsSnakeCase = defaultAccountEnforeDealFloorsSnakeCase } } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with generic bidder with preferdeals = true" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -833,6 +833,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.collect { it.id } == [bidResponse.seatbid.first().bid.last().id] assert response.seatbid.first().bid.collect { it.price } == [floorValue] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: defaultAccountEnforeDealFloors | defaultAccountEnforeDealFloorsSnakeCase | accountEnforeDealFloors | accountEnforeDealFloorsSnakeCase false | null | true | null @@ -846,8 +849,8 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { auction.priceFloors.enforceDealFloors = pbsConfigEnforceDealFloors } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with generic bidder with preferdeals = true" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -890,6 +893,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.first()?.id == bidResponse.seatbid.first().bid.first().id assert response.seatbid.first().bid.collect { it.price } == [dealBidPrice] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigEnforceDealFloors | enforcePbs | accountEnforceDealFloors | floorDeals true | null | false | true @@ -902,8 +908,8 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { auction.priceFloors.enforceFloorsRate = pbsConfigEnforceRate } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -945,6 +951,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.first()?.id == bidResponse.seatbid.first().bid.last().id assert response.seatbid.first().bid.collect { it.price } == [floorValue] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigEnforceRate | requestEnforceRate | accountEnforceRate PBSUtils.getRandomNumber(0, 100) | null | 100 @@ -957,8 +966,8 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { auction.priceFloors.enforceFloorsRate = pbsConfigEnforceFloorsRate } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -999,6 +1008,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.size() == 2 assert response.seatbid.first().bid.collect { it.price } == [floorValue, floorValue - 0.1] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigEnforceFloorsRate | enforceRate | accountEnforceFloorsRate PBSUtils.getRandomNumber(0, 100) | null | 0 diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy index a897fbeff7c..0e45fb277e0 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy @@ -48,7 +48,8 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def "PBS should activate floors feature when price-floors.enabled = true in PBS config"() { given: "Pbs with PF configuration" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + ["price-floors.enabled": "true"]) + def pbsConfig = FLOORS_CONFIG + ["price-floors.enabled": "true"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.getDefaultBidRequest(APP) @@ -69,11 +70,15 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "PBS should signal bids" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert bidderRequest.imp[0].bidFloor + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should not activate floors feature when price-floors.enabled = false in #description config"() { given: "Pbs with PF configuration" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + ["price-floors.enabled": pbdConfigEnabled]) + def pbsConfig = FLOORS_CONFIG + ["price-floors.enabled": pbdConfigEnabled] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.getDefaultBidRequest(APP) @@ -95,6 +100,9 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert !bidderRequest.imp[0].bidFloor + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: description | pbdConfigEnabled | accountConfigEnabled "PBS" | "false" | true @@ -341,8 +349,9 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { useDynamicDataSnakeCase = pbsConfigUseDynamicDataSnakeCase } } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with ext.prebid.floors" def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -373,6 +382,9 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert bidderRequest.imp[0].bidFloor == floorValue + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigUseDynamicData | accountUseDynamicData | pbsConfigUseDynamicDataSnakeCase | accountUseDynamicDataSnakeCase false | true | null | null diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy index e493bbb7df9..82372855c1b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy @@ -914,10 +914,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { } def "PBS should populate seatNonBid when bid rejected due to floor"() { - given: "PBS config with floors config" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG) - - and: "Default BidRequest" + given: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(enforcePbs: enforcePbs)) ext.prebid.returnAllBidStatus = true @@ -935,7 +932,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { floorsProvider.setResponse(bidRequest.site.publisher.id, floorsResponse) and: "PBS cache rules" - cacheFloorsProviderRules(bidRequest, floorValue, pbsService) + cacheFloorsProviderRules(bidRequest, floorValue, floorsPbsService) and: "Set bidder response" def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { @@ -944,7 +941,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = floorsPbsService.sendAuctionRequest(bidRequest) then: "PBS response should contain seatNonBid and contain errors" def seatNonBids = response.ext.seatnonbid @@ -961,10 +958,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { } def "PBS shouldn't populate seatNonBid when rejected due to floor and returnAllBidStatus is false"() { - given: "PBS config with floors config" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG) - - and: "Default BidRequest" + given: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(enforcePbs: enforcePbs)) ext.prebid.returnAllBidStatus = false @@ -982,7 +976,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { floorsProvider.setResponse(bidRequest.site.publisher.id, floorsResponse) and: "PBS cache rules" - cacheFloorsProviderRules(bidRequest, floorValue, pbsService) + cacheFloorsProviderRules(bidRequest, floorValue, floorsPbsService) and: "Set bidder response" def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { @@ -991,7 +985,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = floorsPbsService.sendAuctionRequest(bidRequest) then: "PBS response shouldn't contain seatNonBid and contain errors" assert !response.ext.seatnonbid diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy index 72be2f0a0f3..2c93f251196 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy @@ -332,8 +332,9 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { auction.priceFloors.adjustForBidAdjustment = pbsConfigBidAdjustmentFlag } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "BidRequest with bidAdjustment" def floorsProviderFloorValue = PBSUtils.randomFloorValue @@ -365,6 +366,9 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Bidder request shouldn't include imp.ext.prebid.floors" assert !bidderRequest.imp[0].ext.prebid.floors + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigBidAdjustmentFlag | requestBidAdjustmentFlag | accountBidAdjustmentFlag true | true | null @@ -380,8 +384,9 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { adjustForBidAdjustmentSnakeCase = pbsConfigBidAdjustmentFlagSnakeCase } } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def floorsProviderFloorValue = 0.8 @@ -415,6 +420,9 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Bidder request shouldn't include imp.ext.prebid.floors" assert !bidderRequest.imp[0].ext.prebid.floors + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigBidAdjustmentFlagSnakeCase | pbsConfigBidAdjustmentFlag | requestBidAdjustmentFlag | accountBidAdjustmentFlag | accountBidAdjustmentFlagSnakeCase null | false | false | null | false diff --git a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy index b7cdcc3c4f1..e699eca908b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy @@ -19,8 +19,8 @@ class PrometheusSpec extends BaseSpec { def "PBS should add custom labels to Prometheus metrics when custom labels are enabled in config"() { given: "PBS config with set up Prometheus and enabled Promethues custom labels" - def prometheusPbsService = pbsServiceFactory.getService(basePrometheusConfig + - ["metrics.prometheus.custom-labels-enabled": "true"]) + def pbsConfig = basePrometheusConfig + ["metrics.prometheus.custom-labels-enabled": "true"] + def prometheusPbsService = pbsServiceFactory.getService(pbsConfig) and: "Labels config metric matcher and an appropriate PBS metric to it are specified" def pbsMetricMatcher = "requests.*.*" @@ -44,15 +44,19 @@ class PrometheusSpec extends BaseSpec { def expectedLabelsString = "$normalizedMapperName$metricLabels" assert prometheusMetrics.contains(expectedLabelsString) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should add namespace, subsystem and custom labels info to Prometheus metrics when those are set in config"() { given: "PBS config with set up Prometheus with enabled custom labels" def namespace = "namespace_01" def subsystem = "subsystem_01" - def prometheusPbsService = pbsServiceFactory.getService(basePrometheusConfig + + def pbsConfig = basePrometheusConfig + getNamespaceSubsystemConfig(namespace, subsystem) + - ["metrics.prometheus.custom-labels-enabled": "true"]) + ["metrics.prometheus.custom-labels-enabled": "true"] + def prometheusPbsService = pbsServiceFactory.getService(pbsConfig) and: "Labels config metric matcher and an appropriate PBS metric to it are specified" def pbsMetricMatcher = "requests.*.*" @@ -77,6 +81,9 @@ class PrometheusSpec extends BaseSpec { def expectedLabelsString = "$namespaceSubsystemMapperName$metricLabels" assert prometheusMetrics.contains(expectedLabelsString) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should add namespace and subsystem parts to Prometheus metric names when those are config provided"() { @@ -101,6 +108,10 @@ class PrometheusSpec extends BaseSpec { then: "Prometheus metrics response contains each of PBS metric with added namespace and subsystem" prometheusFormatPbsMetricNames.each { assert prometheusMetrics.contains(it) } + + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(config) } def "PBS service fails to start when invalid symbols by namespace and subsystem in Prometheus config are present"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/storage/AccountS3Spec.groovy b/src/test/groovy/org/prebid/server/functional/tests/storage/AccountS3Spec.groovy index 3a87be7b9e7..3ca62d3d849 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/storage/AccountS3Spec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/storage/AccountS3Spec.groovy @@ -2,6 +2,8 @@ package org.prebid.server.functional.tests.storage import org.prebid.server.functional.model.AccountStatus import org.prebid.server.functional.model.config.AccountConfig +import org.prebid.server.functional.model.config.ModuleName +import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService @@ -13,9 +15,15 @@ import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED class AccountS3Spec extends StorageBaseSpec { - protected PrebidServerService s3StorageAccountPbsService = PbsServiceFactory.getService(s3StorageConfig + - mySqlDisabledConfig + - ['settings.enforce-valid-account': 'true']) + private final static Map> S3_CONFIG = s3StorageConfig + + mySqlDisabledConfig + + ['settings.enforce-valid-account': 'true'] + + private static final PrebidServerService s3StorageAccountPbsService = PbsServiceFactory.getService(S3_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(S3_CONFIG) + } def "PBS should process request when active account is present in S3 storage"() { given: "Default BidRequest with account" diff --git a/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy index 2b1e37736fb..ba10f4e72e1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy @@ -51,5 +51,5 @@ class StorageBaseSpec extends BaseSpec { 'settings.database.stored-responses-query' : null ].asImmutable() as Map - protected PrebidServerService s3StoragePbsService = PbsServiceFactory.getService(s3StorageConfig + mySqlDisabledConfig) + protected static final PrebidServerService s3StoragePbsService = PbsServiceFactory.getService(s3StorageConfig + mySqlDisabledConfig) } From 92b055c363729739f66ba56c6cf9ec6f86a39bb0 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Wed, 12 Feb 2025 18:22:50 +0200 Subject: [PATCH 05/25] Fix invalid tests --- .../functional/tests/CookieSyncSpec.groovy | 43 +++---- .../PriceFloorsCurrencySpec.groovy | 1 - .../PriceFloorsEnforcementSpec.groovy | 16 +-- .../PriceFloorsFetchingSpec.groovy | 4 +- .../PriceFloorsSignalingSpec.groovy | 116 ++++++++++-------- 5 files changed, 100 insertions(+), 80 deletions(-) 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 3429ffc0342..b7fce18dda6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy @@ -106,9 +106,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request should replace synced as family bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS - def pbsConfig = GENERIC_CONFIG + APPNEXUS_CONFIG - +["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] + def pbsConfig = GENERIC_CONFIG + APPNEXUS_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" @@ -377,9 +377,10 @@ class CookieSyncSpec extends BaseSpec { def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with account and privacy" + def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { bidders = [] - account = PBSUtils.randomString + account = accountId usPrivacy = new CcpaConsent(optOutSale: ENFORCED) coopSync = true } @@ -387,7 +388,7 @@ class CookieSyncSpec extends BaseSpec { and: "Save account config into DB" def ccpaConfig = new AccountCcpaConfig(enabled: true) def accountConfig = new AccountConfig(privacy: new AccountPrivacyConfig(ccpa: ccpaConfig)) - def account = new Account(uuid: cookieSyncRequest.account, config: accountConfig) + def account = new Account(uuid: accountId, config: accountConfig) accountDao.save(account) when: "PBS processes cookie sync request" @@ -934,15 +935,15 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.default-limit config should use limit from cookie sync account config"() { given: "PBS bidders config" - def pbsConfig = ["cookie-sync.default-limit": "2"] + PBS_CONFIG + def pbsConfig = ['cookie-sync.default-limit': '2'] + PBS_CONFIG def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def accountId = PBSUtils.randomNumber def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - bidders = [RUBICON, APPNEXUS, GENERIC] - account = accountId - debug = false + it.bidders = [RUBICON, APPNEXUS, GENERIC] + it.account = accountId + it.debug = false } and: "Save account with cookie config" @@ -956,7 +957,7 @@ class CookieSyncSpec extends BaseSpec { def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain one synced bidder" - assert response.bidderStatus.size() == accountDefaultLimit + assert response.bidderStatus.size() == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1112,9 +1113,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.pri and in all places disabled coop sync in account shouldn't sync bidder which present in cookie-sync.pir config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber @@ -1295,9 +1296,9 @@ class CookieSyncSpec extends BaseSpec { and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - bidders = null - coopSync = null - account = accountId + it.bidders = null + it.coopSync = null + it.account = accountId } and: "Save account with cookie config" @@ -1361,9 +1362,9 @@ class CookieSyncSpec extends BaseSpec { and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - bidders = null - coopSync = null - account = accountId + it.bidders = null + it.coopSync = null + it.account = accountId } and: "Save account with cookie config" @@ -1460,8 +1461,8 @@ class CookieSyncSpec extends BaseSpec { and: "Cookie sync request with account and privacy" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - account = PBSUtils.randomString - usPrivacy = new CcpaConsent(optOutSale: ENFORCED) + it.account = PBSUtils.randomString + it.usPrivacy = new CcpaConsent(optOutSale: ENFORCED) } and: "Save account config into DB" diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy index 4dad6b2f4bb..cafd741f089 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy @@ -2,7 +2,6 @@ package org.prebid.server.functional.tests.pricefloors import org.prebid.server.functional.model.Currency import org.prebid.server.functional.model.config.AccountPriceFloorsConfig -import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.PriceFloorsFetch import org.prebid.server.functional.model.mock.services.currencyconversion.CurrencyConversionRatesResponse import org.prebid.server.functional.model.pricefloors.PriceFloorData diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy index 7729159a3af..e1fd6e87645 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy @@ -781,13 +781,13 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should suppress deal that are below the matched floor when enforce-deal-floors = true"() { given: "Pbs with PF configuration with enforceDealFloors" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.tap { enforceDealFloors = defaultAccountEnforeDealFloors enforceDealFloorsSnakeCase = defaultAccountEnforeDealFloorsSnakeCase } } - def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with generic bidder with preferdeals = true" @@ -846,10 +846,10 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should not suppress deal that are below the matched floor according to ext.prebid.floors.enforcement.enforcePBS"() { given: "Pbs with PF configuration with enforceDealFloors" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.enforceDealFloors = pbsConfigEnforceDealFloors } - def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with generic bidder with preferdeals = true" @@ -905,10 +905,10 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should suppress any bids below the matched floor when fetch.enforce-floors-rate = 100 in account config"() { given: "Pbs with PF configuration with minMaxAgeSec" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.enforceFloorsRate = pbsConfigEnforceRate } - def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" @@ -963,10 +963,10 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should not suppress any bids below the matched floor when fetch.enforce-floors-rate = 0 in account config"() { given: "Pbs with PF configuration with minMaxAgeSec" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.enforceFloorsRate = pbsConfigEnforceFloorsRate } - def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)] + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy index 0e45fb277e0..a9900f997f7 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy @@ -343,14 +343,14 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def "PBS should fetch data from provider when use-dynamic-data enabled"() { given: "Pbs with PF configuration with useDynamicData" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.tap { useDynamicData = pbsConfigUseDynamicData useDynamicDataSnakeCase = pbsConfigUseDynamicDataSnakeCase } } def pbsConfig = FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)] + ["settings.default-account-config": encode(accountConfig)] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with ext.prebid.floors" diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy index 2c93f251196..0e0b2b035d8 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy @@ -328,20 +328,12 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { } def "PBS should update imp[0].bidFloor when ext.prebid.bidadjustmentfactors is defined"() { - given: "Pbs with PF configuration with minMaxAgeSec" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { - auction.priceFloors.adjustForBidAdjustment = pbsConfigBidAdjustmentFlag - } - def pbsConfig = FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)] - def pbsService = pbsServiceFactory.getService(pbsConfig) - - and: "BidRequest with bidAdjustment" + given: "BidRequest with bidAdjustment" def floorsProviderFloorValue = PBSUtils.randomFloorValue BigDecimal bidAdjustment = 0.1 def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) - ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) + it.ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) + it.ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) } and: "Account with adjustForBidAdjustment in the DB" @@ -357,7 +349,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { floorsProvider.setResponse(bidRequest.app.publisher.id, floorsResponse) when: "PBS cache rules and processes auction request" - cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue / bidAdjustment, pbsService) + cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue / bidAdjustment, floorsPbsService) then: "Bidder request bidFloor should be update according to bidAdjustment" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() @@ -366,52 +358,38 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Bidder request shouldn't include imp.ext.prebid.floors" assert !bidderRequest.imp[0].ext.prebid.floors - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) - where: - pbsConfigBidAdjustmentFlag | requestBidAdjustmentFlag | accountBidAdjustmentFlag - true | true | null - true | null | null - false | null | true + requestBidAdjustmentFlag | accountBidAdjustmentFlag + true | null + null | null + null | true } def "PBS should not update imp[0].bidFloor when bidadjustment is disallowed"() { - given: "Pbs with PF configuration with adjustForBidAdjustment" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { - auction.priceFloors.tap { - adjustForBidAdjustment = pbsConfigBidAdjustmentFlag - adjustForBidAdjustmentSnakeCase = pbsConfigBidAdjustmentFlagSnakeCase - } - } - def pbsConfig = FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)] - def pbsService = pbsServiceFactory.getService(pbsConfig) - - and: "Default BidRequest" + given: "Default BidRequest" def floorsProviderFloorValue = 0.8 def bidAdjustment = 0.1 def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) - ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) + it.ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) + it.ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) } and: "Account in the DB" def accountId = bidRequest.app.publisher.id def account = getAccountWithEnabledFetch(accountId).tap { - config.auction.priceFloors.adjustForBidAdjustment = accountBidAdjustmentFlag - config.auction.priceFloors.adjustForBidAdjustmentSnakeCase = accountBidAdjustmentFlagSnakeCase + it.config.auction.priceFloors.adjustForBidAdjustment = accountBidAdjustmentFlag + it.config.auction.priceFloors.adjustForBidAdjustmentSnakeCase = accountBidAdjustmentFlagSnakeCase } accountDao.save(account) and: "Set Floors Provider response" def floorsResponse = PriceFloorData.priceFloorData.tap { - modelGroups[0].values = [(rule): floorsProviderFloorValue] + it.modelGroups[0].values = [(rule): floorsProviderFloorValue] } floorsProvider.setResponse(accountId, floorsResponse) when: "PBS cache rules and processes auction request" - cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue, pbsService) + cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue, floorsPbsService) then: "Bidder request bidFloor should be changed" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() @@ -420,15 +398,57 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Bidder request shouldn't include imp.ext.prebid.floors" assert !bidderRequest.imp[0].ext.prebid.floors + where: + requestBidAdjustmentFlag | accountBidAdjustmentFlag | accountBidAdjustmentFlagSnakeCase + false | null | false + null | false | null + false | null | false + null | false | null + } + + def "PBS should priorities account config over default account config and update imp[0].bidFloor"() { + given: "Pbs with PF configuration with adjustForBidAdjustment" + def accountConfig = defaultAccountConfigSettings.tap { + it.auction.priceFloors.tap { + it.adjustForBidAdjustment = false + adjustForBidAdjustmentSnakeCase = null + } + } + def pbsConfig = FLOORS_CONFIG + + ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) + + and: "BidRequest with bidAdjustment" + def floorsProviderFloorValue = PBSUtils.randomFloorValue + BigDecimal bidAdjustment = 0.1 + def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { + ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: null)) + ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) + } + and: "Account with adjustForBidAdjustment in the DB" + def account = getAccountWithEnabledFetch(bidRequest.app.publisher.id).tap { + config.auction.priceFloors.adjustForBidAdjustment = null + config.auction.priceFloors.adjustForBidAdjustmentSnakeCase = true + } + accountDao.save(account) + + and: "Set Floors Provider response" + def floorsResponse = PriceFloorData.priceFloorData.tap { + modelGroups[0].values = [(rule): floorsProviderFloorValue] + } + floorsProvider.setResponse(bidRequest.app.publisher.id, floorsResponse) + when: "PBS cache rules and processes auction request" + cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue / bidAdjustment, pbsService) + + then: "Bidder request bidFloor should be update according to bidAdjustment" + def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() + assert bidderRequest.imp[0].bidFloor == floorsProviderFloorValue / bidAdjustment + + and: "Bidder request shouldn't include imp.ext.prebid.floors" + assert !bidderRequest.imp[0].ext.prebid.floors + cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) - - where: - pbsConfigBidAdjustmentFlagSnakeCase | pbsConfigBidAdjustmentFlag | requestBidAdjustmentFlag | accountBidAdjustmentFlag | accountBidAdjustmentFlagSnakeCase - null | false | false | null | false - null | true | null | false | null - false | null | false | null | false - true | null | null | false | null } def "PBS should choose most aggressive adjustment when request contains multiple media-types"() { @@ -670,10 +690,10 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Floor config with default account" def accountConfig = getDefaultAccountConfigSettings().tap { - auction.priceFloors.fetch.enabled = true - auction.priceFloors.fetch.url = BASIC_FETCH_URL + bidRequest.site.publisher.id - auction.priceFloors.fetch.maxSchemaDims = MAX_SCHEMA_DIMENSIONS_SIZE - auction.priceFloors.maxSchemaDims = null + it.auction.priceFloors.fetch.enabled = true + it.auction.priceFloors.fetch.url = BASIC_FETCH_URL + bidRequest.site.publisher.id + it.auction.priceFloors.fetch.maxSchemaDims = MAX_SCHEMA_DIMENSIONS_SIZE + it.auction.priceFloors.maxSchemaDims = null } def pbsFloorConfig = GENERIC_ALIAS_CONFIG + ["price-floors.enabled" : "true", "settings.default-account-config": encode(accountConfig)] From fa6de4d50af2c65c7caf16cc627593aec9430590 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 21 Feb 2025 14:30:25 +0200 Subject: [PATCH 06/25] Update after review --- .../functional/model/config/Stage.groovy | 3 +- .../model/request/auction/UserExtData.groovy | 3 + .../response/auction/AnalyticResult.groovy | 6 +- .../response/auction/AnalyticTagStatus.groovy | 13 ++++ .../auction/AnalyticsTagActivity.groovy | 2 +- .../auction/AnalyticsTagActivityResult.groovy | 2 +- .../server/functional/tests/BaseSpec.groovy | 8 +- .../server/functional/tests/CacheSpec.groovy | 6 +- .../server/functional/tests/UUIDSpec.groovy | 1 - .../tests/module/AbTestingModuleSpec.groovy | 77 ++++++++++--------- .../AnalyticsTagsModuleSpec.groovy | 17 ++-- 11 files changed, 77 insertions(+), 61 deletions(-) create mode 100644 src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticTagStatus.groovy diff --git a/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy b/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy index ba787025f28..a3a2b3f9ca7 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy @@ -25,8 +25,7 @@ enum Stage { } static Stage forValue(ModuleHookImplementation moduleHook) { - values() - .collect { [stage: it, matchLength: moduleHook.code.indexOf(it.value) >= 0 ? it.value.length() : -1] } + values().collect { [stage: it, matchLength: moduleHook.code.indexOf(it.value) >= 0 ? it.value.length() : -1] } .findAll { it.matchLength > 0 } .max { it.matchLength } ?.stage diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy index ad7cdf63390..fb7ac0a62dc 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy @@ -1,9 +1,12 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.databind.PropertyNamingStrategies +import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) class UserExtData { List keywords diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy index 136fbc47e5e..14946e3b644 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy @@ -6,20 +6,18 @@ import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.model.request.auction.Imp -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS - @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) @EqualsAndHashCode class AnalyticResult { String name - String status + AnalyticTagStatus status List results static AnalyticResult buildFromImp(Imp imp) { def appliedTo = new AppliedTo(impIds: [imp.id], bidders: [imp.ext.prebid.bidder.configuredBidders.first()]) def impResult = new ImpResult(status: 'success-block', values: new ModuleValue(richmediaFormat: 'mraid'), appliedTo: appliedTo) - new AnalyticResult(name: 'reject-richmedia', status: SUCCESS.value, results: [impResult]) + new AnalyticResult(name: 'reject-richmedia', status: AnalyticTagStatus.SUCCESS, results: [impResult]) } } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticTagStatus.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticTagStatus.groovy new file mode 100644 index 00000000000..f7575677ce3 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticTagStatus.groovy @@ -0,0 +1,13 @@ +package org.prebid.server.functional.model.response.auction + +import com.fasterxml.jackson.annotation.JsonValue + +enum AnalyticTagStatus { + + NONE, LOOKUP, CONTROL, SUCCESS, ERROR, SUCCESS_ALLOW, SUCCESS_BLOCK, SKIPPED, RUN + + @JsonValue + String getValue() { + name().toLowerCase().replace('_', '-') + } +} diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy index 6fd41583617..bc952b46b09 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy @@ -10,6 +10,6 @@ import org.prebid.server.functional.model.request.auction.FetchStatus class AnalyticsTagActivity { ModuleActivityName name - FetchStatus status + AnalyticTagStatus status List results } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy index a439d6411c2..570d7271b5f 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy @@ -9,7 +9,7 @@ import org.prebid.server.functional.model.request.auction.FetchStatus @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) class AnalyticsTagActivityResult { - FetchStatus status + AnalyticTagStatus status AnalyticsTagActivityValue values AppliedTo appliedTo } diff --git a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy index 4579c069e07..4428e69d1eb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy @@ -43,11 +43,11 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper { protected static final Map GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true", "adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()] protected static final Map EMPTY_CACHE_TTL_CONFIG = ["cache.default-ttl-seconds.banner": "", - "cache.default-ttl-seconds.video" : "", - "cache.default-ttl-seconds.native": "", - "cache.default-ttl-seconds.audio" : ""] + "cache.default-ttl-seconds.video" : "", + "cache.default-ttl-seconds.native": "", + "cache.default-ttl-seconds.audio" : ""] protected static final Map EMPTY_CACHE_TTL_HOST_CONFIG = ["cache.banner-ttl-seconds": "", - "cache.video-ttl-seconds" : ""] + "cache.video-ttl-seconds" : ""] protected static final PrebidServerService defaultPbsService = pbsServiceFactory.getService([:]) diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy index 109f90fbeb1..54dd3ee466c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy @@ -97,7 +97,8 @@ class CacheSpec extends BaseSpec { def "PBS should cache bids without api-key header when targeting is specified and api-key-secured disabled"() { given: "Pbs config with disabled api-key-secured and pbc.api.key" def apiKey = PBSUtils.randomString - def pbsConfig = ['pbc.api.key': apiKey, 'cache.api-key-secured': 'false'] + def pbsConfig = ['pbc.api.key' : apiKey, + 'cache.api-key-secured': 'false'] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with cache, targeting" @@ -122,7 +123,8 @@ class CacheSpec extends BaseSpec { def "PBS should cache bids with api-key header when targeting is specified and api-key-secured enabled"() { given: "Pbs config with api-key-secured and pbc.api.key" def apiKey = PBSUtils.randomString - def pbsConfig = ['pbc.api.key': apiKey, 'cache.api-key-secured': 'true'] + def pbsConfig = ['pbc.api.key' : apiKey, + 'cache.api-key-secured': 'true'] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with cache, targeting" diff --git a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy index 107fadb70b5..cd4545ec6b0 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy @@ -24,7 +24,6 @@ class UUIDSpec extends BaseSpec { ] private static final PrebidServerService storedRequestIdGenEnabledService = pbsServiceFactory.getService(STORED_REQUEST_ID_GEN_ENABLED_CONFIG) - private static final PrebidServerService storedRequestIdGenDisabledService = pbsServiceFactory.getService(STORED_REQUEST_ID_GEN_DISABLED_CONFIG) def cleanupSpec() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index a62bf021514..f599bb4e645 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -11,6 +11,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.FetchStatus import org.prebid.server.functional.model.request.auction.TraceLevel import org.prebid.server.functional.model.response.auction.AnalyticResult +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.PBSUtils @@ -216,8 +217,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].value.sort() + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -227,8 +228,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.RUN].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.RUN].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -277,8 +278,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -288,8 +289,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -338,8 +339,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -349,8 +350,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.RUN].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.RUN].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -392,8 +393,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -430,8 +431,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].value.sort() + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -479,8 +480,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -526,8 +527,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -574,8 +575,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].value.sort() + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -623,8 +624,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -793,8 +794,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -856,8 +857,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -920,8 +921,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -931,8 +932,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -980,8 +981,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten() == [ORTB2_BLOCKING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SUCCESS_ALLOW].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SUCCESS_ALLOW].value it.analyticsTags.activities.results.values.module.flatten().every { it == null } } @@ -1049,8 +1050,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS, SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION, NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING, AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED, FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -1118,8 +1119,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS].value - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy index ece53e033c9..6e29a4a2f1f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy @@ -13,6 +13,7 @@ import org.prebid.server.functional.model.request.auction.FetchStatus import org.prebid.server.functional.model.request.auction.PrebidAnalytics import org.prebid.server.functional.model.request.auction.RichmediaFilter import org.prebid.server.functional.model.request.auction.StoredBidResponse +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ModuleActivityName import org.prebid.server.functional.service.PrebidServerService @@ -53,12 +54,12 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.ORTB2_BLOCKING and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_ALLOW + it.status == AnalyticTagStatus.SUCCESS_ALLOW it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } @@ -103,12 +104,12 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.REJECT_RICHMEDIA and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_BLOCK + it.status == AnalyticTagStatus.SUCCESS_BLOCK it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } @@ -142,12 +143,12 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.ORTB2_BLOCKING and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_ALLOW + it.status == AnalyticTagStatus.SUCCESS_ALLOW it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } @@ -188,12 +189,12 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.ORTB2_BLOCKING and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_ALLOW + it.status == AnalyticTagStatus.SUCCESS_ALLOW it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } From dca221afb0341c286f5536b6560b1c1e6a697d62 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 21 Feb 2025 15:16:53 +0200 Subject: [PATCH 07/25] Update after review --- .../tests/module/AbTestingModuleSpec.groovy | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index f599bb4e645..3c70478e734 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -228,7 +228,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.RUN].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -278,7 +278,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -289,7 +289,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -339,7 +339,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -350,7 +350,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.RUN].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -393,7 +393,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -480,7 +480,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -527,7 +527,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -624,7 +624,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -794,7 +794,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -857,7 +857,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -921,7 +921,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -932,7 +932,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -981,7 +981,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten() == [ORTB2_BLOCKING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SUCCESS_ALLOW].value it.analyticsTags.activities.results.values.module.flatten().every { it == null } } @@ -1050,7 +1050,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS, SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION, NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING, AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -1119,7 +1119,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED].value it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } From 72bb24111fdef0a55fa18fc5459d25f0503d8a11 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 21 Feb 2025 15:37:15 +0200 Subject: [PATCH 08/25] Update after review --- .../functional/tests/module/AbTestingModuleSpec.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index 3c70478e734..341f65eee60 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -217,7 +217,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -431,7 +431,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -575,7 +575,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS].value + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].value.sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } From 0b11156f7a66be13cffbd5019a5ce6a2c75a6300 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 11 Apr 2025 09:00:09 +0300 Subject: [PATCH 09/25] update after review --- .../functional/tests/module/richmedia/RichMediaFilterSpec.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy index c42267767f6..1b040cc3ab0 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy @@ -39,7 +39,6 @@ class RichMediaFilterSpec extends ModuleBaseSpec { private static PrebidServerService pbsServiceWithEnabledMediaFilter private static PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy - def setupSpec() { pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG) From 56b4c1e495dfdc1ba92019f20515f16adcc2b42e Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Mon, 14 Jul 2025 18:59:45 +0300 Subject: [PATCH 10/25] Update functional tests --- .../functional/testcontainers/scaffolding/Bidder.groovy | 2 +- .../org/prebid/server/functional/tests/CacheSpec.groovy | 2 -- .../tests/pricefloors/PriceFloorsCurrencySpec.groovy | 4 ---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy index c0991ee30d1..50cc351fdaa 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/scaffolding/Bidder.groovy @@ -34,7 +34,7 @@ class Bidder extends NetworkScaffolding { request().withPath(endpoint) } - static HttpRequest getRequest(String bidRequestId, String requestMatchPath) { + HttpRequest getRequest(String bidRequestId, String requestMatchPath) { request().withPath(endpoint) .withBody(jsonPath("\$[?(@.$requestMatchPath == '$bidRequestId')]")) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy index 96570469a3f..bc3d963d9f3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy @@ -127,8 +127,6 @@ class CacheSpec extends BaseSpec { given: "Pbs config with disabled api-key-secured and pbc.api.key" def apiKey = PBSUtils.randomString def pbsConfig = ['pbc.api.key': apiKey, 'cache.api-key-secured': 'false'] - def pbsConfig = ['pbc.api.key' : apiKey, - 'cache.api-key-secured': 'false'] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with cache, targeting" diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy index 9fd29ab64d8..0e9d84b29e2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy @@ -36,10 +36,6 @@ class PriceFloorsCurrencySpec extends PriceFloorsBaseSpec { pbsServiceFactory.removeContainer(FLOORS_CONFIG + PbsConfig.currencyConverterConfig) } - def cleanupSpec() { - pbsServiceFactory.removeContainer(FLOORS_CONFIG + CURRENCY_CONVERTER_CONFIG) - } - def "PBS should update bidFloor, bidFloorCur for signalling when request.cur is specified"() { given: "Default BidRequest with cur" def bidRequest = bidRequestWithFloors.tap { From 67c57c7c685c56c3299cd8f66cbbb02760dc46e1 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Mon, 14 Jul 2025 20:46:44 +0300 Subject: [PATCH 11/25] Fix module tests --- .../module/responsecorrenction/ResponseCorrectionSpec.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c8e16b9a799..d7f105b050d 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 @@ -588,10 +588,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection.size() == 1 From b66572aeb4749df3af34c5b38501236d8e2d9df0 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Wed, 16 Jul 2025 11:15:37 +0300 Subject: [PATCH 12/25] Fix module tests --- .../model/request/auction/User.groovy | 2 +- .../functional/tests/AuctionSpec.groovy | 14 +-- .../tests/BidderInsensitiveCaseSpec.groovy | 2 +- .../functional/tests/CurrencySpec.groovy | 2 +- .../functional/tests/privacy/CoppaSpec.groovy | 10 +- .../tests/privacy/GdprAmpSpec.groovy | 4 +- .../tests/privacy/GdprAuctionSpec.groovy | 14 +-- .../GppTransmitUfpdActivitiesSpec.groovy | 118 +++++++++--------- .../functional/tests/privacy/LmtSpec.groovy | 10 +- .../tests/privacy/PrivacyBaseSpec.groovy | 2 +- 10 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy index 0104494910b..2643108e983 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy @@ -9,7 +9,7 @@ import org.prebid.server.functional.util.PBSUtils class User { String id - String buyeruid + String buyerUid Integer yob String gender String keywords diff --git a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy index 195e20977e8..faeb5ab0f62 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy @@ -164,7 +164,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid } def "PBS shouldn't populate bidder request buyeruid from buyeruids when buyeruids without appropriate bidder present in request"() { @@ -204,7 +204,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the uids cookie" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == uidsCookie.tempUIDs[GENERIC].uid + assert bidderRequest?.user?.buyerUid == uidsCookie.tempUIDs[GENERIC].uid cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -230,7 +230,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request shouldn't contain buyeruid from the uids cookie" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert !bidderRequest.user.buyeruid + assert !bidderRequest.user.buyerUid cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -252,7 +252,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid } def "PBS should populate buyeruid from host cookie name config when host cookie family matched with requested bidder"() { @@ -275,7 +275,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from cookieName" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == hostCookieUid + assert bidderRequest?.user?.buyerUid == hostCookieUid } def "PBS shouldn't populate buyeruid from cookie name config when host cookie family not matched with requested cookie-family-name"() { @@ -417,7 +417,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid where: bidderName << [GENERIC, GENERIC_CAMEL_CASE] @@ -448,7 +448,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid where: bidderName << [GENERIC, GENERIC_CAMEL_CASE] diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy index a6dc63f08f8..de60c9be236 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderInsensitiveCaseSpec.groovy @@ -217,7 +217,7 @@ class BidderInsensitiveCaseSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid } def "PBS should be able to match requested bidder with original bidder name in ext.prebid.aliase"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy index 95a7af60ce8..c9ff3d005d3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy @@ -27,7 +27,7 @@ class CurrencySpec extends BaseSpec { } def cleanupSpec() { - pbsServiceFactory.removeContainer(externalCurrencyConverterConfig) + pbsServiceFactory.removeContainer(PbsConfig.currencyConverterConfig) } def "PBS should return currency rates"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy index f93a014f058..ebc3d3b2f23 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy @@ -185,7 +185,7 @@ class CoppaSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == bidRequest.device.geo.ext bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source @@ -254,7 +254,7 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -324,7 +324,7 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -389,7 +389,7 @@ class CoppaSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source @@ -462,7 +462,7 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids 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 a63738ab94b..8eb190ba857 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 @@ -565,7 +565,7 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -640,7 +640,7 @@ class GdprAmpSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source 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 cc2fe5e4156..a6b3fb34fff 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 @@ -611,7 +611,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -689,7 +689,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -765,7 +765,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == bidRequest.device.geo.ext bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source @@ -969,7 +969,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { given: "Default bid requests with personal data" def bidRequest = bidRequestWithPersonalData.tap { regs.gdpr = 1 - user.buyeruid = null + user.buyerUid = null user.ext.consent = new TcfConsent.Builder().build() ext.prebid.trace = VERBOSE } @@ -992,7 +992,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -1038,7 +1038,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -1083,7 +1083,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index 6da825b3f90..d75a38784e8 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -112,7 +112,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -162,7 +162,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -214,7 +214,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -290,7 +290,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -333,7 +333,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -385,7 +385,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -447,7 +447,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -507,7 +507,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -573,7 +573,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -637,7 +637,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -696,7 +696,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -755,7 +755,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -813,7 +813,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -865,7 +865,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -916,7 +916,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1087,7 +1087,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1150,12 +1150,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.zip == bidRequest.user.geo.zip - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1220,12 +1220,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.zip == bidRequest.user.geo.zip - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1279,7 +1279,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1335,7 +1335,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -1394,7 +1394,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -1463,7 +1463,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -1549,7 +1549,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data @@ -1608,7 +1608,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1690,12 +1690,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1749,7 +1749,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1871,7 +1871,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data @@ -1926,7 +1926,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1980,7 +1980,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2074,7 +2074,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data @@ -2126,7 +2126,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2184,7 +2184,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2246,7 +2246,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data @@ -2305,7 +2305,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2365,7 +2365,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2545,7 +2545,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2617,12 +2617,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2695,12 +2695,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2762,7 +2762,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2826,7 +2826,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data @@ -2893,12 +2893,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2967,7 +2967,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data @@ -3037,7 +3037,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data @@ -3141,7 +3141,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data @@ -3209,7 +3209,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3297,12 +3297,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3367,7 +3367,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3483,7 +3483,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3538,7 +3538,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3586,7 +3586,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3652,12 +3652,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Bidder request should have data in EIDS fields" diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy index 4f13b59ff9c..4028fb4d05e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy @@ -377,7 +377,7 @@ class LmtSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -447,7 +447,7 @@ class LmtSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -510,7 +510,7 @@ class LmtSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == bidRequest.device.geo.ext bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source @@ -583,7 +583,7 @@ class LmtSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -649,7 +649,7 @@ class LmtSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source 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 9c5bfb1681d..9cdeab282b3 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 @@ -164,7 +164,7 @@ abstract class PrivacyBaseSpec extends BaseSpec { customdata = PBSUtils.randomString eids = [Eid.defaultEid] data = [new Data(name: PBSUtils.randomString)] - buyeruid = PBSUtils.randomString + buyerUid = PBSUtils.randomString yob = PBSUtils.randomNumber gender = PBSUtils.randomString geo = Geo.FPDGeo From ec1bcf149736c90d1b53cd1a87ae3b47765e1f3c Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Wed, 16 Jul 2025 15:37:56 +0300 Subject: [PATCH 13/25] Fix module tests --- .../prebid/server/functional/model/request/auction/User.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy index 2643108e983..93090dd72e5 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy @@ -1,10 +1,13 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.databind.PropertyNamingStrategies +import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) @EqualsAndHashCode class User { From f5e659331dd2f197f66704087bc48b6a2f5a2d47 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 31 Oct 2025 10:27:39 +0200 Subject: [PATCH 14/25] fix imports --- .../prebid/server/functional/tests/HttpSettingsSpec.groovy | 4 ---- .../server/functional/tests/module/ModuleBaseSpec.groovy | 7 ++----- .../tests/module/optabletargeting/CacheStorageSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineAliasSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineBaseSpec.groovy | 4 +--- .../tests/module/pbruleengine/RuleEngineContextSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineCoreSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineDeviceSpec.groovy | 3 +-- .../pbruleengine/RuleEngineInfrastructureSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEnginePrivacySpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineSpecialSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineSyncSpec.groovy | 2 +- .../tests/module/richmedia/RichMediaFilterSpec.groovy | 6 ------ 13 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy index 87287722929..4c9e42bb888 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy @@ -43,10 +43,6 @@ class HttpSettingsSpec extends BaseSpec { prebidServerService = pbsServiceFactory.removeContainer(PBS_CONFIG_WITH_RFC) } - def cleanupSpec() { - pbsServiceFactory.removeContainer(PbsConfig.httpSettingsConfig) - } - def "PBS should take account information from http data source on auction request"() { given: "Get basic BidRequest with generic bidder and set gdpr = 1" def bidRequest = BidRequest.defaultBidRequest diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy index 8aa47ce1940..6c94d891091 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy @@ -12,7 +12,6 @@ import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.response.auction.AnalyticResult import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.tests.BaseSpec import spock.lang.Shared import org.prebid.server.functional.util.PBSUtils @@ -22,13 +21,11 @@ import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGE import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING import static org.prebid.server.functional.model.config.ModuleName.PB_RESPONSE_CORRECTION import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER -import static org.prebid.server.functional.model.ModuleName.PB_REQUEST_CORRECTION -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_REQUEST_CORRECTION +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION -import static org.prebid.server.functional.model.config.Stage.ALL_PROCESSED_BID_RESPONSES import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer -import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer class ModuleBaseSpec extends BaseSpec { 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..128b00312ee 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 @@ -21,7 +21,7 @@ import org.prebid.server.functional.util.PBSUtils import static org.apache.commons.codec.binary.Base64.encodeBase64 import static org.mockserver.model.HttpStatusCode.NOT_FOUND_404 -import static org.prebid.server.functional.model.ModuleName.OPTABLE_TARGETING +import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGETING import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer class CacheStorageSpec extends ModuleBaseSpec { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy index 4477e6d9d38..cb5653f5d6a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy @@ -2,7 +2,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.request.auction.Imp -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy index d27d44e0fc0..2326be54ddf 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy @@ -19,9 +19,8 @@ import org.prebid.server.functional.model.request.auction.ImpUnitCode import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils -import spock.lang.Retry -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -41,7 +40,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 MULTI_BID_ADAPTERS = [GENERIC, OPENX, AMX].sort() diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy index 5bea040218e..124468a3132 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy @@ -16,7 +16,7 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant import static org.prebid.server.functional.model.ChannelType.WEB -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy index 8e9de1807c9..23f815a8cf4 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy @@ -8,7 +8,7 @@ import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy index 229e54a0ff0..c109e4691e6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy @@ -6,11 +6,10 @@ import org.prebid.server.functional.model.pricefloors.Country import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.DeviceType import org.prebid.server.functional.util.PBSUtils -import spock.lang.RepeatUntilFailure import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy index f710ba39f93..cc5ae6bf1a2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy @@ -6,7 +6,7 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy index c4f207544b5..b8c30337d44 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy @@ -19,7 +19,7 @@ import org.prebid.server.functional.util.privacy.TcfConsent import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy index cce9631e1b9..af06f07e305 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy @@ -5,7 +5,7 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy index 881a8211ca4..72e1e442274 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy @@ -3,7 +3,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.UidsCookie import org.prebid.server.functional.util.HttpUtil -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy index 9fba58d6eab..a31b16c340a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy @@ -452,12 +452,6 @@ class RichMediaFilterSpec extends ModuleBaseSpec { admValue << [PATTERN_NAME, "${PBSUtils.randomString}-${PATTERN_NAME}", "${PATTERN_NAME}.${PBSUtils.randomString}"] } - private static List getAnalyticResults(BidResponse response) { - response.ext.prebid.modules?.trace?.stages?.first() - ?.outcomes?.first()?.groups?.first() - ?.invocationResults?.first()?.analyticsTags?.activities - } - private static Account getAccountWithRichmediaFilter(String accountId, Boolean filterMraid, String mraidScriptPattern) { getAccountWithModuleConfig(accountId, [PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES]).tap { it.config.hooks.modules.pbRichmediaFilter = new RichmediaFilter(filterMraid: filterMraid, mraidScriptPattern: mraidScriptPattern) From d3371fbe5824e24fa577292d6150a1f14412db7b Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 31 Oct 2025 13:26:07 +0200 Subject: [PATCH 15/25] fix imports --- .../server/functional/model/response/auction/ImpResult.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineAliasSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineContextSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineCoreSpec.groovy | 3 ++- .../tests/module/pbruleengine/RuleEngineDeviceSpec.groovy | 2 +- .../module/pbruleengine/RuleEngineInfrastructureSpec.groovy | 3 ++- .../tests/module/pbruleengine/RuleEnginePrivacySpec.groovy | 3 ++- .../tests/module/pbruleengine/RuleEngineSpecialSpec.groovy | 2 +- .../tests/module/pbruleengine/RuleEngineSyncSpec.groovy | 3 ++- 9 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy index 8740e415f47..e95e3ee896e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy @@ -11,7 +11,7 @@ import org.prebid.server.functional.model.request.auction.FetchStatus @EqualsAndHashCode class ImpResult { - FetchStatus status + AnalyticTagStatus status ModuleValue values AppliedTo appliedTo } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy index cb5653f5d6a..a4cc7a15556 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy @@ -11,7 +11,7 @@ import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineAliasSpec extends RuleEngineBaseSpec { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy index 124468a3132..3b9b96c479f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy @@ -33,11 +33,11 @@ import static org.prebid.server.functional.model.pricefloors.MediaType.BANNER import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP import static org.prebid.server.functional.model.request.auction.DistributionChannel.DOOH import static org.prebid.server.functional.model.request.auction.DistributionChannel.SITE -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS import static org.prebid.server.functional.model.request.auction.ImpUnitCode.GPID import static org.prebid.server.functional.model.request.auction.ImpUnitCode.PB_AD_SLOT import static org.prebid.server.functional.model.request.auction.ImpUnitCode.STORED_REQUEST import static org.prebid.server.functional.model.request.auction.ImpUnitCode.TAG_ID +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineContextSpec extends RuleEngineBaseSpec { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy index 23f815a8cf4..58b6e2d5a01 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy @@ -6,6 +6,7 @@ import org.prebid.server.functional.model.config.RuleSet import org.prebid.server.functional.model.config.RulesEngineModelGroup import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.request.auction.Imp +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE @@ -20,8 +21,8 @@ import static org.prebid.server.functional.model.config.RuleEngineModelRuleResul import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithLogATagResult import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.model.pricefloors.Country.BULGARIA -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.ERROR_NO_BID import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy index c109e4691e6..5500ba3c09a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy @@ -19,7 +19,7 @@ import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVIC import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_TYPE import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_TYPE_IN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineDeviceSpec extends RuleEngineBaseSpec { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy index cc5ae6bf1a2..72f8ee83173 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.config.RuleEngineFunctionArgs import org.prebid.server.functional.model.config.RuleEngineModelSchema +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -13,7 +14,7 @@ import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER_IN -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy index b8c30337d44..49b90352640 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy @@ -14,6 +14,7 @@ import org.prebid.server.functional.model.request.auction.SiteExtData import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.model.request.auction.UserExtData +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent @@ -32,7 +33,7 @@ import static org.prebid.server.functional.model.config.RuleEngineFunction.GPP_S 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.auction.DistributionChannel.APP -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID import static org.prebid.server.functional.util.privacy.TcfConsent.PurposeId.BASIC_ADS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy index af06f07e305..a504f7ca37a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy @@ -12,7 +12,7 @@ import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.PERCENT import static org.prebid.server.functional.model.config.RuleEngineFunction.PREBID_KEY -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineSpecialSpec extends RuleEngineBaseSpec { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy index 72e1e442274..b62f1cff541 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.UidsCookie +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.HttpUtil import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE @@ -10,7 +11,7 @@ import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineSyncSpec extends RuleEngineBaseSpec { From 11f47a333bb2e9ba02c18538df744760a7966cf9 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 31 Oct 2025 18:37:57 +0200 Subject: [PATCH 16/25] fix mr conflicts --- .../response/auction/AnalyticResult.groovy | 6 +++--- .../functional/tests/TargetingSpec.groovy | 21 ------------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy index 8d1967bf09d..5b605b12c0f 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy @@ -6,8 +6,8 @@ import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.model.request.auction.Imp -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS_BLOCK +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS_BLOCK @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) @@ -21,6 +21,6 @@ class AnalyticResult { static AnalyticResult buildFromImp(Imp imp) { def appliedTo = new AppliedTo(impIds: [imp.id], bidders: [imp.ext.prebid.bidder.configuredBidders.first()]) def impResult = new ImpResult(status: SUCCESS_BLOCK, values: new ModuleValue(richmediaFormat: 'mraid'), appliedTo: appliedTo) - new AnalyticResult(name: 'reject-richmedia', status: AnalyticTagStatus.SUCCESS, results: [impResult]) + new AnalyticResult(name: 'reject-richmedia', status: SUCCESS, results: [impResult]) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy index 9638b843c5e..d9d337b3c27 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TargetingSpec.groovy @@ -955,9 +955,6 @@ class TargetingSpec extends BaseSpec { def targeting = ampResponse.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } - - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) } def "PBS amp should use long request targeting prefix when settings.targeting.truncate-attr-chars override"() { @@ -981,9 +978,6 @@ class TargetingSpec extends BaseSpec { def targeting = ampResponse.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } - - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should use long request targeting prefix when settings.targeting.truncate-attr-chars override"() { @@ -1000,9 +994,6 @@ class TargetingSpec extends BaseSpec { def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } - - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should use long account targeting prefix when settings.targeting.truncate-attr-chars override"() { @@ -1024,9 +1015,6 @@ class TargetingSpec extends BaseSpec { def targeting = bidResponse.seatbid?.first()?.bid?.first()?.ext?.prebid?.targeting assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(prefix) } - - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) } def "PBS amp should ignore and add a warning to ext.warnings when value of the account prefix is longer then settings.targeting.truncate-attr-chars"() { @@ -1075,9 +1063,6 @@ class TargetingSpec extends BaseSpec { then: "Amp response should contain warning" def decreasePrefixLength = prefix.length() + TARGETING_PREFIX_LENGTH - DEFAULT_TRUNCATE_CHARS assert ampResponse.ext?.warnings[TARGETING]*.message == [DROP_PREFIX_WARNING.formatted(decreasePrefixLength), truncatedMessage()] - - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should ignore and add a warning to ext.warnings when value of the request prefix is longer then settings.targeting.truncate-attr-chars"() { @@ -1096,9 +1081,6 @@ class TargetingSpec extends BaseSpec { assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } assert bidResponse.ext?.warnings[TARGETING]*.message == [DROP_PREFIX_WARNING.formatted(prefix.length() + TARGETING_PREFIX_LENGTH - DEFAULT_TRUNCATE_CHARS)] - - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) } def "PBS auction should ignore and add a warning to ext.warnings when value of the account prefix is longer then settings.targeting.truncate-attr-chars"() { @@ -1121,9 +1103,6 @@ class TargetingSpec extends BaseSpec { assert !targeting.isEmpty() assert targeting.keySet().every { it -> it.startsWith(DEFAULT_TARGETING_PREFIX) } assert bidResponse.ext?.warnings[TARGETING]*.message == [DROP_PREFIX_WARNING.formatted(prefix.length() + TARGETING_PREFIX_LENGTH - DEFAULT_TRUNCATE_CHARS)] - - cleanup: "Stop and remove pbs container" - pbsServiceFactory.removeContainer(pbsConfig) } def "PBS amp should apply data from query to ext.prebid.amp.data"() { From 8a4d564ae7b1558cf00ca3bc92cca7319a36cb96 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Mon, 3 Nov 2025 13:43:10 +0200 Subject: [PATCH 17/25] Optimize module tests --- .../tests/module/ModuleBaseSpec.groovy | 91 ++++++++++++------- .../optabletargeting/CacheStorageSpec.groovy | 59 +++++------- .../pbruleengine/RuleEngineAliasSpec.groovy | 8 +- .../pbruleengine/RuleEngineBaseSpec.groovy | 37 ++------ .../pbruleengine/RuleEngineContextSpec.groovy | 48 +++++----- .../pbruleengine/RuleEngineCoreSpec.groovy | 38 ++++---- .../pbruleengine/RuleEngineDeviceSpec.groovy | 20 ++-- .../RuleEngineInfrastructureSpec.groovy | 12 +-- .../pbruleengine/RuleEnginePrivacySpec.groovy | 36 ++++---- .../pbruleengine/RuleEngineSpecialSpec.groovy | 16 ++-- .../pbruleengine/RuleEngineSyncSpec.groovy | 12 +-- .../RuleEngineValidationSpec.groovy | 40 ++++---- 12 files changed, 203 insertions(+), 214 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy index 6c94d891091..bf911d38e64 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy @@ -9,13 +9,16 @@ import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.PbsModulesConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.service.PrebidServerService -import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.response.auction.AnalyticResult import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.tests.BaseSpec import spock.lang.Shared import org.prebid.server.functional.util.PBSUtils +import static org.prebid.server.functional.model.bidder.BidderName.AMX +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC +import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGETING import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING @@ -24,22 +27,44 @@ import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_ import static org.prebid.server.functional.model.config.ModuleName.PB_REQUEST_CORRECTION import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION -import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer +import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID class ModuleBaseSpec extends BaseSpec { protected static final String WILDCARD = '*' - private static final Map ORTB_ADAPTER_CONFIG = ['adapter-defaults.ortb.multiformat-supported': 'false'] - private static final Map MODIFYING_VAST_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false", - "adapters.generic.modifying-vast-xml-allowed": "false"] - private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true", - "adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - + protected static final String CONFIG_DATA_CENTER = PBSUtils.randomString protected final static Map EXTERNAL_MODULES_CONFIG = getModuleBaseSettings(PB_RICHMEDIA_FILTER) + getModuleBaseSettings(PB_RESPONSE_CORRECTION) + getModuleBaseSettings(ORTB2_BLOCKING) + - getModuleBaseSettings(PB_REQUEST_CORRECTION) + getModuleBaseSettings(PB_REQUEST_CORRECTION) + + getOptableTargetingSettings() + + getRulesEngineSettings() + + private static final Map ENABLED_DEBUG_LOG_MODE = ["logging.level.root": "debug"] + private static final Map ORTB_ADAPTER_CONFIG = ['adapter-defaults.ortb.multiformat-supported': 'false'] + private static final Map MODIFYING_VAST_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false", + "adapters.generic.modifying-vast-xml-allowed": "false"] + private static final Map CACHE_STORAGE_CONFIG = ['storage.pbc.path' : "$networkServiceContainer.rootUri/stored-cache".toString(), + 'storage.pbc.call-timeout-ms': '1000', + 'storage.pbc.enabled' : 'true', + 'cache.module.enabled' : 'true', + 'pbc.api.key' : PBSUtils.randomString, + 'cache.api-key-secured' : 'false'] + private static final String USER_SYNC_URL = "$networkServiceContainer.rootUri/generic-usersync" + private static final Map GENERIC_CONFIG = [ + "adapters.${GENERIC.value}.usersync.redirect.url" : USER_SYNC_URL, + "adapters.${GENERIC.value}.usersync.redirect.support-cors": false as String, + "adapters.${GENERIC.value}.meta-info.vendor-id" : GENERIC_VENDOR_ID as String] + private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true", + "adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + private static final Map AMX_CONFIG = ["adapters.${AMX}.enabled" : "true", + "adapters.${AMX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + private static final Map OPENX_CONFIG = ["adapters.${OPENX}.enabled" : "true", + "adapters.${OPENX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + + private static final Map OPENX_ALIAS_CONFIG = ["adapters.${OPENX}.aliases.${OPENX_ALIAS}.enabled" : "true", + "adapters.${OPENX}.aliases.${OPENX_ALIAS}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] @Shared protected static PrebidServerService pbsServiceWithMultipleModules @@ -48,10 +73,17 @@ class ModuleBaseSpec extends BaseSpec { prebidCache.setResponse() bidder.setResponse() pbsServiceWithMultipleModules = pbsServiceFactory.getService( - IX_CONFIG + + ['datacenter-region': CONFIG_DATA_CENTER] + + EXTERNAL_MODULES_CONFIG + + ENABLED_DEBUG_LOG_MODE + ORTB_ADAPTER_CONFIG + MODIFYING_VAST_CONFIG + - EXTERNAL_MODULES_CONFIG + CACHE_STORAGE_CONFIG + + GENERIC_CONFIG + + IX_CONFIG + + AMX_CONFIG + + OPENX_CONFIG + + OPENX_ALIAS_CONFIG ) } @@ -76,15 +108,24 @@ class ModuleBaseSpec extends BaseSpec { } } - protected static Map getOptableTargetingSettings(boolean isEnabled = true, Endpoint endpoint = OPENRTB2_AUCTION) { - ["hooks.${OPTABLE_TARGETING.code}.enabled": isEnabled as String, - "hooks.modules.${OPTABLE_TARGETING.code}.api-endpoint" : "$networkServiceContainer.rootUri/stored-cache".toString(), - "hooks.modules.${OPTABLE_TARGETING.code}.tenant" : PBSUtils.randomString, - "hooks.modules.${OPTABLE_TARGETING.code}.origin" : PBSUtils.randomString, - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, [(PROCESSED_AUCTION_REQUEST): [OPTABLE_TARGETING]]))] + protected static Map getOptableTargetingSettings(boolean isEnabled = true) { + ["hooks.${OPTABLE_TARGETING.code}.enabled" : isEnabled as String, + "hooks.modules.${OPTABLE_TARGETING.code}.api-endpoint": "$networkServiceContainer.rootUri/stored-cache".toString(), + "hooks.modules.${OPTABLE_TARGETING.code}.tenant" : PBSUtils.randomString, + "hooks.modules.${OPTABLE_TARGETING.code}.origin" : PBSUtils.randomString] .collectEntries { key, value -> [(key.toString()): value.toString()] } } + protected static Map getRulesEngineSettings() { + ["hooks.${PB_RULE_ENGINE.code}.enabled" : "true", + "hooks.${PB_RULE_ENGINE.code}.rule-cache.expire-after-minutes" : "10000", + "hooks.${PB_RULE_ENGINE.code}.rule-cache.max-size" : "20000", + "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-initial-delay-millis": "10000", + "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-max-delay-millis" : "10000", + "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-factor" : "1.2", + "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-jitter" : "1.2"] + } + protected static Account getAccountWithModuleConfig(String accountId, List modulesHooks, Endpoint endpoint = OPENRTB2_AUCTION) { @@ -95,22 +136,6 @@ class ModuleBaseSpec extends BaseSpec { new Account(uuid: accountId, config: accountConfig) } - protected static Map getRequestCorrectionSettings(Endpoint endpoint = OPENRTB2_AUCTION, Stage stage = PROCESSED_AUCTION_REQUEST) { - ["hooks.${PB_REQUEST_CORRECTION.code}.enabled": "true", - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, PB_REQUEST_CORRECTION, [stage]))] - } - - protected static Map getRulesEngineSettings(Endpoint endpoint = OPENRTB2_AUCTION, Stage stage = PROCESSED_AUCTION_REQUEST) { - ["hooks.${PB_RULE_ENGINE.code}.enabled" : "true", - "hooks.${PB_RULE_ENGINE.code}.rule-cache.expire-after-minutes" : "10000", - "hooks.${PB_RULE_ENGINE.code}.rule-cache.max-size" : "20000", - "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-initial-delay-millis": "10000", - "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-max-delay-millis" : "10000", - "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-factor" : "1.2", - "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-jitter" : "1.2", - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, PB_RULE_ENGINE, [stage]))] - } - protected static List getAnalyticResults(BidResponse response) { response.ext.prebid.modules?.trace?.stages?.first() ?.outcomes?.first()?.groups?.first() 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 128b00312ee..3d551a00139 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 @@ -3,6 +3,7 @@ package org.prebid.server.functional.tests.module.optabletargeting import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.IdentifierType +import org.prebid.server.functional.model.config.ModuleHookImplementation import org.prebid.server.functional.model.config.OperatingSystem import org.prebid.server.functional.model.config.OptableTargetingConfig import org.prebid.server.functional.model.config.PbsModulesConfig @@ -14,13 +15,13 @@ import org.prebid.server.functional.model.request.auction.Eid import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.PublicCountryIp import org.prebid.server.functional.model.request.auction.User -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.scaffolding.StoredCache import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils import static org.apache.commons.codec.binary.Base64.encodeBase64 import static org.mockserver.model.HttpStatusCode.NOT_FOUND_404 +import static org.prebid.server.functional.model.config.ModuleHookImplementation.OPTABLE_TARGETING_PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGETING import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer @@ -36,23 +37,10 @@ class CacheStorageSpec extends ModuleBaseSpec { private static final StoredCache storedCache = new StoredCache(networkServiceContainer) - private static final Map CACHE_STORAGE_CONFIG = ['storage.pbc.path' : "$networkServiceContainer.rootUri/stored-cache".toString(), - 'storage.pbc.call-timeout-ms': '1000', - 'storage.pbc.enabled' : 'true', - 'cache.module.enabled' : 'true', - 'pbc.api.key' : PBSUtils.randomString, - 'cache.api-key-secured' : 'false'] - private static final Map MODULE_STORAGE_CACHE_CONFIG = getOptableTargetingSettings() + CACHE_STORAGE_CONFIG - private static final PrebidServerService prebidServerStoredCacheService = pbsServiceFactory.getService(MODULE_STORAGE_CACHE_CONFIG) - def setup() { storedCache.reset() } - def cleanupSpec() { - pbsServiceFactory.removeContainer(MODULE_STORAGE_CACHE_CONFIG) - } - def "PBS should update error metrics when no cached requests present"() { given: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -65,13 +53,13 @@ class CacheStorageSpec extends ModuleBaseSpec { accountDao.save(account) and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update metrics for new saved text storage cache" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_READ_ERR] == 1 and: "No updates for success metrics" @@ -96,13 +84,13 @@ class CacheStorageSpec extends ModuleBaseSpec { storedCache.setCachingResponse(NOT_FOUND_404) and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update error metrics" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_WRITE_ERR] == 1 and: "No updates for success metrics" @@ -111,7 +99,7 @@ class CacheStorageSpec extends ModuleBaseSpec { def "PBS should update metrics for new saved text storage cache when no cached requests"() { given: "Current value of metric prebid cache" - def okInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_OK) + def okInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_OK) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -128,13 +116,13 @@ class CacheStorageSpec extends ModuleBaseSpec { storedCache.setCachingResponse() and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update metrics for new saved text storage cache" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_SIZE_TEXT] == new String(encodeBase64(encode(targetingResult).bytes)).size() assert metrics[METRIC_CREATIVE_WRITE_OK] == okInitialValue + 1 @@ -144,11 +132,11 @@ class CacheStorageSpec extends ModuleBaseSpec { def "PBS should update metrics for stored cached requests cache when proper record present"() { given: "Current value of metric prebid cache" - def textInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_SIZE_TEXT) - def ttlInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_TTL_TEXT) - def writeInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_OK) - def readErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_READ_ERR) - def writeErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_ERR) + def textInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_SIZE_TEXT) + def ttlInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_TTL_TEXT) + def writeInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_OK) + def readErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_READ_ERR) + def writeErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_ERR) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -165,13 +153,13 @@ class CacheStorageSpec extends ModuleBaseSpec { storedCache.setCachingResponse() and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update metrics for stored cached requests" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_READ_OK] == 1 and: "No updates for new saved text storage metrics" @@ -199,9 +187,8 @@ class CacheStorageSpec extends ModuleBaseSpec { private static Account createAccountWithRequestCorrectionConfig(BidRequest bidRequest, OptableTargetingConfig optableTargetingConfig) { - def pbsModulesConfig = new PbsModulesConfig(optableTargeting: optableTargetingConfig) - def accountHooksConfig = new AccountHooksConfiguration(modules: pbsModulesConfig) - def accountConfig = new AccountConfig(hooks: accountHooksConfig) - new Account(uuid: bidRequest.accountId, config: accountConfig) + getAccountWithModuleConfig(bidRequest.accountId, [OPTABLE_TARGETING_PROCESSED_AUCTION_REQUEST]).tap { + it.config.hooks.modules.optableTargeting = optableTargetingConfig + } } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy index a4cc7a15556..b07003a0fbb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy @@ -35,7 +35,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.size() == 1 @@ -97,7 +97,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -157,7 +157,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seat" assert bidResponse.seatbid.seat == [ALIAS] @@ -219,7 +219,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy index 2326be54ddf..1ac39666347 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy @@ -3,10 +3,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.bidder.Generic import org.prebid.server.functional.model.bidder.Openx -import org.prebid.server.functional.model.config.AccountConfig -import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.PbRulesEngine -import org.prebid.server.functional.model.config.PbsModulesConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.pricefloors.Country import org.prebid.server.functional.model.request.auction.Amx @@ -16,7 +13,6 @@ import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.ImpUnitCode -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils @@ -37,13 +33,10 @@ import static org.prebid.server.functional.model.request.auction.ImpUnitCode.PB_ import static org.prebid.server.functional.model.request.auction.ImpUnitCode.STORED_REQUEST import static org.prebid.server.functional.model.request.auction.ImpUnitCode.TAG_ID import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE -import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer -import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID abstract class RuleEngineBaseSpec extends ModuleBaseSpec { protected static final List MULTI_BID_ADAPTERS = [GENERIC, OPENX, AMX].sort() - protected static final String APPLIED_FOR_ALL_IMPS = "*" protected static final String DEFAULT_CONDITIONS = "default" protected final static String CALL_METRIC = "modules.module.${PB_RULE_ENGINE.code}.stage.${PROCESSED_AUCTION_REQUEST.metricValue}.hook.${PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST.code}.call" protected final static String NOOP_METRIC = "modules.module.${PB_RULE_ENGINE.code}.stage.${PROCESSED_AUCTION_REQUEST.metricValue}.hook.${PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST.code}.success.noop" @@ -72,23 +65,6 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { "Field '$functionType.fieldName' is required and has to be an array of integers" } - protected static final Map ENABLED_DEBUG_LOG_MODE = ["logging.level.root": "debug"] - protected static final Map OPENX_CONFIG = ["adapters.${OPENX}.enabled" : "true", - "adapters.${OPENX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - protected static final Map AMX_CONFIG = ["adapters.${AMX}.enabled" : "true", - "adapters.${AMX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - protected static final Map OPENX_ALIAS_CONFIG = ["adapters.${OPENX}.aliases.${OPENX_ALIAS}.enabled" : "true", - "adapters.${OPENX}.aliases.${OPENX_ALIAS}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - protected static final String CONFIG_DATA_CENTER = PBSUtils.randomString - private static final String USER_SYNC_URL = "$networkServiceContainer.rootUri/generic-usersync" - private static final Map GENERIC_CONFIG = [ - "adapters.${GENERIC.value}.usersync.redirect.url" : USER_SYNC_URL, - "adapters.${GENERIC.value}.usersync.redirect.support-cors": false as String, - "adapters.${GENERIC.value}.meta-info.vendor-id" : GENERIC_VENDOR_ID as String] - protected static final PrebidServerService pbsServiceWithRulesEngineModule = pbsServiceFactory.getService(GENERIC_CONFIG + - getRulesEngineSettings() + AMX_CONFIG + OPENX_CONFIG + OPENX_ALIAS_CONFIG + ['datacenter-region': CONFIG_DATA_CENTER] + - ENABLED_DEBUG_LOG_MODE) - protected static BidRequest getDefaultBidRequestWithMultiplyBidders(DistributionChannel distributionChannel = SITE) { BidRequest.getDefaultBidRequest(distributionChannel).tap { it.tmax = 5_000 // prevents timeout issues on slow pipelines @@ -116,8 +92,9 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { } protected static Account getAccountWithRulesEngine(String accountId, PbRulesEngine ruleEngine) { - def accountHooksConfiguration = new AccountHooksConfiguration(modules: new PbsModulesConfig(pbRuleEngine: ruleEngine)) - new Account(uuid: accountId, config: new AccountConfig(hooks: accountHooksConfiguration)) + getAccountWithModuleConfig(accountId, [PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST]).tap { + it.config.hooks.modules.pbRuleEngine = ruleEngine + } } protected static BidRequest createBidRequestWithDomains(DistributionChannel type, String domain, boolean usePublisher = true) { @@ -180,15 +157,15 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { protected static waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) { PBSUtils.waitUntil({ - pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) - pbsServiceWithRulesEngineModule.isContainLogsByValue("Successfully parsed rule-engine config for account $bidRequest.accountId") + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.isContainLogsByValue("Successfully parsed rule-engine config for account $bidRequest.accountId") }) } protected static waitUntilFailedParsedAndCacheAccount(bidRequest) { PBSUtils.waitUntil({ - pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) - pbsServiceWithRulesEngineModule.isContainLogsByValue("Failed to parse rule-engine config for account $bidRequest.accountId") + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.isContainLogsByValue("Failed to parse rule-engine config for account $bidRequest.accountId") }) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy index 3b9b96c479f..e82a78754da 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy @@ -62,7 +62,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -122,7 +122,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -164,7 +164,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -229,7 +229,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -274,7 +274,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -293,7 +293,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, DOMAIN_IN)) where: @@ -339,7 +339,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -405,7 +405,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -468,7 +468,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -530,7 +530,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -574,7 +574,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -593,7 +593,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors then: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, BUNDLE_IN)) } @@ -620,7 +620,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -682,7 +682,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -724,7 +724,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -743,7 +743,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) then: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, MEDIA_TYPE_IN)) where: @@ -774,7 +774,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -834,7 +834,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -882,7 +882,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -953,7 +953,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -1006,7 +1006,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -1025,7 +1025,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, AD_UNIT_CODE_IN)) where: @@ -1062,7 +1062,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -1125,7 +1125,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy index 58b6e2d5a01..ab264a09c27 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy @@ -45,10 +45,10 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) and: "Flush metric" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Response should contain seat bid" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -64,7 +64,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors and: "PBs should populate call and update metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[CALL_METRIC] == 1 assert metrics[UPDATE_METRIC] == 1 @@ -95,7 +95,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -159,7 +159,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -212,7 +212,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.size() == 0 @@ -245,7 +245,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -278,7 +278,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat == [OPENX] @@ -338,7 +338,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seatBids" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -397,7 +397,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat == [GENERIC] @@ -455,7 +455,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -487,7 +487,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { it.values.resultFunction == groups.rules.first.results.first.function.value it.values.conditionFired == groups.rules.first.conditions.first - it.appliedTo.impIds == [APPLIED_FOR_ALL_IMPS] + it.appliedTo.impIds == [WILDCARD] } verifyAll(impResult) { @@ -514,7 +514,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Response should contain seat bid" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -578,7 +578,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Response should contain seat bid" assert bidResponse.seatbid.seat.sort() == [GENERIC, OPENX].sort() @@ -646,7 +646,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -706,7 +706,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -766,7 +766,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -797,7 +797,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { it.values.analyticsValue == analyticsValue it.values.resultFunction == LOG_A_TAG.value it.values.conditionFired == DEFAULT_CONDITIONS - it.appliedTo.impIds == [APPLIED_FOR_ALL_IMPS] + it.appliedTo.impIds == [WILDCARD] } and: "Analytics imp result shouldn't contain remove info" @@ -826,7 +826,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain two seat" assert bidResponse.seatbid.size() == 2 diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy index 5500ba3c09a..3891eafd32c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy @@ -46,7 +46,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -108,7 +108,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -150,7 +150,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -213,7 +213,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -257,7 +257,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -276,7 +276,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, DEVICE_COUNTRY_IN)) } @@ -305,7 +305,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -324,7 +324,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_INTEGERS_LOG_WARNING(bidRequest.accountId, DEVICE_TYPE_IN)) } @@ -351,7 +351,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -413,7 +413,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy index 72f8ee83173..a312d9978ad 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy @@ -42,7 +42,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -61,7 +61,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, DATA_CENTER_IN)) } @@ -85,7 +85,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -145,7 +145,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -184,7 +184,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -244,7 +244,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy index 49b90352640..367027fc609 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy @@ -59,7 +59,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -121,7 +121,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -168,7 +168,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -187,7 +187,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, EID_IN)) } @@ -214,7 +214,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -276,7 +276,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -314,7 +314,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -378,7 +378,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -417,7 +417,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -493,7 +493,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -555,7 +555,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -614,7 +614,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -661,7 +661,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -680,7 +680,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_INTEGERS_LOG_WARNING(bidRequest.accountId, GPP_SID_IN)) } @@ -706,7 +706,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -771,7 +771,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -819,7 +819,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -890,7 +890,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy index a504f7ca37a..416590b010f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy @@ -40,7 +40,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -59,7 +59,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_SINGLE_INTEGER_LOG_WARNING(bidRequest.accountId, PERCENT)) } @@ -83,7 +83,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -143,7 +143,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -188,7 +188,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -207,7 +207,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_SINGLE_STRING_LOG_WARNING(bidRequest.accountId, PREBID_KEY)) } @@ -236,7 +236,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -300,7 +300,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy index b62f1cff541..0f902b7b31b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy @@ -36,7 +36,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX] @@ -93,7 +93,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -129,7 +129,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -168,7 +168,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response shouldn't contain seat" assert bidResponse.seatbid.seat == [GENERIC] @@ -228,7 +228,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response shouldn't contain seat" assert !bidResponse.seatbid.seat @@ -278,7 +278,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { accountDao.save(accountWithRulesEngine) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy index dbf7395c1f0..6cc940023b9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy @@ -35,10 +35,10 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) and: "Flush metrics" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -57,7 +57,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBs should populate call and noop metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[CALL_METRIC] == 1 assert metrics[NOOP_METRIC] == 1 @@ -89,10 +89,10 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) and: "Flush metrics" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -111,7 +111,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBs should populate noop metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[NOOP_METRIC] == 1 } @@ -130,10 +130,10 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) and: "Flush metrics" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -149,7 +149,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS and: "PBs should populate failer metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[NOOP_METRIC] == 1 } @@ -171,7 +171,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -187,7 +187,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS and: "PBs should emit failed logs" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, "Failed to parse rule-engine config for account $bidRequest.accountId:" + " Weighted list cannot be empty") } @@ -209,7 +209,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -239,7 +239,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { accountDao.save(accountWithRulesEngine) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -278,7 +278,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -312,7 +312,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { accountDao.save(accountWithRulesEngine) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -331,7 +331,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBs should emit failed logs" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, "Parsing rule for account $bidRequest.accountId").size() == 1 } @@ -357,7 +357,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -376,7 +376,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBS should emit log" - def logsByTime = pbsServiceWithRulesEngineModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, "Failed to parse rule-engine config for account $bidRequest.accountId:" + " Weight must be greater than zero") @@ -407,7 +407,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -426,7 +426,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, "Failed to parse rule-engine config for account ${bidRequest.accountId}: " + "Function '${function.value}' configuration is invalid: No arguments allowed") From de083663c4e94d59d25f273f5419f6bd2c670a05 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Mon, 3 Nov 2025 18:50:47 +0200 Subject: [PATCH 18/25] fix gpp error --- .../functional/tests/privacy/GppAuctionSpec.groovy | 2 +- .../functional/tests/privacy/GppCookieSyncSpec.groovy | 1 - .../tests/privacy/GppSyncUserActivitiesSpec.groovy | 2 +- .../tests/privacy/GppTransmitEidsActivitiesSpec.groovy | 4 ++-- .../tests/privacy/GppTransmitUfpdActivitiesSpec.groovy | 4 ++-- .../functional/tests/privacy/PrivacyBaseSpec.groovy | 10 ++++++++++ 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy index 4eb78ee2140..7d918287220 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy @@ -108,7 +108,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 = invalidGppString def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gpp: invalidGpp) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy index a5a6a13ca09..fb880039585 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy @@ -18,7 +18,6 @@ import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.gpp.TcfEuV2Consent import org.prebid.server.functional.util.privacy.gpp.UsV1Consent -import spock.lang.IgnoreRest import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.GENERIC diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy index 2303bfc9e5f..b78f78f1fc8 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy @@ -533,7 +533,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 = invalidGppString 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/GppTransmitEidsActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy index 41e1079986d..4f1d4be16ed 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy @@ -897,7 +897,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 = invalidGppString def bidRequest = getBidRequestWithPersonalData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = invalidGpp @@ -2023,7 +2023,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = getBidRequestWithPersonalData(accountId) and: "Default amp request with link to account" - def invalidGpp = PBSUtils.randomString + def invalidGpp = invalidGppString 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/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index d75a38784e8..c361fa63846 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -1182,7 +1182,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 = invalidGppString def bidRequest = getBidRequestWithPersonalData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = invalidGpp @@ -2651,7 +2651,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = getBidRequestWithPersonalData(accountId) and: "Default amp request with link to account" - def invalidGpp = PBSUtils.randomString + def invalidGpp = invalidGppString 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/PrivacyBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/PrivacyBaseSpec.groovy index 9cdeab282b3..3b950ba4a32 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 @@ -581,6 +581,16 @@ abstract class PrivacyBaseSpec extends BaseSpec { }) } + protected static String getInvalidGppString(int stringLength = 20) { + // Random string can potentially generate deprecated v1 value with specific starting values + def gppV1Prefix = ['A', 'B', 'C', 'D'] + def invalidGPPValue + do { + invalidGPPValue = PBSUtils.getRandomString(stringLength) + } while (gppV1Prefix.contains(invalidGPPValue[0].toUpperCase())) + return invalidGPPValue + } + private static Purpose getRandomPurposeWithExclusion(Purpose excludeFromRandom) { def availablePurposes = Purpose.values().toList() - excludeFromRandom availablePurposes.shuffled().first() From 6f32685dfd595ad72724ca5b3e74e1efd7f93638 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Fri, 7 Nov 2025 10:18:45 +0200 Subject: [PATCH 19/25] update module tests --- .../functional/model/config/ModuleName.groovy | 8 +- .../tests/module/ModuleBaseSpec.groovy | 86 +++++++++++-------- .../RuleEngineInfrastructureSpec.groovy | 7 +- .../server/functional/util/PBSUtils.groovy | 2 +- 4 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy b/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy index 3e5a8368928..9632eccbbfa 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy @@ -4,12 +4,12 @@ import com.fasterxml.jackson.annotation.JsonValue enum ModuleName { - PB_RICHMEDIA_FILTER("pb-richmedia-filter"), - PB_RESPONSE_CORRECTION ("pb-response-correction"), - ORTB2_BLOCKING("ortb2-blocking"), + PB_RICHMEDIA_FILTER('pb-richmedia-filter'), + PB_RESPONSE_CORRECTION ('pb-response-correction'), + ORTB2_BLOCKING('ortb2-blocking'), PB_REQUEST_CORRECTION('pb-request-correction'), OPTABLE_TARGETING('optable-targeting'), - PB_RULE_ENGINE('pb-rule-engine') + PB_RULE_ENGINE('pb-rule-engine'), @JsonValue final String code diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy index bf911d38e64..e2e08fd662e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy @@ -8,63 +8,69 @@ import org.prebid.server.functional.model.config.ModuleHookImplementation import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.PbsModulesConfig import org.prebid.server.functional.model.db.Account -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.model.response.auction.AnalyticResult import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.BaseSpec -import spock.lang.Shared import org.prebid.server.functional.util.PBSUtils +import spock.lang.Shared import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC +import static org.prebid.server.functional.model.bidder.BidderName.IX import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS +import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGETING import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING +import static org.prebid.server.functional.model.config.ModuleName.PB_REQUEST_CORRECTION import static org.prebid.server.functional.model.config.ModuleName.PB_RESPONSE_CORRECTION import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER -import static org.prebid.server.functional.model.config.ModuleName.PB_REQUEST_CORRECTION import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE -import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID class ModuleBaseSpec extends BaseSpec { protected static final String WILDCARD = '*' - protected static final String CONFIG_DATA_CENTER = PBSUtils.randomString - protected final static Map EXTERNAL_MODULES_CONFIG = getModuleBaseSettings(PB_RICHMEDIA_FILTER) + - getModuleBaseSettings(PB_RESPONSE_CORRECTION) + - getModuleBaseSettings(ORTB2_BLOCKING) + - getModuleBaseSettings(PB_REQUEST_CORRECTION) + - getOptableTargetingSettings() + - getRulesEngineSettings() + protected static final String RANDOM_DATACENTER_REGION = PBSUtils.randomString + + protected static final Map GENERIC_CONFIG = [ + "adapters.${GENERIC.value}.usersync.redirect.url" : "$networkServiceContainer.rootUri/generic-usersync".toString(), + "adapters.${GENERIC.value}.usersync.redirect.support-cors": 'false', + "adapters.${GENERIC.value}.meta-info.vendor-id" : GENERIC_VENDOR_ID.toString()] + + protected static final Map IX_CONFIG = ["adapters.${IX}.enabled" : "true", + "adapters.${IX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + protected static final Map AMX_CONFIG = ["adapters.${AMX}.enabled" : "true", + "adapters.${AMX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + protected static final Map OPENX_CONFIG = ["adapters.${OPENX}.enabled" : "true", + "adapters.${OPENX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + + protected static final Map OPENX_ALIAS_CONFIG = ["adapters.${OPENX}.aliases.${OPENX_ALIAS}.enabled" : "true", + "adapters.${OPENX}.aliases.${OPENX_ALIAS}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] private static final Map ENABLED_DEBUG_LOG_MODE = ["logging.level.root": "debug"] + private static final Map ORTB_ADAPTER_CONFIG = ['adapter-defaults.ortb.multiformat-supported': 'false'] + private static final Map MODIFYING_VAST_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false", "adapters.generic.modifying-vast-xml-allowed": "false"] + private static final Map CACHE_STORAGE_CONFIG = ['storage.pbc.path' : "$networkServiceContainer.rootUri/stored-cache".toString(), 'storage.pbc.call-timeout-ms': '1000', 'storage.pbc.enabled' : 'true', 'cache.module.enabled' : 'true', 'pbc.api.key' : PBSUtils.randomString, 'cache.api-key-secured' : 'false'] - private static final String USER_SYNC_URL = "$networkServiceContainer.rootUri/generic-usersync" - private static final Map GENERIC_CONFIG = [ - "adapters.${GENERIC.value}.usersync.redirect.url" : USER_SYNC_URL, - "adapters.${GENERIC.value}.usersync.redirect.support-cors": false as String, - "adapters.${GENERIC.value}.meta-info.vendor-id" : GENERIC_VENDOR_ID as String] - private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true", - "adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - private static final Map AMX_CONFIG = ["adapters.${AMX}.enabled" : "true", - "adapters.${AMX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - private static final Map OPENX_CONFIG = ["adapters.${OPENX}.enabled" : "true", - "adapters.${OPENX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - - private static final Map OPENX_ALIAS_CONFIG = ["adapters.${OPENX}.aliases.${OPENX_ALIAS}.enabled" : "true", - "adapters.${OPENX}.aliases.${OPENX_ALIAS}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + + protected final static Map EXTERNAL_MODULES_CONFIG = getModuleBaseSettings(PB_RICHMEDIA_FILTER) + + getModuleBaseSettings(PB_RESPONSE_CORRECTION) + + getModuleBaseSettings(ORTB2_BLOCKING) + + getModuleBaseSettings(PB_REQUEST_CORRECTION) + + getOptableTargetingSettings() + + getRulesEngineSettings() @Shared protected static PrebidServerService pbsServiceWithMultipleModules @@ -72,19 +78,7 @@ class ModuleBaseSpec extends BaseSpec { def setupSpec() { prebidCache.setResponse() bidder.setResponse() - pbsServiceWithMultipleModules = pbsServiceFactory.getService( - ['datacenter-region': CONFIG_DATA_CENTER] + - EXTERNAL_MODULES_CONFIG + - ENABLED_DEBUG_LOG_MODE + - ORTB_ADAPTER_CONFIG + - MODIFYING_VAST_CONFIG + - CACHE_STORAGE_CONFIG + - GENERIC_CONFIG + - IX_CONFIG + - AMX_CONFIG + - OPENX_CONFIG + - OPENX_ALIAS_CONFIG - ) + pbsServiceWithMultipleModules = pbsServiceFactory.getService(getDefaultMultipleModulesConfig()) } def cleanupSpec() { @@ -93,6 +87,21 @@ class ModuleBaseSpec extends BaseSpec { repository.removeAllDatabaseData() } + protected Map getDefaultMultipleModulesConfig() { + ['datacenter-region': RANDOM_DATACENTER_REGION] + + EMPTY_CACHE_TTL_CONFIG + + EXTERNAL_MODULES_CONFIG + + ENABLED_DEBUG_LOG_MODE + + ORTB_ADAPTER_CONFIG + + MODIFYING_VAST_CONFIG + + CACHE_STORAGE_CONFIG + + GENERIC_CONFIG + + IX_CONFIG + + AMX_CONFIG + + OPENX_CONFIG + + OPENX_ALIAS_CONFIG + } + protected static Map getModuleBaseSettings(ModuleName name, boolean isEnabled = true) { [("hooks.${name.code}.enabled".toString()): isEnabled as String] } @@ -124,6 +133,7 @@ class ModuleBaseSpec extends BaseSpec { "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-max-delay-millis" : "10000", "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-factor" : "1.2", "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-jitter" : "1.2"] + .collectEntries { key, value -> [(key.toString()): value.toString()] } } protected static Account getAccountWithModuleConfig(String accountId, diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy index a312d9978ad..dd7dcd2bdc6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy @@ -2,7 +2,6 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.config.RuleEngineFunctionArgs import org.prebid.server.functional.model.config.RuleEngineModelSchema -import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -30,7 +29,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { def pbRuleEngine = createRulesEngineWithRule().tap { it.ruleSets[0].modelGroups[0].schema[0].tap { it.function = DATA_CENTER_IN - it.args = new RuleEngineFunctionArgs(countries: [CONFIG_DATA_CENTER]) + it.args = new RuleEngineFunctionArgs(countries: [RANDOM_DATACENTER_REGION]) } } @@ -73,7 +72,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { def pbRuleEngine = createRulesEngineWithRule().tap { it.ruleSets[0].modelGroups[0].schema[0].tap { it.function = DATA_CENTER_IN - it.args = new RuleEngineFunctionArgs(datacenters: [CONFIG_DATA_CENTER]) + it.args = new RuleEngineFunctionArgs(datacenters: [RANDOM_DATACENTER_REGION]) } } @@ -172,7 +171,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { def pbRuleEngine = createRulesEngineWithRule().tap { it.ruleSets[0].modelGroups[0].tap { schema = [new RuleEngineModelSchema(function: DATA_CENTER)] - rules[0].conditions = [CONFIG_DATA_CENTER] + rules[0].conditions = [RANDOM_DATACENTER_REGION] } } 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..46633e32453 100644 --- a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy @@ -48,7 +48,7 @@ class PBSUtils implements ObjectMapperWrapper { static String getRandomString(int stringLength = 20) { RandomStringUtils.randomAlphanumeric(stringLength) - } + } static String getRandomSpecialChars(int stringLength = 20) { RandomStringUtils.random(stringLength, "!@#\$%^&*()-_=+[]{}|;:'\",.<>/?") From 82c8a7d4d773614f5bbe334aef6b27ae00b22ece Mon Sep 17 00:00:00 2001 From: markiian Date: Tue, 2 Dec 2025 17:09:25 +0200 Subject: [PATCH 20/25] Move creation of local stack container --- .../server/functional/testcontainers/Dependencies.groovy | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy index 70c99a2a833..7f0b697c1dc 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy @@ -37,13 +37,12 @@ class Dependencies { static final NetworkServiceContainer networkServiceContainer = new NetworkServiceContainer(MOCKSERVER_VERSION) .withNetwork(network) - static LocalStackContainer localStackContainer + static LocalStackContainer localStackContainer = new LocalStackContainer(DockerImageName.parse("localstack/localstack:s3-latest")) + .withNetwork(network) + .withServices(S3) static void start() { if (IS_LAUNCH_CONTAINERS) { - localStackContainer = new LocalStackContainer(DockerImageName.parse("localstack/localstack:s3-latest")) - .withNetwork(network) - .withServices(S3) Startables.deepStart([networkServiceContainer, mysqlContainer, localStackContainer]).join() } } From 5761e58bd2122c1179c639283fec47e7481ff7e6 Mon Sep 17 00:00:00 2001 From: markiian Date: Wed, 3 Dec 2025 18:29:20 +0200 Subject: [PATCH 21/25] Removing duplication and add NOOP metrics --- .../tests/module/AbTestingModuleSpec.groovy | 53 +++++-------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index fa45bb59ef2..6c8d05a76cb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -34,6 +34,7 @@ import static org.prebid.server.functional.model.response.auction.ResponseAction class AbTestingModuleSpec extends ModuleBaseSpec { + private final static String NOOP_METRIC = "modules.module.%s.stage.%s.hook.%s.success.noop" private final static String NO_INVOCATION_METRIC = "modules.module.%s.stage.%s.hook.%s.success.no-invocation" private final static String CALL_METRIC = "modules.module.%s.stage.%s.hook.%s.call" private final static String EXECUTION_ERROR_METRIC = "modules.module.%s.stage.%s.hook.%s.execution-error" @@ -90,8 +91,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -130,10 +132,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be with error call" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[EXECUTION_ERROR_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[EXECUTION_ERROR_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 @@ -174,8 +174,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 @@ -242,9 +243,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for allowed to run response-correction module should be updated based on ab test config" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert !metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] } def "PBS should apply a/b test config for each module when multiple config are presents and set to skip modules"() { @@ -299,13 +300,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 + assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 and: "Metric for skipped response-correction module should be updated based on ab test config" assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 + assert !metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 } def "PBS should apply a/b test config for each module when multiple config are presents with different percentage"() { @@ -364,7 +364,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert !metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] } def "PBS should ignore accounts property for a/b test config when ab test config specialize for specific account"() { @@ -440,8 +440,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -584,8 +582,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -720,8 +716,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -815,9 +809,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -878,9 +869,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -941,13 +929,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 and: "Metric for skipped response-correction module should be updated based on ab test config" assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 cleanup: "Stop and remove pbs container" @@ -999,17 +983,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -1071,9 +1050,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 2 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 2 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -1140,9 +1116,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" From ef7d3487d6ef7c1a3bfd8070534cf5d0d1b5b90f Mon Sep 17 00:00:00 2001 From: markiian Date: Wed, 3 Dec 2025 23:23:47 +0200 Subject: [PATCH 22/25] Resolve conflict --- .../server/functional/tests/module/AbTestingModuleSpec.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index 6c8d05a76cb..a0b26584678 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -8,7 +8,6 @@ import org.prebid.server.functional.model.config.ExecutionPlan import org.prebid.server.functional.model.config.Stage 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.FetchStatus import org.prebid.server.functional.model.request.auction.TraceLevel import org.prebid.server.functional.model.response.auction.AnalyticResult import org.prebid.server.functional.model.response.auction.AnalyticTagStatus From a091b96a0a5ab876a89c9798cc76d582afe55eee Mon Sep 17 00:00:00 2001 From: markiian Date: Thu, 4 Dec 2025 13:04:01 +0200 Subject: [PATCH 23/25] Update: Remove unnecessary metics checks --- .../server/functional/tests/module/AbTestingModuleSpec.groovy | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index a0b26584678..8e8f725fb57 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -244,7 +244,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] } def "PBS should apply a/b test config for each module when multiple config are presents and set to skip modules"() { @@ -303,7 +302,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for skipped response-correction module should be updated based on ab test config" assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 } @@ -363,7 +361,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] } def "PBS should ignore accounts property for a/b test config when ab test config specialize for specific account"() { From 4fb9287fd0306f40221763dfd75442478ad02ad0 Mon Sep 17 00:00:00 2001 From: markiian Date: Thu, 4 Dec 2025 13:19:33 +0200 Subject: [PATCH 24/25] Update: Remove unnecessary metics checks --- .../server/functional/tests/module/AbTestingModuleSpec.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index 8e8f725fb57..1b3b4407b0b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -298,11 +298,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 and: "Metric for skipped response-correction module should be updated based on ab test config" assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 } def "PBS should apply a/b test config for each module when multiple config are presents with different percentage"() { From 7604047646140dfecbbd5efe48f9208ceded73f6 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Tue, 12 May 2026 20:33:03 +0300 Subject: [PATCH 25/25] Refactor tests metrics --- .../functional/model/bidder/Adrino.groovy | 6 + .../{request/auction => bidder}/Amx.groovy | 4 +- .../{request/auction => bidder}/Ix.groovy | 4 +- .../{request/auction => bidder}/IxDiag.groovy | 2 +- .../functional/model/privacy/Metric.groovy | 52 --- .../model/request/auction/Adrino.groovy | 6 - .../request/auction/BidRequestExt.groovy | 8 +- .../model/request/auction/Bidder.groovy | 3 + .../tests/AlternateBidderCodeSpec.groovy | 78 ++-- .../functional/tests/AuctionSpec.groovy | 21 +- .../server/functional/tests/BaseSpec.groovy | 1 - .../functional/tests/BidAdjustmentSpec.groovy | 2 +- .../functional/tests/BidValidationSpec.groovy | 7 +- .../functional/tests/BidderFormatSpec.groovy | 63 +-- .../functional/tests/BidderParamsSpec.groovy | 4 +- .../server/functional/tests/CacheSpec.groovy | 66 ++- .../functional/tests/CacheVtrackSpec.groovy | 69 ++- .../functional/tests/CookieSyncSpec.groovy | 9 +- .../server/functional/tests/DebugSpec.groovy | 31 +- .../server/functional/tests/GeoSpec.groovy | 58 ++- .../functional/tests/MetricsSpec.groovy | 46 +- .../functional/tests/ProfileSpec.groovy | 26 +- .../server/functional/tests/SetUidSpec.groovy | 15 +- .../server/functional/tests/UUIDSpec.groovy | 9 +- .../tests/bidder/openx/OpenxSpec.groovy | 3 +- .../tests/module/AbTestingModuleSpec.groovy | 172 ++++---- .../tests/module/GeneralModuleSpec.groovy | 139 +++--- .../optabletargeting/CacheStorageSpec.groovy | 55 +-- .../ortb2blocking/Ortb2BlockingSpec.groovy | 3 +- .../pbruleengine/RuleEngineAliasSpec.groovy | 2 +- .../pbruleengine/RuleEngineBaseSpec.groovy | 7 +- .../pbruleengine/RuleEngineContextSpec.groovy | 2 +- .../pbruleengine/RuleEngineCoreSpec.groovy | 8 +- .../pbruleengine/RuleEngineDeviceSpec.groovy | 2 +- .../RuleEngineInfrastructureSpec.groovy | 2 +- .../pbruleengine/RuleEnginePrivacySpec.groovy | 3 +- .../pbruleengine/RuleEngineSpecialSpec.groovy | 2 +- .../pbruleengine/RuleEngineSyncSpec.groovy | 3 +- .../RuleEngineValidationSpec.groovy | 13 +- .../ResponseCorrectionSpec.groovy | 2 - .../pricefloors/PriceFloorsBaseSpec.groovy | 3 +- .../PriceFloorsFetchingSpec.groovy | 58 +-- .../pricefloors/PriceFloorsRulesSpec.groovy | 2 +- .../PriceFloorsSignalingSpec.groovy | 35 +- .../tests/privacy/CcpaAmpSpec.groovy | 27 +- .../tests/privacy/CcpaAuctionSpec.groovy | 58 ++- .../functional/tests/privacy/CoppaSpec.groovy | 88 ++-- .../tests/privacy/GdprAmpSpec.groovy | 41 +- .../tests/privacy/GdprAuctionSpec.groovy | 103 +++-- .../tests/privacy/GdprSetUidSpec.groovy | 7 +- .../privacy/GppFetchBidActivitiesSpec.groovy | 78 ++-- .../privacy/GppSyncUserActivitiesSpec.groovy | 72 ++-- .../GppTransmitEidsActivitiesSpec.groovy | 105 +++-- ...GppTransmitPreciseGeoActivitiesSpec.groovy | 80 ++-- .../GppTransmitTidActivitiesSpec.groovy | 19 +- .../GppTransmitUfpdActivitiesSpec.groovy | 115 +++-- .../functional/tests/privacy/LmtSpec.groovy | 89 ++-- .../tests/privacy/PrivacyBaseSpec.groovy | 3 +- .../server/functional/util/Metrics.groovy | 408 ++++++++++++++++++ 59 files changed, 1343 insertions(+), 1056 deletions(-) create mode 100644 src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy rename src/test/groovy/org/prebid/server/functional/model/{request/auction => bidder}/Amx.groovy (62%) rename src/test/groovy/org/prebid/server/functional/model/{request/auction => bidder}/Ix.groovy (81%) rename src/test/groovy/org/prebid/server/functional/model/{request/auction => bidder}/IxDiag.groovy (75%) delete mode 100644 src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/util/Metrics.groovy diff --git a/src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy new file mode 100644 index 00000000000..8b1ff813fe6 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy @@ -0,0 +1,6 @@ +package org.prebid.server.functional.model.bidder + +class Adrino implements BidderAdapter { + + Integer hash +} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Amx.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Amx.groovy similarity index 62% rename from src/test/groovy/org/prebid/server/functional/model/request/auction/Amx.groovy rename to src/test/groovy/org/prebid/server/functional/model/bidder/Amx.groovy index 3ae0dcd17a3..28f89053cd6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Amx.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Amx.groovy @@ -1,8 +1,6 @@ -package org.prebid.server.functional.model.request.auction +package org.prebid.server.functional.model.bidder import com.fasterxml.jackson.annotation.JsonProperty -import org.prebid.server.functional.model.bidder.BidderAdapter -import org.prebid.server.functional.model.bidder.BidderName class Amx implements BidderAdapter { diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Ix.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Ix.groovy similarity index 81% rename from src/test/groovy/org/prebid/server/functional/model/request/auction/Ix.groovy rename to src/test/groovy/org/prebid/server/functional/model/bidder/Ix.groovy index a620c7646b1..73fa3ef64e0 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Ix.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Ix.groovy @@ -1,10 +1,10 @@ -package org.prebid.server.functional.model.request.auction +package org.prebid.server.functional.model.bidder import groovy.transform.EqualsAndHashCode import org.prebid.server.functional.util.PBSUtils @EqualsAndHashCode -class Ix { +class Ix implements BidderAdapter { String siteId List size diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/IxDiag.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/IxDiag.groovy similarity index 75% rename from src/test/groovy/org/prebid/server/functional/model/request/auction/IxDiag.groovy rename to src/test/groovy/org/prebid/server/functional/model/bidder/IxDiag.groovy index d68075b6668..5100c7d0f18 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/IxDiag.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/IxDiag.groovy @@ -1,4 +1,4 @@ -package org.prebid.server.functional.model.request.auction +package org.prebid.server.functional.model.bidder import groovy.transform.ToString diff --git a/src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy b/src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy deleted file mode 100644 index 80d779e069d..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.functional.model.privacy - -import org.prebid.server.functional.model.request.auction.ActivityType -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest -import org.prebid.server.functional.model.request.setuid.SetuidRequest - -enum Metric { - - PROCESSED_ACTIVITY_RULES_COUNT("requests.activity.processedrules.count"), - ACCOUNT_PROCESSED_RULES_COUNT("requests.activity.processedrules.count"), - TEMPLATE_ADAPTER_DISALLOWED_COUNT("adapter.{bidderName}.activity.{activityType}.disallowed.count"), - TEMPLATE_ACCOUNT_DISALLOWED_COUNT("account.{accountId}.activity.{activityType}.disallowed.count"), - TEMPLATE_REQUEST_DISALLOWED_COUNT("requests.activity.{activityType}.disallowed.count"), - - final String value - - Metric(String value) { - this.value = value - } - - String getValue(BidRequest bidRequest, String accountId, ActivityType activityType) { - if (bidRequest.imp.size() != 1) { - throw new IllegalStateException("No imp found") - } - replaceValues(bidRequest.imp.first.bidderName.value, accountId, activityType.metricValue) - } - - String getValue(BidRequest bidRequest, ActivityType activityType) { - if (bidRequest.imp.size() != 1) { - throw new IllegalStateException("No imp found") - } - replaceValues(bidRequest.imp.first.bidderName.value, bidRequest.accountId, activityType.metricValue) - } - - String getValue(CookieSyncRequest syncRequest, ActivityType activityType) { - if (syncRequest.bidders.size() != 1) { - throw new IllegalStateException("No bidder found") - } - replaceValues(syncRequest.bidders.first.value, syncRequest.account, activityType.metricValue) - } - - String getValue(SetuidRequest syncRequest, ActivityType activityType) { - replaceValues(syncRequest.bidder.value, syncRequest.account, activityType.metricValue) - } - - private String replaceValues(String bidderName, String accountId, String activityType) { - this.value.replaceAll('\\{bidderName}', bidderName) - .replaceAll('\\{accountId}', accountId) - .replaceAll('\\{activityType}', activityType) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy deleted file mode 100644 index 2d1675194e9..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.functional.model.request.auction - -class Adrino { - - Integer hash -} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy index 3c39de5781e..efc7a9f3c37 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.model.bidder.AppNexus +import org.prebid.server.functional.model.bidder.IxDiag @EqualsAndHashCode @ToString(includeNames = true, ignoreNulls = true) @@ -10,8 +12,10 @@ class BidRequestExt { Prebid prebid SupplyChain schain - AppNexus appnexus + @JsonProperty("appnexus") + AppNexus appNexus String bc String platform - IxDiag ixdiag + @JsonProperty("ixdiag") + IxDiag ixDiag } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy index 9c4a17ec5cf..dd2532e8d9e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy @@ -3,8 +3,11 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.ToString +import org.prebid.server.functional.model.bidder.Adrino +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.bidder.AppNexus import org.prebid.server.functional.model.bidder.Generic +import org.prebid.server.functional.model.bidder.Ix import org.prebid.server.functional.model.bidder.Openx import org.prebid.server.functional.model.bidder.Rubicon diff --git a/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy index 1e2c67fad6f..0dadfcb8dd1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy @@ -7,7 +7,7 @@ import org.prebid.server.functional.model.config.BidderConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredImp import org.prebid.server.functional.model.db.StoredResponse -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.PrebidStoredRequest @@ -18,6 +18,7 @@ import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import spock.lang.Shared @@ -37,7 +38,6 @@ import static org.prebid.server.functional.testcontainers.Dependencies.getNetwor class AlternateBidderCodeSpec extends BaseSpec { - private static final String ADAPTER_RESPONSE_VALIDATION_METRICS = "adapter.%s.response.validation.seat" private static final String ERROR_BID_CODE_VALIDATION = "BidId `%s` validation messages: " + "Error: invalid bidder code %s was set by the adapter %s for the account %s" private static final String INVALID_BIDDER_CODE_LOGS = "invalid bidder code %s was set by the adapter %s for the account %s" @@ -100,7 +100,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] + assert !metrics[Metrics.Adapter.seat(ALIAS)] } def "PBS should populate meta demand source when bid response with demand source"() { @@ -149,7 +149,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] } def "PBS shouldn't populate meta demand source when bid response without demand source"() { @@ -197,7 +197,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] } def "PBS shouldn't discard bid for amx bidder same seat in response as seat in bid.ext.bidderCode"() { @@ -245,7 +245,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: bidderCode << [AMX, AMX_CAMEL_CASE] @@ -296,7 +296,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[Metrics.Adapter.seat(AMX)] where: bidderName << [BOGUS, UNKNOWN, WILDCARD] @@ -351,7 +351,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] + assert metrics[Metrics.Adapter.seat(ALIAS)] where: bidderName << [BOGUS, UNKNOWN, WILDCARD] @@ -413,7 +413,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] + assert !metrics[Metrics.Adapter.seat(ALIAS)] where: requestAlternateBidderCode | accountAlternateBidderCodes @@ -470,7 +470,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(bidderCode)] + assert !metrics[Metrics.Adapter.seat(bidderCode)] where: bidderCode << [ALIAS, ALIAS_CAMEL_CASE] @@ -527,7 +527,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: accountAlternateBidderCodes << [null, @@ -595,7 +595,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: requestedAlternateBidderCodes << [null, @@ -695,7 +695,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] } def "PBS shouldn't discard bid when alternate bidder code allows bidder codes fully configured with different case"() { @@ -749,7 +749,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: configAccountAlternateBidderCodes << [ @@ -803,7 +803,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[Metrics.Adapter.seat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -859,7 +859,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[Metrics.Adapter.seat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -926,7 +926,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBs metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: accountAllowedBidderCodes << [[WILDCARD], [WILDCARD, EMPTY], [EMPTY, WILDCARD], null] @@ -979,7 +979,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBs metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: requestedAllowedBidderCodes << [[WILDCARD], [WILDCARD, EMPTY], [EMPTY, WILDCARD], null] @@ -1032,7 +1032,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBs metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: requestAlternateBidders << [[(AMX): new BidderConfig(enabled: true, allowedBidderCodes: [GENERIC])], @@ -1092,7 +1092,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBs metric shouldn't be updated" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: accountAlternateBidders << [[(AMX): new BidderConfig(enabled: true, allowedBidderCodes: [GENERIC])], @@ -1158,7 +1158,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Alert.general metric shouldn't be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(config) @@ -1203,7 +1203,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[Metrics.Adapter.seat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -1258,7 +1258,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[Metrics.Adapter.seat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -1322,7 +1322,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit metrics" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[Metrics.Adapter.seat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -1385,7 +1385,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1447,9 +1447,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(ALIAS)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: requestAlternateBidderCode | accountAlternateBidderCodes @@ -1513,9 +1513,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(ALIAS)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] + assert !metrics[Metrics.Adapter.seat(AMX)] where: requestAlternateBidderCode | accountAlternateBidderCodes @@ -1571,7 +1571,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1627,8 +1627,8 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[Metrics.Adapter.seat(AMX)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] } def "PBS should return two seat when same bidder response with different bidder code"() { @@ -1687,8 +1687,8 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[Metrics.Adapter.seat(AMX)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] } def "PBS should populate seat bid from stored bid response when stored bid response and alternate bidder code specified"() { @@ -1744,7 +1744,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(AMX)] } def "PBS auction allow bidder code when imp stored request and allowed bidder code present"() { @@ -1795,8 +1795,8 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[Metrics.Adapter.seat(GENERIC)] + assert !metrics[Metrics.Adapter.seat(AMX)] } private static Account getAccountWithAlternateBidderCode(BidRequest bidRequest) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy index e64090a1ebd..c366fcea6c9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy @@ -25,6 +25,7 @@ import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.HttpUtil +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import spock.lang.Shared @@ -54,8 +55,6 @@ class AuctionSpec extends BaseSpec { @Shared PrebidServerService prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) - private static final String IMPS_REQUESTED_METRIC = 'imps_requested' - private static final String IMPS_DROPPED_METRIC = 'imps_dropped' private static final Integer IMP_LIMIT = 1 private static final Map PBS_CONFIG = ["auction.biddertmax.max" : MAX_TIMEOUT as String, "auction.default-timeout-ms": DEFAULT_TIMEOUT as String] @@ -92,7 +91,7 @@ class AuctionSpec extends BaseSpec { and: "account..requests.rejected.invalid-account metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.rejected.invalid-account" as String] == 1 + assert metrics[Metrics.Account.rejectedInvalidAccount(accountId)] == 1 } def "PBS should update account..requests.rejected.#metricName metric when stored request is invalid"() { @@ -770,8 +769,8 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_DROPPED_METRIC] == bidRequest.imp.size() - IMP_LIMIT - assert metrics[IMPS_REQUESTED_METRIC] == IMP_LIMIT + assert metrics[Metrics.General.impsDropped()] == bidRequest.imp.size() - IMP_LIMIT + assert metrics[Metrics.General.impsRequested()] == IMP_LIMIT and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == IMP_LIMIT @@ -812,8 +811,8 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps requested should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_REQUESTED_METRIC] == bidRequest.imp.size() - assert !metrics[IMPS_DROPPED_METRIC] + assert metrics[Metrics.General.impsRequested()] == bidRequest.imp.size() + assert !metrics[Metrics.General.impsDropped()] and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == bidRequest.imp.size() @@ -849,8 +848,8 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps requested should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_REQUESTED_METRIC] == bidRequest.imp.size() - assert !metrics[IMPS_DROPPED_METRIC] + assert metrics[Metrics.General.impsRequested()] == bidRequest.imp.size() + assert !metrics[Metrics.General.impsDropped()] and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == bidRequest.imp.size() @@ -885,8 +884,8 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps requested should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_REQUESTED_METRIC] == bidRequest.imp.size() - assert !metrics[IMPS_DROPPED_METRIC] + assert metrics[Metrics.General.impsRequested()] == bidRequest.imp.size() + assert !metrics[Metrics.General.impsDropped()] and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == bidRequest.imp.size() diff --git a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy index 087c84880ab..d49c5591395 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy @@ -46,7 +46,6 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper { private static final int MIN_TIMEOUT = DEFAULT_TIMEOUT private static final int DEFAULT_TARGETING_PRECISION = 1 private static final String DEFAULT_CACHE_DIRECTORY = "/app/prebid-server/data" - protected static final String ALERT_GENERAL = "alerts.general" protected static final Map GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true", "adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()] protected static final Map EMPTY_CACHE_TTL_CONFIG = ["cache.default-ttl-seconds.banner": "", diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy index 7da1c89fffb..b1f4affa5da 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy @@ -9,7 +9,7 @@ import org.prebid.server.functional.model.config.BidderConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.AdjustmentRule import org.prebid.server.functional.model.request.auction.AdjustmentType -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.BidAdjustment import org.prebid.server.functional.model.request.auction.BidAdjustmentFactors import org.prebid.server.functional.model.request.auction.BidAdjustmentRule diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy index 9dd17c31e0a..f3f8a755998 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy @@ -12,6 +12,7 @@ import org.prebid.server.functional.model.response.auction.Bid import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature @@ -63,7 +64,7 @@ class BidValidationSpec extends BaseSpec { and: "Bid validation metric value is incremented" def metrics = strictPrebidService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: bidRequest << [BidRequest.getDefaultBidRequest(DistributionChannel.APP).tap { @@ -105,7 +106,7 @@ class BidValidationSpec extends BaseSpec { and: "Bid validation metric value is incremented" def metrics = softPrebidService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "PBS log should contain message" def logs = softPrebidService.getLogsByTime(startTime) @@ -376,7 +377,7 @@ class BidValidationSpec extends BaseSpec { then: "Bid validation metric value is incremented" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["adapter.generic.requests.bid_validation"] == 1 + assert metrics[Metrics.Adapter.bidValidation(GENERIC)] == 1 } def "PBS shouldn't throw error when two separate eids with same eids.source"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy index b47a2e47ddf..dc17f381286 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy @@ -18,6 +18,7 @@ import org.prebid.server.functional.model.request.auction.Video import org.prebid.server.functional.model.response.auction.Adm import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature import spock.lang.Shared @@ -191,8 +192,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.size.warn"] == 1 - assert metrics["adapter.generic.response.validation.size.warn"] == 1 + assert metrics[Metrics.Account.validationSizeWarn(bidRequest.accountId)] == 1 + assert metrics[Metrics.Adapter.validationSizeWarn(BidderName.GENERIC)] == 1 and: "Response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -255,8 +256,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.size.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] + assert !metrics[Metrics.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] and: "Response should contain error" assert !bidResponse.ext?.errors @@ -322,8 +323,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.size.err"] == 1 - assert metrics["adapter.generic.response.validation.size.err"] == 1 + assert metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] == 1 + assert metrics[Metrics.Adapter.validationSizeError(BidderName.GENERIC)] == 1 and: "Response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -382,8 +383,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.size.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] + assert !metrics[Metrics.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] and: "Response should contain error" assert !bidResponse.ext?.errors @@ -438,8 +439,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] - assert !metrics["adapter.generic.response.validation.size.err"] + assert !metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeError(BidderName.GENERIC)] and: "Response shouldn't contain error" assert !bidResponse.ext?.errors @@ -509,8 +510,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.size.err"] == 1 - assert metrics["adapter.generic.response.validation.size.err"] == 1 + assert metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] == 1 + assert metrics[Metrics.Adapter.validationSizeError(BidderName.GENERIC)] == 1 and: "Bid response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -567,10 +568,10 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't be increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + assert !metrics[Metrics.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response should contain error" assert !bidResponse.ext?.errors @@ -622,8 +623,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] == 1 - assert metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] == 1 + assert metrics[Metrics.Account.validationSecureWarn(bidRequest.accountId)] == 1 + assert metrics[Metrics.Adapter.validationSecureWarn(BidderName.GENERIC)] == 1 and: "Bid response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -675,10 +676,10 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + assert !metrics[Metrics.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response shouldn't contain error" assert !bidResponse.ext?.errors @@ -730,8 +731,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.secure.err"] == 1 - assert metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] == 1 + assert metrics[Metrics.Account.validationSecureError(bidRequest.accountId)] == 1 + assert metrics[Metrics.Adapter.validationSecureError(BidderName.GENERIC)] == 1 and: "Bid response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -783,10 +784,10 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + assert !metrics[Metrics.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response shouldn't contain error" assert !bidResponse.ext?.errors @@ -836,8 +837,10 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] + assert !metrics[Metrics.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[Metrics.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[Metrics.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response shouldn't contain error" assert !bidResponse.ext?.errors diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy index 81b2dc5d46e..5051f1f382e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy @@ -7,8 +7,8 @@ import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredImp import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest -import org.prebid.server.functional.model.request.auction.Adrino -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Adrino +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.AuctionEnvironment import org.prebid.server.functional.model.request.auction.Banner import org.prebid.server.functional.model.request.auction.BidRequest diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy index f1ea6de084c..bdebcbed29f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy @@ -10,6 +10,7 @@ import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.Targeting import org.prebid.server.functional.model.response.auction.Adm import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.response.auction.ErrorType.CACHE @@ -25,19 +26,6 @@ class CacheSpec extends BaseSpec { private static final Integer MAX_DATACENTER_REGION_LENGTH = 4 private static final Integer DEFAULT_UUID_LENGTH = 36 - private static final String ACCOUNT_JSON_CREATIVE_SIZE_METRIC = "account.%s.prebid_cache.creative_size.json" - private static final String ACCOUNT_XML_CREATIVE_SIZE_METRIC = "account.%s.prebid_cache.creative_size.xml" - private static final String ACCOUNT_XML_CREATIVE_TTL_METRIC = "account.%s.prebid_cache.creative_ttl.xml" - private static final String ACCOUNT_JSON_CREATIVE_TTL_METRIC = "account.%s.prebid_cache.creative_ttl.json" - - private static final String ACCOUNT_REQUEST_OK_METRIC = "account.%s.prebid_cache.requests.ok" - private static final String REQUEST_OK_METRIC = "prebid_cache.requests.ok" - - private static final String JSON_CREATIVE_SIZE_GLOBAL_METRIC = "prebid_cache.creative_size.json" - private static final String XML_CREATIVE_SIZE_GLOBAL_METRIC = "prebid_cache.creative_size.xml" - private static final String XML_CREATIVE_TTL_METRIC = "prebid_cache.creative_ttl.xml" - private static final String JSON_CREATIVE_TTL_METRIC = "prebid_cache.creative_ttl.json" - private static final String CACHE_PATH = "/${PBSUtils.randomString}".toString() private static final String CACHE_HOST = "${PBSUtils.randomString}:${PBSUtils.getRandomNumber(0, 65535)}".toString() private static final String INTERNAL_CACHE_PATH = '/cache' @@ -46,7 +34,7 @@ class CacheSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.json metric when json creative is received"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, REQUEST_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.requestsOk()) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -71,17 +59,17 @@ class CacheSpec extends BaseSpec { and: "prebid_cache.creative_size.json metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[REQUEST_OK_METRIC] == initialValue + 1 - assert metrics[JSON_CREATIVE_SIZE_GLOBAL_METRIC] == creativeSize + assert metrics[Metrics.Cache.requestsOk()] == initialValue + 1 + assert metrics[Metrics.Cache.creativeSizeJson()] == creativeSize and: "account..prebid_cache.creative_size.json should be update" - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 - assert metrics[ACCOUNT_JSON_CREATIVE_SIZE_METRIC.formatted(bidRequest.accountId)] == creativeSize + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.accountCreativeSizeJson(bidRequest.accountId)] == creativeSize } def "PBS should update prebid_cache.creative_size.xml metric when video bid and xml creative is received"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, REQUEST_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.requestsOk()) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.defaultVideoRequest.tap { @@ -107,12 +95,12 @@ class CacheSpec extends BaseSpec { and: "prebid_cache.creative_size.json metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[REQUEST_OK_METRIC] == initialValue + 1 - assert metrics[XML_CREATIVE_SIZE_GLOBAL_METRIC] == creativeSize + assert metrics[Metrics.Cache.requestsOk()] == initialValue + 1 + assert metrics[Metrics.Cache.creativeSizeXml()] == creativeSize and: "account..prebid_cache.creative_size.json should be update" - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 - assert metrics[ACCOUNT_XML_CREATIVE_SIZE_METRIC.formatted(bidRequest.accountId)] == creativeSize + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.accountCreativeSizeXml(bidRequest.accountId)] == creativeSize } def "PBS should cache bids when targeting is specified"() { @@ -214,8 +202,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -256,13 +244,13 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for account" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == videoHostTtl - assert metrics[ACCOUNT_XML_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == videoHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.accountCreativeTtlJson(bidRequest.accountId)] == videoHostTtl + assert metrics[Metrics.Cache.accountCreativeTtlXml(bidRequest.accountId)] == videoHostTtl + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 and: "PBS should include metrics prebid_cache_creative.{xml,json}.creative.ttl for general" - assert metrics[JSON_CREATIVE_TTL_METRIC] == videoHostTtl - assert metrics[XML_CREATIVE_TTL_METRIC] == videoHostTtl + assert metrics[Metrics.Cache.creativeTtlXml()] == videoHostTtl + assert metrics[Metrics.Cache.creativeTtlJson()] == videoHostTtl cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -298,8 +286,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -334,8 +322,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -368,8 +356,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -627,7 +615,7 @@ class CacheSpec extends BaseSpec { def "PBS should cache bids and add targeting values when account cache config #accountAuctionConfig"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, REQUEST_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.requestsOk()) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.getDefaultVideoRequest().tap { @@ -661,8 +649,8 @@ class CacheSpec extends BaseSpec { and: "Metrics should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[REQUEST_OK_METRIC] == initialValue + 1 - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[Metrics.Cache.requestsOk()] == initialValue + 1 + assert metrics[Metrics.Cache.accountRequestsOk(bidRequest.accountId)] == 1 where: accountAuctionConfig << [ diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy index e5637fe80e2..fbd968b950c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy @@ -11,6 +11,7 @@ import org.prebid.server.functional.model.request.vtrack.xml.Vast import org.prebid.server.functional.model.response.vtrack.TransferValue import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST @@ -19,18 +20,6 @@ import static org.prebid.server.functional.testcontainers.Dependencies.getNetwor class CacheVtrackSpec extends BaseSpec { - private static final String ACCOUNT_VTRACK_XML_CREATIVE_SIZE_METRIC = "account.%s.prebid_cache.vtrack.creative_size.xml" - private static final String ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC = "account.%s.prebid_cache.vtrack.creative_ttl.xml" - private static final String ACCOUNT_VTRACK_WRITE_ERR_METRIC = "account.%s.prebid_cache.vtrack.write.err" - private static final String ACCOUNT_VTRACK_WRITE_OK_METRIC = "account.%s.prebid_cache.vtrack.write.ok" - - private static final String VTRACK_XML_CREATIVE_SIZE_METRIC = "prebid_cache.vtrack.creative_size.xml" - private static final String VTRACK_XML_CREATIVE_TTL_METRIC = "prebid_cache.vtrack.creative_ttl.xml" - private static final String VTRACK_WRITE_OK_METRIC = "prebid_cache.vtrack.write.ok" - private static final String VTRACK_WRITE_ERROR_METRIC = "prebid_cache.vtrack.write.err" - private static final String VTRACK_READ_OK_METRIC = "prebid_cache.vtrack.read.ok" - private static final String VTRACK_READ_ERROR_METRIC = "prebid_cache.vtrack.read.err" - private static final String CACHE_ENDPOINT = "/cache" private static final String CACHE_PATH = "/${PBSUtils.randomString}".toString() private static final String CACHE_HOST = "${PBSUtils.randomString}:${PBSUtils.getRandomNumber(0, 65535)}".toString() @@ -58,7 +47,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.xml metric and adding tracking xml when xml creative contain #wrapper and impression are valid xml value"() { given: "Current value of metric prebid_cache.vtrack.write.ok" - def initialOkVTrackValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_OK_METRIC) + def initialOkVTrackValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.vtrackWriteOk()) and: "Create and save enabled events config in account" def accountId = PBSUtils.randomNumber.toString() @@ -94,12 +83,12 @@ class CacheVtrackSpec extends BaseSpec { and: "prebid_cache.creative_size.xml metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() def ttlSeconds = request.puts[0].ttlseconds - assert metrics[VTRACK_WRITE_OK_METRIC] == initialOkVTrackValue + 1 - assert metrics[VTRACK_XML_CREATIVE_TTL_METRIC] == ttlSeconds + assert metrics[Metrics.Cache.vtrackWriteOk()] == initialOkVTrackValue + 1 + assert metrics[Metrics.Cache.vtrackCreativeTtlXml()] == ttlSeconds and: "account..prebid_cache.vtrack.creative_size.xml should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_OK_METRIC.formatted(accountId) as String] == 1 - assert metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId) as String] == ttlSeconds + assert metrics[Metrics.Account.cacheVtrackWriteOk(accountId)] == 1 + assert metrics[Metrics.Account.cacheVtrackCreativeTtlXml(accountId)] == ttlSeconds where: wrapper | impression @@ -113,7 +102,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.xml metric when xml creative is received"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.vtrackWriteOk()) and: "Cache set up response" prebidCache.setResponse() @@ -132,11 +121,11 @@ class CacheVtrackSpec extends BaseSpec { then: "prebid_cache.vtrack.creative_size.xml metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() def creativeSize = creative.bytes.length - assert metrics[VTRACK_WRITE_OK_METRIC] == initialValue + 1 + assert metrics[Metrics.Cache.vtrackWriteOk()] == initialValue + 1 and: "account..prebid_cache.creative_size.xml should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_OK_METRIC.formatted(accountId)] == 1 - assert metrics[ACCOUNT_VTRACK_XML_CREATIVE_SIZE_METRIC.formatted(accountId)] == creativeSize + assert metrics[Metrics.Account.cacheVtrackWriteOk(accountId)] == 1 + assert metrics[Metrics.Account.cacheVtrackCreativeSizeXml(accountId)] == creativeSize } def "PBS should failed VTrack request when sending request without account"() { @@ -184,7 +173,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Pbs should emit creative_ttl.xml with lowest value" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId)] + assert metrics[Metrics.Account.cacheVtrackCreativeTtlXml(accountId)] == [requestedTtl, accountTtl].findAll { it -> it > 0 }.min() where: requestedTtl | accountTtl @@ -221,7 +210,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Pbs should emit creative_ttl.xml with lowest value" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId)] == [requestedTtl, accountTtl].min() + assert metrics[Metrics.Account.cacheVtrackCreativeTtlXml(accountId)] == [requestedTtl, accountTtl].min() where: requestedTtl | accountTtl @@ -259,7 +248,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Pbs shouldn't emit creative_ttl.xml" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId)] + assert !metrics[Metrics.Account.cacheVtrackCreativeTtlXml(accountId)] } def "PBS should return 400 status code when get vtrack request without uuid"() { @@ -285,7 +274,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Metrics should contain ok metric" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == 1 + assert metricsRequest[Metrics.Cache.vtrackReadOk()] == 1 } def "PBS should return status code that came from pbc when get vtrack request and response from pbc invalid"() { @@ -306,12 +295,12 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain error metric" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_ERROR_METRIC] == 1 + assert metricsRequest[Metrics.Cache.vtrackReadErr()] == 1 } def "PBS should return 200 status code and body when get vtrack request with uuid and ch"() { given: "Current value of metric prebid_cache.vtrack.read.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, VTRACK_READ_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.vtrackReadOk()) and: "Random uuid and cache host" def uuid = UUID.randomUUID().toString() @@ -329,12 +318,12 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain ok metrics" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == initialValue + 1 + assert metricsRequest[Metrics.Cache.vtrackReadOk()] == initialValue + 1 } def "PBS should return 200 status code and body when internal cache configured and get vtrack request with uuid and ch"() { given: "Current value of metric prebid_cache.vtrack.read.ok" - def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, VTRACK_READ_OK_METRIC) + def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, Metrics.Cache.vtrackReadOk()) and: "Flush metric" flushMetrics(pbsServiceWithInternalCache) @@ -355,7 +344,7 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain ok metrics" def metricsRequest = pbsServiceWithInternalCache.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == initialValue + 1 + assert metricsRequest[Metrics.Cache.vtrackReadOk()] == initialValue + 1 and: "Verify parameters that came to external cache services" def requestParams = prebidCache.getVTracGetRequestParams() @@ -364,7 +353,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should return 200 status code when internal cache and get vtrack request contain uuid"() { given: "Current value of metric prebid_cache.vtrack.read.ok" - def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, VTRACK_READ_OK_METRIC) + def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, Metrics.Cache.vtrackReadOk()) and: "Random uuid" def uuid = UUID.randomUUID().toString() @@ -384,7 +373,7 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain ok metrics" def metricsRequest = pbsServiceWithInternalCache.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == initialValue + 1 + assert metricsRequest[Metrics.Cache.vtrackReadOk()] == initialValue + 1 and: "Verify parameters that came to external cache services" def requestParams = prebidCache.getVTracGetRequestParams() @@ -412,7 +401,7 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain error metric" def metricsRequest = pbsServiceWithInternalCache.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_ERROR_METRIC] == 1 + assert metricsRequest[Metrics.Cache.vtrackReadErr()] == 1 and: "Verify parameters that came to external cache services" def requestParams = prebidCache.getVTracGetRequestParams() @@ -431,7 +420,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.xml metric when account cache config #enabledCacheConcfig"() { given: "Current value of metric prebid_cache.requests.ok" - def okInitialValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_OK_METRIC) + def okInitialValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.vtrackWriteOk()) and: "Default VtrackRequest" def accountId = PBSUtils.randomNumber.toString() @@ -459,11 +448,11 @@ class CacheVtrackSpec extends BaseSpec { then: "prebid_cache.creative_size.xml metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() def creativeSize = creative.bytes.length - assert metrics[VTRACK_WRITE_OK_METRIC] == okInitialValue + 1 + assert metrics[Metrics.Cache.vtrackWriteOk()] == okInitialValue + 1 and: "account..prebid_cache.creative_size.xml should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_OK_METRIC.formatted(accountId)] == 1 - assert metrics[ACCOUNT_VTRACK_XML_CREATIVE_SIZE_METRIC.formatted(accountId)] == creativeSize + assert metrics[Metrics.Account.cacheVtrackWriteOk(accountId)] == 1 + assert metrics[Metrics.Account.cacheVtrackCreativeSizeXml(accountId)] == creativeSize where: enabledCacheConcfig << [null, false, true] @@ -471,7 +460,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should failed cache and update prebid_cache.vtrack.write.err metric when cache service respond with invalid status code"() { given: "Current value of metric prebid_cache.requests.ok" - def okInitialValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_ERROR_METRIC) + def okInitialValue = getCurrentMetricValue(defaultPbsService, Metrics.Cache.vtrackWriteErr()) and: "Default VtrackRequest" def accountId = PBSUtils.randomNumber.toString() @@ -503,9 +492,9 @@ class CacheVtrackSpec extends BaseSpec { then: "prebid_cache.vtrack.write.err metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[VTRACK_WRITE_ERROR_METRIC] == okInitialValue + 1 + assert metrics[Metrics.Cache.vtrackWriteErr()] == okInitialValue + 1 and: "account..prebid_cache.vtrack.write.err should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_ERR_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.cacheVtrackWriteErr(accountId)] == 1 } } 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 b7fce18dda6..5f1fee021c1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy @@ -19,6 +19,7 @@ import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.HttpUtil +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent @@ -367,7 +368,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.FAMILY.tcf.blocked" def metric = this.prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.tcf.blocked"] == 1 + assert metric[Metrics.CookieSync.tcfBlocked(GENERIC)] == 1 } def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder with ccpa"() { @@ -419,7 +420,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.generic.filtered" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.filtered"] == 1 + assert metric[Metrics.CookieSync.filtered(GENERIC)] == 1 } def "PBS cookie sync request should reflect error even when response is full by account cookie sync config limit"() { @@ -1423,7 +1424,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.FAMILY.filtered" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.filtered"] == 1 + assert metric[Metrics.CookieSync.filtered(GENERIC)] == 1 } def "PBS cookie sync with gdpr should reject bidder sync"() { @@ -1448,7 +1449,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.FAMILY.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.tcf.blocked"] == 1 + assert metric[Metrics.CookieSync.tcfBlocked(GENERIC)] == 1 } def "PBS cookie sync with ccpa should reject bidder sync"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy index 22dd16b2b9a..264730b13d1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests import org.apache.commons.lang3.StringUtils +import org.prebid.server.functional.model.ChannelType import org.prebid.server.functional.model.config.AccountAuctionConfig import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountMetricsConfig @@ -15,6 +16,7 @@ import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature @@ -30,9 +32,6 @@ class DebugSpec extends BaseSpec { private static final String overrideToken = PBSUtils.randomString private static final String ACCOUNT_METRICS_PREFIX_NAME = "account" - private static final String DEBUG_REQUESTS_METRIC = "debug_requests" - private static final String ACCOUNT_DEBUG_REQUESTS_METRIC = "account.%s.debug_requests" - private static final String REQUEST_OK_WEB_METRICS = "requests.ok.openrtb2-web" private static final PrebidServerService enabledDebugPbsService = pbsServiceFactory.getService("adapters.generic.debug.allow": "true") private static final PrebidServerService disabledDebugPbsService = pbsServiceFactory.getService("adapters.generic.debug.allow": "false") @@ -59,7 +58,7 @@ class DebugSpec extends BaseSpec { and: "Debug metrics should be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[Metrics.General.debugRequests()] == 1 and: "Account debug metrics shouldn't be incremented" assert !metricsRequest.keySet().contains(ACCOUNT_METRICS_PREFIX_NAME) @@ -88,11 +87,11 @@ class DebugSpec extends BaseSpec { and: "Debug metrics shouldn't be populated" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[DEBUG_REQUESTS_METRIC] + assert !metricsRequest[Metrics.General.debugRequests()] assert !metricsRequest.keySet().contains(ACCOUNT_METRICS_PREFIX_NAME) and: "General metrics should be present" - assert metricsRequest[REQUEST_OK_WEB_METRICS] == 1 + assert metricsRequest[Metrics.General.requestOk(ChannelType.WEB)] == 1 where: debug | test @@ -402,8 +401,8 @@ class DebugSpec extends BaseSpec { and: "Debug metrics should be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(bidRequest.accountId)] == 1 - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[Metrics.General.debugRequests().formatted(bidRequest.accountId)] == 1 + assert metricsRequest[Metrics.General.debugRequests()] == 1 } def "PBS shouldn't return debug information and emit metrics when account debug enabled and verbosity #verbosityLevel"() { @@ -428,10 +427,10 @@ class DebugSpec extends BaseSpec { and: "Account debug metrics shouldn't be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(bidRequest.accountId)] + assert !metricsRequest[Metrics.Account.debugRequests(bidRequest.accountId)] and: "Request debug metrics should be incremented" - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[Metrics.General.debugRequests()] == 1 where: verbosityLevel << [NONE, BASIC] @@ -466,8 +465,8 @@ class DebugSpec extends BaseSpec { and: "Debug metrics should be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(ampRequest.account)] == 1 - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[Metrics.General.debugRequests().formatted(ampRequest.account)] == 1 + assert metricsRequest[Metrics.General.debugRequests()] == 1 } def "PBS amp should return debug information and emit metrics when account debug enabled and verbosity #verbosityLevel"() { @@ -499,10 +498,10 @@ class DebugSpec extends BaseSpec { and: "Account debug metrics shouldn't be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(ampRequest.account)] + assert !metricsRequest[Metrics.Account.debugRequests(ampRequest.account)] and: "Debug metrics should be incremented" - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[Metrics.General.debugRequests()] == 1 where: verbosityLevel << [NONE, BASIC] @@ -526,10 +525,10 @@ class DebugSpec extends BaseSpec { and: "Debug metrics shouldn't be populated" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[DEBUG_REQUESTS_METRIC] + assert !metricsRequest[Metrics.General.debugRequests()] assert !metricsRequest.keySet().contains(ACCOUNT_METRICS_PREFIX_NAME) and: "General metrics shouldn't be present" - assert !metricsRequest[REQUEST_OK_WEB_METRICS] + assert !metricsRequest[Metrics.General.requestOk(ChannelType.WEB)] } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy index 808d16ccb04..a9d9de37a25 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy @@ -7,6 +7,7 @@ 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.Device import org.prebid.server.functional.model.request.auction.Geo +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -24,9 +25,6 @@ import static org.prebid.server.functional.util.privacy.model.State.QUEBEC class GeoSpec extends BaseSpec { // TODO refactor containers for this spec - private static final String GEO_LOCATION_REQUESTS = "geolocation_requests" - private static final String GEO_LOCATION_FAIL = "geolocation_fail" - private static final String GEO_LOCATION_SUCCESSFUL = "geolocation_successful" private static final Map GEO_LOCATION = ["geolocation.type" : "configuration", "geolocation.configurations.[0].address-pattern" : USA_IP.v4, "geolocation.configurations.[0].geo-info.country": USA.ISOAlpha2, @@ -77,9 +75,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 - assert !metrics[GEO_LOCATION_FAIL] + assert metrics[Metrics.General.geolocationRequests()] == 1 + assert metrics[Metrics.General.geolocationSuccessful()] == 1 + assert !metrics[Metrics.General.geolocationFail()] where: settingDefaultAccountGeoLookup | settingAccountDefaultAccountGeoLookup @@ -132,9 +130,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 - assert !metrics[GEO_LOCATION_FAIL] + assert metrics[Metrics.General.geolocationRequests()] == 1 + assert metrics[Metrics.General.geolocationSuccessful()] == 1 + assert !metrics[Metrics.General.geolocationFail()] where: defaultAccountGeoLookup | accountGeoLookup @@ -185,9 +183,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 - assert !metrics[GEO_LOCATION_FAIL] + assert metrics[Metrics.General.geolocationRequests()] == 1 + assert metrics[Metrics.General.geolocationSuccessful()] == 1 + assert !metrics[Metrics.General.geolocationFail()] where: defaultAccountGeoLookup | accountGeoLookup @@ -238,9 +236,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[Metrics.General.geolocationRequests()] + assert !metrics[Metrics.General.geolocationSuccessful()] + assert !metrics[Metrics.General.geolocationFail()] where: defaultAccountGeoLookupConfig | hostGeolocation | accountGeoLookup @@ -292,9 +290,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[Metrics.General.geolocationRequests()] + assert !metrics[Metrics.General.geolocationSuccessful()] + assert !metrics[Metrics.General.geolocationFail()] where: defaultAccountGeoLookupConfig | hostGeolocation | accountGeoLookup @@ -346,9 +344,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_FAIL] == 1 - assert !metrics[GEO_LOCATION_SUCCESSFUL] + assert metrics[Metrics.General.geolocationRequests()] == 1 + assert metrics[Metrics.General.geolocationFail()] == 1 + assert !metrics[Metrics.General.geolocationSuccessful()] and: "PBs should emit geo failed logs" def logs = defaultPbsService.getLogsByTime(startTime) @@ -400,9 +398,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_FAIL] == 1 - assert !metrics[GEO_LOCATION_SUCCESSFUL] + assert metrics[Metrics.General.geolocationRequests()] == 1 + assert metrics[Metrics.General.geolocationFail()] == 1 + assert !metrics[Metrics.General.geolocationSuccessful()] and: "PBs should emit geo failed logs" def logs = defaultPbsService.getLogsByTime(startTime) @@ -450,9 +448,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[Metrics.General.geolocationRequests()] + assert !metrics[Metrics.General.geolocationSuccessful()] + assert !metrics[Metrics.General.geolocationFail()] } def "PBS shouldn't populate country and region via geo when geo enabled in account and country and region specified in request and ip present in header"() { @@ -493,8 +491,8 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[Metrics.General.geolocationRequests()] + assert !metrics[Metrics.General.geolocationSuccessful()] + assert !metrics[Metrics.General.geolocationFail()] } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy index 7225bd170de..254268456ff 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy @@ -1,14 +1,16 @@ package org.prebid.server.functional.tests +import org.prebid.server.functional.model.ChannelType +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountMetricsConfig -import org.prebid.server.functional.model.config.ModuleName 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.Dooh import org.prebid.server.functional.model.request.auction.Site import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.BASIC import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.DETAILED @@ -65,7 +67,7 @@ class MetricsSpec extends BaseSpec { and: "account..generic and requests.type.openrtb2-web metrics shouldn't populated" assert !metrics.findAll({ it.key.startsWith("account.${accountId}.generic") }) - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] + assert !metrics[Metrics.Account.requestType(accountId, ChannelType.WEB)] where: accountMetricsConfig << [new AccountConfig(metrics: new AccountMetricsConfig(verbosityLevel: BASIC)), @@ -94,12 +96,12 @@ class MetricsSpec extends BaseSpec { then: "account..* should be populated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.adapter.generic.bids_received" as String] == 1 - assert metrics["account.${accountId}.adapter.generic.prices" as String] == bidPrice - assert metrics["account.${accountId}.adapter.generic.request_time" as String] == 1 - assert metrics["account.${accountId}.adapter.generic.requests.gotbids" as String] == 1 - assert metrics["account.${accountId}.requests" as String] == 1 - assert metrics["account.${accountId}.requests.type.openrtb2-web" as String] == 1 + assert metrics[Metrics.Account.bidsReceived(accountId, BidderName.GENERIC)] == 1 + assert metrics[Metrics.Account.prices(accountId, BidderName.GENERIC)] == bidPrice + assert metrics[Metrics.Account.requestTime(accountId, BidderName.GENERIC)] == 1 + assert metrics[Metrics.Account.requestsGotBids(accountId, BidderName.GENERIC)] == 1 + assert metrics[Metrics.Account.requests(accountId)] == 1 + assert metrics[Metrics.Account.requestType(accountId, ChannelType.WEB)] == 1 } def "PBS should update hood metrics when bid request contains hood channel type and verbosity level is detailed"() { @@ -117,12 +119,12 @@ class MetricsSpec extends BaseSpec { then: "account..* should be populated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] == 1 - assert metrics["adapter.generic.requests.type.openrtb2-dooh" as String] == 1 + assert metrics[Metrics.Account.requestType(accountId, ChannelType.DOOH)] == 1 + assert metrics[Metrics.Adapter.requestType(BidderName.GENERIC, ChannelType.DOOH)] == 1 and: "ather channel types should not be populated" - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] - assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] + assert !metrics[Metrics.Account.requestType(accountId, ChannelType.WEB)] + assert !metrics[Metrics.Account.requestType(accountId, ChannelType.APP)] } def "PBS with soft setup should ignore site distribution channel and update only dooh metrics when presented dooh and site in request"() { @@ -147,15 +149,15 @@ class MetricsSpec extends BaseSpec { and: "Metrics processed across site should be updated" def metrics = softPrebidService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] == 1 - assert metrics["adapter.generic.requests.type.openrtb2-dooh" as String] == 1 + assert metrics[Metrics.Account.requestType(accountId, ChannelType.DOOH)] == 1 + assert metrics[Metrics.Adapter.requestType(BidderName.GENERIC, ChannelType.DOOH)] == 1 and: "alert.general metric should be updated" - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Other channel types should not be populated" - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] - assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] + assert !metrics[Metrics.Account.requestType(accountId, ChannelType.WEB)] + assert !metrics[Metrics.Account.requestType(accountId, ChannelType.APP)] } def "PBS with soft setup should ignore other distribution channel and update only app metrics when presented app ant other channels in request"() { @@ -176,15 +178,15 @@ class MetricsSpec extends BaseSpec { and: "Metrics processed across site should be updated" def metrics = softPrebidService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.type.openrtb2-app" as String] == 1 - assert metrics["adapter.generic.requests.type.openrtb2-app" as String] == 1 + assert metrics[Metrics.Account.requestType(accountId, ChannelType.APP)] == 1 + assert metrics[Metrics.Adapter.requestType(BidderName.GENERIC, ChannelType.APP)] == 1 and: "alert.general metric should be updated" - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Other channel types should not be populated" - assert !metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] + assert !metrics[Metrics.Account.requestType(accountId, ChannelType.DOOH)] + assert !metrics[Metrics.Account.requestType(accountId, ChannelType.WEB)] where: bidRequest << [BidRequest.getDefaultBidRequest(APP).tap { diff --git a/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy index c6d600d518c..a5f18a53f07 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy @@ -33,6 +33,7 @@ import org.prebid.server.functional.repository.dao.ProfileRequestDao import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.container.PrebidServerContainer +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.testcontainers.images.builder.Transferable import spock.lang.PendingFeature @@ -76,9 +77,6 @@ class ProfileSpec extends BaseSpec { private static final String NO_REQUEST_PROFILE_MESSAGE = "No request profiles for ids [%s] were found" private static final String NO_PROFILE_MESSAGE = "No profile found for id: %s" - private static final String LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC = "account.%s.profiles.limit_exceeded" - private static final String MISSING_ACCOUNT_PROFILE_METRIC = "account.%s.profiles.missing" - private static final ProfileImpDao profileImpDao = repository.profileImpDao private static final ProfileRequestDao profileRequestDao = repository.profileRequestDao @@ -645,7 +643,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesLimitExceeded(accountId)] == 1 and: "Bidder request should contain data from profile" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -733,7 +731,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric shouldn't increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert !metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] + assert !metrics[Metrics.Account.profilesLimitExceeded(accountId)] and: "Bidder request should contain data from profiles" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -815,7 +813,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesLimitExceeded(accountId)] == 1 and: "Bidder request should contain data from original request" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -995,7 +993,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesMissing(accountId)] == 1 where: profilesConfigs << [ @@ -1201,7 +1199,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesLimitExceeded(accountId)] == 1 and: "Bidder request should contain data from original request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { @@ -1242,7 +1240,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" verifyAll(bidder.getBidderRequest(bidRequest.id)) { @@ -1296,7 +1294,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" verifyAll(bidder.getBidderRequest(bidRequest.id)) { @@ -1345,7 +1343,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesMissing(accountId)] == 1 and: "Bidder request imp should contain data from original imp" assert bidder.getBidderRequest(bidRequest.id).imp.banner == bidRequest.imp.banner @@ -1377,7 +1375,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" verifyAll(bidder.getBidderRequest(bidRequest.id)) { @@ -1425,7 +1423,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesMissing(accountId)] == 1 and: "Bidder request imp should contain data from original imp" assert bidder.getBidderRequest(bidRequest.id).imp.banner == bidRequest.imp.banner @@ -1465,7 +1463,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[Metrics.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" verifyAll(bidder.getBidderRequest(bidRequest.id)) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy index 7e9eff9ebd3..ee1e408f805 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy @@ -6,6 +6,7 @@ import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.model.response.setuid.SetuidResponse import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.util.ResourceUtil @@ -95,7 +96,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.sets metric should be updated" def metrics = singleCookiesPbsService.sendCollectedMetricsRequest() - assert metrics["usersync.${GENERIC.value}.sets"] == 1 + assert metrics[Metrics.UserSync.sets(GENERIC)] == 1 } def "PBS setuid should remove expired uids cookie"() { @@ -215,7 +216,7 @@ class SetUidSpec extends BaseSpec { then: "usersync.FAMILY.sizeblocked metric should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics["usersync.${bidderName.value}.sizeblocked"] == 1 + assert metrics[Metrics.UserSync.sizeBlocked(bidderName)] == 1 and: "Response should contain uids cookies" assert response.uidsCookie.tempUIDs[APPNEXUS] @@ -252,7 +253,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.tcf.blocked metric should be updated" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${RUBICON.value}.tcf.blocked"] == 1 + assert metric[Metrics.UserSync.tcfBlocked(RUBICON)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -281,7 +282,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.sizeblocked metric should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics["usersync.${RUBICON.value}.sizeblocked"] == 1 + assert metrics[Metrics.UserSync.sizeBlocked(RUBICON)] == 1 then: "Response should contain uids cookies" assert response.uidsCookie.tempUIDs[APPNEXUS] @@ -325,10 +326,10 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.sizeblocked metric should be updated" def metricsRequest = prebidServerService.sendCollectedMetricsRequest() - assert metricsRequest["usersync.${APPNEXUS.value}.sizeblocked"] == 1 + assert metricsRequest[Metrics.UserSync.sizeBlocked(APPNEXUS)] == 1 and: "usersync.FAMILY.sets metric should be updated" - assert metricsRequest["usersync.${OPENX.value}.sets"] == 1 + assert metricsRequest[Metrics.UserSync.sets(OPENX)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -364,7 +365,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.sizedout metric should be updated" def metricsRequest = prebidServerService.sendCollectedMetricsRequest() - assert metricsRequest["usersync.${APPNEXUS.value}.sizedout"] == 1 + assert metricsRequest[Metrics.UserSync.sizedOut(APPNEXUS)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy index cd4545ec6b0..e524747223f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy @@ -8,6 +8,7 @@ import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.request.auction.Source import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP @@ -53,7 +54,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[Metrics.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -144,7 +145,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[Metrics.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -210,7 +211,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[Metrics.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -296,7 +297,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = storedRequestIdGenEnabledService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[Metrics.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/bidder/openx/OpenxSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/bidder/openx/OpenxSpec.groovy index 97a0015cea5..d205bfbd427 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/bidder/openx/OpenxSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/bidder/openx/OpenxSpec.groovy @@ -18,6 +18,7 @@ import org.prebid.server.functional.model.response.auction.OpenxBidResponseExt import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.BaseSpec +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import spock.lang.Shared @@ -444,7 +445,7 @@ class OpenxSpec extends BaseSpec { and: "Alert.general metric should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS shouldn't populate fledge or igi config when bidder respond with igb"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index 1b3b4407b0b..a95612ffc7b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -13,13 +13,11 @@ import org.prebid.server.functional.model.response.auction.AnalyticResult import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.config.ModuleName.PB_RESPONSE_CORRECTION import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION -import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_BIDDER_REQUEST -import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_RAW_BIDDER_RESPONSE -import static org.prebid.server.functional.model.config.ModuleHookImplementation.RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES import static org.prebid.server.functional.model.config.Stage.ALL_PROCESSED_BID_RESPONSES import static org.prebid.server.functional.model.config.Stage.BIDDER_REQUEST import static org.prebid.server.functional.model.config.Stage.RAW_BIDDER_RESPONSE @@ -33,10 +31,6 @@ import static org.prebid.server.functional.model.response.auction.ResponseAction class AbTestingModuleSpec extends ModuleBaseSpec { - private final static String NOOP_METRIC = "modules.module.%s.stage.%s.hook.%s.success.noop" - private final static String NO_INVOCATION_METRIC = "modules.module.%s.stage.%s.hook.%s.success.no-invocation" - private final static String CALL_METRIC = "modules.module.%s.stage.%s.hook.%s.call" - private final static String EXECUTION_ERROR_METRIC = "modules.module.%s.stage.%s.hook.%s.execution-error" private final static Integer MIN_PERCENT_AB = 0 private final static Integer MAX_PERCENT_AB = 100 private final static String INVALID_HOOK_MESSAGE = "Hook implementation does not exist or disabled" @@ -88,14 +82,14 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noop(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] } def "PBS shouldn't apply valid a/b test config when module is disabled"() { @@ -131,13 +125,13 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be with error call" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[EXECUTION_ERROR_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[EXECUTION_ERROR_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.executionError(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.executionError(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -173,14 +167,14 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noop(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: moduleName << [ModuleName.ORTB2_BLOCKING.code.toUpperCase(), PBSUtils.randomString] @@ -235,15 +229,15 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for allowed to run ortb2blocking module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "Metric for allowed to run response-correction module should be updated based on ab test config" - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[Metrics.Module.noop(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] } def "PBS should apply a/b test config for each module when multiple config are presents and set to skip modules"() { @@ -295,12 +289,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for skipped ortb2blocking module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 + assert !metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "Metric for skipped response-correction module should be updated based on ab test config" - assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert !metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + assert metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 } def "PBS should apply a/b test config for each module when multiple config are presents with different percentage"() { @@ -352,13 +346,13 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for skipped ortb2blocking module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "Metric for allowed to run response-correction module should be updated based on ab test config" - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] } def "PBS should ignore accounts property for a/b test config when ab test config specialize for specific account"() { @@ -394,8 +388,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 } def "PBS should apply a/b test config and run module when config is on max percentage or default value"() { @@ -432,11 +426,11 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: percentActive | percentActiveSnakeCase @@ -479,8 +473,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: percentActive | percentActiveSnakeCase @@ -526,8 +520,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: percentActive | percentActiveSnakeCase @@ -574,11 +568,11 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: percentActive | percentActiveSnakeCase @@ -621,8 +615,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: logAnalyticsTag | logAnalyticsTagSnakeCase @@ -665,8 +659,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: logAnalyticsTag | logAnalyticsTagSnakeCase @@ -708,11 +702,11 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: logAnalyticsTag | logAnalyticsTagSnakeCase @@ -798,12 +792,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -858,12 +852,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -921,12 +915,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for skipped ortb2blocking module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "Metric for skipped response-correction module should be updated based on ab test config" - assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 + assert !metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + assert metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -975,15 +969,15 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1039,12 +1033,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 2 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 2 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 2 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 2 and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 2 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 2 + assert !metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1105,12 +1099,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be updated based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noInvocation(ModuleName.ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[Metrics.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[Metrics.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy index 8aa26625f5f..a5b36ff34be 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy @@ -1,10 +1,10 @@ package org.prebid.server.functional.tests.module -import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.AdminConfig import org.prebid.server.functional.model.config.ExecutionPlan +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.Ortb2BlockingConfig import org.prebid.server.functional.model.config.PbResponseCorrection import org.prebid.server.functional.model.config.PbsModulesConfig @@ -14,13 +14,11 @@ import org.prebid.server.functional.model.request.auction.RichmediaFilter import org.prebid.server.functional.model.request.auction.TraceLevel import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics +import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER -import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION -import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_BIDDER_REQUEST -import static org.prebid.server.functional.model.config.ModuleHookImplementation.ORTB2_BLOCKING_RAW_BIDDER_RESPONSE -import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES import static org.prebid.server.functional.model.config.Stage.ALL_PROCESSED_BID_RESPONSES import static org.prebid.server.functional.model.config.Stage.BIDDER_REQUEST import static org.prebid.server.functional.model.config.Stage.RAW_BIDDER_RESPONSE @@ -30,9 +28,6 @@ import static org.prebid.server.functional.model.response.auction.ResponseAction class GeneralModuleSpec extends ModuleBaseSpec { - private final static String CALL_METRIC = "modules.module.%s.stage.%s.hook.%s.call" - private final static String NOOP_METRIC = "modules.module.%s.stage.%s.hook.%s.success.noop" - private final static Map DISABLED_INVOKE_CONFIG = ['settings.modules.require-config-to-invoke': 'false'] private final static Map ENABLED_INVOKE_CONFIG = ['settings.modules.require-config-to-invoke': 'true'] @@ -78,14 +73,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 + assert metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 where: modulesConfig << [null, new PbsModulesConfig()] @@ -118,14 +113,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 + assert metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 where: pbRichmediaFilterConfig | pbResponseCorrectionConfig @@ -166,14 +161,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 + assert metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -206,14 +201,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 + assert metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 where: pbRichmediaFilterConfig | ortb2BlockingConfig @@ -251,14 +246,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] == 1 + assert metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 } def "PBS shouldn't call any modules and traces that in response when account config is empty and require-config-to-invoke is enabled"() { @@ -283,14 +278,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics shouldn't be updated" def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "RB-Richmedia-Filter module call metrics shouldn't be updated" - assert !metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] + assert !metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] where: modulesConfig << [null, new PbsModulesConfig()] @@ -322,10 +317,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -353,10 +348,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics shouldn't be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -392,10 +387,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics shouldn't be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -434,10 +429,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -472,14 +467,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics shouldn't be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] - assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "RB-Richmedia-Filter module call metrics shouldn't be updated" - assert !metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] + assert !metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -521,14 +516,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.call(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics shouldn't be updated" - assert !metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)] + assert !metrics[Metrics.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[Metrics.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) 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 3d551a00139..3c0ba31e771 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 @@ -1,12 +1,8 @@ package org.prebid.server.functional.tests.module.optabletargeting -import org.prebid.server.functional.model.config.AccountConfig -import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.IdentifierType -import org.prebid.server.functional.model.config.ModuleHookImplementation import org.prebid.server.functional.model.config.OperatingSystem import org.prebid.server.functional.model.config.OptableTargetingConfig -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.Data @@ -17,6 +13,7 @@ import org.prebid.server.functional.model.request.auction.PublicCountryIp import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.testcontainers.scaffolding.StoredCache import org.prebid.server.functional.tests.module.ModuleBaseSpec +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import static org.apache.commons.codec.binary.Base64.encodeBase64 @@ -27,14 +24,6 @@ import static org.prebid.server.functional.testcontainers.Dependencies.getNetwor class CacheStorageSpec extends ModuleBaseSpec { - private static final String METRIC_CREATIVE_SIZE_TEXT = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.entry_size.text" - private static final String METRIC_CREATIVE_TTL_TEXT = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.entry_ttl.text" - - private static final String METRIC_CREATIVE_READ_OK = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.read.ok" - private static final String METRIC_CREATIVE_READ_ERR = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.read.err" - private static final String METRIC_CREATIVE_WRITE_OK = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.write.ok" - private static final String METRIC_CREATIVE_WRITE_ERR = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.write.err" - private static final StoredCache storedCache = new StoredCache(networkServiceContainer) def setup() { @@ -60,12 +49,12 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update metrics for new saved text storage cache" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_READ_ERR] == 1 + assert metrics[Metrics.Cache.readErr(OPTABLE_TARGETING)] == 1 and: "No updates for success metrics" - assert !metrics[METRIC_CREATIVE_SIZE_TEXT] - assert !metrics[METRIC_CREATIVE_TTL_TEXT] - assert !metrics[METRIC_CREATIVE_READ_OK] + assert !metrics[Metrics.Cache.creativeSizeText(OPTABLE_TARGETING)] + assert !metrics[Metrics.Cache.creativeTtlText(OPTABLE_TARGETING)] + assert !metrics[Metrics.Cache.readOk(OPTABLE_TARGETING)] } def "PBS should update error metrics when external service responded with invalid values"() { @@ -91,15 +80,15 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update error metrics" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_WRITE_ERR] == 1 + assert metrics[Metrics.Cache.writeErr(OPTABLE_TARGETING)] == 1 and: "No updates for success metrics" - assert !metrics[METRIC_CREATIVE_WRITE_OK] + assert !metrics[Metrics.Cache.writeOk(OPTABLE_TARGETING)] } def "PBS should update metrics for new saved text storage cache when no cached requests"() { given: "Current value of metric prebid cache" - def okInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_OK) + def okInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, Metrics.Cache.writeOk(OPTABLE_TARGETING)) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -123,20 +112,20 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update metrics for new saved text storage cache" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_SIZE_TEXT] == new String(encodeBase64(encode(targetingResult).bytes)).size() - assert metrics[METRIC_CREATIVE_WRITE_OK] == okInitialValue + 1 + assert metrics[Metrics.Cache.creativeSizeText(OPTABLE_TARGETING)] == new String(encodeBase64(encode(targetingResult).bytes)).size() + assert metrics[Metrics.Cache.writeOk(OPTABLE_TARGETING)] == okInitialValue + 1 and: "PBS should include histogram metric" - assert metrics[METRIC_CREATIVE_TTL_TEXT] + assert metrics[Metrics.Cache.creativeTtlText(OPTABLE_TARGETING)] } def "PBS should update metrics for stored cached requests cache when proper record present"() { given: "Current value of metric prebid cache" - def textInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_SIZE_TEXT) - def ttlInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_TTL_TEXT) - def writeInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_OK) - def readErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_READ_ERR) - def writeErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_ERR) + def textInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, Metrics.Cache.creativeSizeText(OPTABLE_TARGETING)) + def ttlInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, Metrics.Cache.creativeTtlText(OPTABLE_TARGETING)) + def writeInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, Metrics.Cache.writeOk(OPTABLE_TARGETING)) + def readErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, Metrics.Cache.readErr(OPTABLE_TARGETING)) + def writeErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, Metrics.Cache.writeErr(OPTABLE_TARGETING)) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -160,16 +149,16 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update metrics for stored cached requests" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_READ_OK] == 1 + assert metrics[Metrics.Cache.readOk(OPTABLE_TARGETING)] == 1 and: "No updates for new saved text storage metrics" - assert metrics[METRIC_CREATIVE_SIZE_TEXT] == textInitialValue - assert metrics[METRIC_CREATIVE_TTL_TEXT] == ttlInitialValue - assert metrics[METRIC_CREATIVE_WRITE_OK] == writeInitialValue + assert metrics[Metrics.Cache.creativeSizeText(OPTABLE_TARGETING)] == textInitialValue + assert metrics[Metrics.Cache.creativeTtlText(OPTABLE_TARGETING)] == ttlInitialValue + assert metrics[Metrics.Cache.writeOk(OPTABLE_TARGETING)] == writeInitialValue and: "No update for error metrics" - assert metrics[METRIC_CREATIVE_READ_ERR] == readErrorInitialValue - assert metrics[METRIC_CREATIVE_WRITE_ERR] == writeErrorInitialValue + assert metrics[Metrics.Cache.readErr(OPTABLE_TARGETING)] == readErrorInitialValue + assert metrics[Metrics.Cache.writeErr(OPTABLE_TARGETING)] == writeErrorInitialValue } private static BidRequest getBidRequestForModuleCacheStorage(String ifa, OperatingSystem os) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy index e4d04a6695b..a37ea6c58f3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy @@ -15,7 +15,7 @@ import org.prebid.server.functional.model.request.auction.Audio import org.prebid.server.functional.model.request.auction.Banner import org.prebid.server.functional.model.request.auction.BidderControls import org.prebid.server.functional.model.request.auction.GenericPreferredBidder -import org.prebid.server.functional.model.request.auction.Ix +import org.prebid.server.functional.model.bidder.Ix import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.Video @@ -23,7 +23,6 @@ import org.prebid.server.functional.model.response.auction.Adm import org.prebid.server.functional.model.response.auction.Bid import org.prebid.server.functional.model.response.auction.BidMediaType import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.model.response.auction.MediaType import org.prebid.server.functional.model.response.auction.SeatBid import org.prebid.server.functional.tests.module.ModuleBaseSpec diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy index b07003a0fbb..d2879f1b8ba 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy @@ -2,12 +2,12 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.request.auction.Imp -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy index 1ac39666347..48fc2a55194 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy @@ -1,12 +1,12 @@ package org.prebid.server.functional.tests.module.pbruleengine +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.bidder.Generic import org.prebid.server.functional.model.bidder.Openx import org.prebid.server.functional.model.config.PbRulesEngine import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.pricefloors.Country -import org.prebid.server.functional.model.request.auction.Amx 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.DistributionChannel @@ -16,14 +16,12 @@ import org.prebid.server.functional.model.request.auction.ImpUnitCode import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST -import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.model.pricefloors.Country.USA import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP import static org.prebid.server.functional.model.request.auction.DistributionChannel.DOOH @@ -38,9 +36,6 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { protected static final List MULTI_BID_ADAPTERS = [GENERIC, OPENX, AMX].sort() protected static final String DEFAULT_CONDITIONS = "default" - protected final static String CALL_METRIC = "modules.module.${PB_RULE_ENGINE.code}.stage.${PROCESSED_AUCTION_REQUEST.metricValue}.hook.${PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST.code}.call" - protected final static String NOOP_METRIC = "modules.module.${PB_RULE_ENGINE.code}.stage.${PROCESSED_AUCTION_REQUEST.metricValue}.hook.${PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST.code}.success.noop" - protected final static String UPDATE_METRIC = "modules.module.${PB_RULE_ENGINE.code}.stage.${PROCESSED_AUCTION_REQUEST.metricValue}.hook.${PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST.code}.success.update" protected final static Closure INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING = { accountId, functionType -> "Failed to parse rule-engine config for account $accountId: " + "Function '$functionType' configuration is invalid: " + diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy index e82a78754da..283e2b1e64e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy @@ -16,10 +16,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant import static org.prebid.server.functional.model.ChannelType.WEB -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.AD_UNIT_CODE import static org.prebid.server.functional.model.config.RuleEngineFunction.AD_UNIT_CODE_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy index ab264a09c27..6821afde514 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy @@ -6,14 +6,14 @@ import org.prebid.server.functional.model.config.RuleSet import org.prebid.server.functional.model.config.RulesEngineModelGroup import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.request.auction.Imp -import org.prebid.server.functional.model.response.auction.AnalyticTagStatus +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.bidder.BidderName.UNKNOWN +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.ResultFunction.LOG_A_TAG import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult @@ -65,8 +65,8 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { and: "PBs should populate call and update metrics" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC] == 1 - assert metrics[UPDATE_METRIC] == 1 + assert metrics[Metrics.Module.call(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[Metrics.Module.update(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 and: "Response should seatNon bid with code 203" assert bidResponse.ext.seatnonbid.size() == 1 diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy index 3891eafd32c..a3fb7f1aef9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy @@ -9,10 +9,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_COUNTRY import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_COUNTRY_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy index dd7dcd2bdc6..506b63ab485 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy @@ -6,10 +6,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy index 367027fc609..bd6ba408723 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy @@ -14,16 +14,15 @@ import org.prebid.server.functional.model.request.auction.SiteExtData import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.model.request.auction.UserExtData -import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.EID_AVAILABLE import static org.prebid.server.functional.model.config.RuleEngineFunction.EID_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy index 416590b010f..e301fb60530 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy @@ -5,10 +5,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.PERCENT import static org.prebid.server.functional.model.config.RuleEngineFunction.PREBID_KEY diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy index 0f902b7b31b..f3dd6728cb5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy @@ -1,13 +1,12 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.UidsCookie -import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.HttpUtil -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy index 6cc940023b9..0e7d23f1ca9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy @@ -1,10 +1,12 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.config.RuleEngineFunctionArgs +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import java.time.Instant +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.AD_UNIT_CODE import static org.prebid.server.functional.model.config.RuleEngineFunction.BUNDLE @@ -17,6 +19,7 @@ import static org.prebid.server.functional.model.config.RuleEngineFunction.FPD_A import static org.prebid.server.functional.model.config.RuleEngineFunction.GPP_SID_AVAILABLE 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.config.Stage.PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.model.pricefloors.Country.BULGARIA class RuleEngineValidationSpec extends RuleEngineBaseSpec { @@ -58,11 +61,11 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { and: "PBs should populate call and noop metrics" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC] == 1 - assert metrics[NOOP_METRIC] == 1 + assert metrics[Metrics.Module.call(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[Metrics.Module.noop(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 and: "PBs should populate update metrics" - assert !metrics[UPDATE_METRIC] + assert !metrics[Metrics.Module.update(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] where: pbRulesEngine << [ @@ -112,7 +115,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { and: "PBs should populate noop metrics" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NOOP_METRIC] == 1 + assert metrics[Metrics.Module.noop(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 } def "PBS shouldn't remove bidder and emit a warning when args rule engine not fully configured in account"() { @@ -150,7 +153,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { and: "PBs should populate failer metrics" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NOOP_METRIC] == 1 + assert metrics[Metrics.Module.noop(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 } def "PBS shouldn't remove bidder and emit a warning when model group rule engine not fully configured in account"() { 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 d7f105b050d..c0f1395f1ec 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 @@ -2,8 +2,6 @@ package org.prebid.server.functional.tests.module.responsecorrenction import org.prebid.server.functional.model.config.AccountAuctionConfig import org.prebid.server.functional.model.config.AccountCacheConfig -import org.prebid.server.functional.model.config.AccountConfig -import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.AppVideoHtml import org.prebid.server.functional.model.config.PbResponseCorrection import org.prebid.server.functional.model.db.Account diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy index 84b1202214e..616ea862cad 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy @@ -22,6 +22,7 @@ import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.scaffolding.CurrencyConversion import org.prebid.server.functional.testcontainers.scaffolding.FloorsProvider import org.prebid.server.functional.tests.BaseSpec +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import java.math.RoundingMode @@ -41,8 +42,6 @@ abstract class PriceFloorsBaseSpec extends BaseSpec { protected static final String BASIC_FETCH_URL = networkServiceContainer.rootUri + FloorsProvider.FLOORS_ENDPOINT protected static final int MAX_MODEL_WEIGHT = 100 - protected static final Closure INVALID_CONFIG_METRIC = { account -> "alerts.account_config.${account}.price-floors" } - protected static final Closure URL_EMPTY_ERROR = { url -> "Failed to fetch price floor from provider for fetch.url '${url}'" } protected static final String FETCHING_DISABLED_ERROR = "Fetching is disabled" diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy index 4cfdfc80097..6d1dc904e84 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy @@ -10,6 +10,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.ExtPrebidFloors import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -45,7 +46,6 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { private static final int DEFAULT_FLOOR_VALUE_MIN = 0 private static final int FLOOR_MIN = 0 - private static final String FETCH_FAILURE_METRIC = "price-floors.fetch.failure" private static final String PRICE_FLOOR_VALUES_MISSING = 'Price floor rules values can\'t be null or empty, but were null' private static final String MODEL_WEIGHT_INVALID = "Price floor modelGroup modelWeight must be in range(1-100), but was %s" private static final String SKIP_RATE_INVALID = "Price floor modelGroup skipRate must be in range(0-100), but was %s" @@ -163,7 +163,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid.isEmpty() @@ -189,7 +189,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -216,7 +216,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -237,7 +237,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -258,7 +258,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -288,7 +288,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -573,7 +573,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "metric should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS should fetch data" assert floorsProvider.getRequestCount(bidRequest.accountId) == 1 @@ -655,7 +655,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "metric should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS should add single warning" assert response.ext?.warnings[PREBID]*.code == [999] @@ -764,7 +764,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Failed to request, provider respond with status 400" @@ -806,7 +806,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Failed to parse price floor response, cause: DecodeException: Failed to decode" @@ -847,7 +847,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Failed to parse price floor response, response body can not be empty" @@ -891,7 +891,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor rules should contain at least one model group" @@ -935,7 +935,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = floorsPbsService.getLogsByTime(startTime) @@ -981,7 +981,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor rules number 2 exceeded its maximum number $maxRules" @@ -1029,7 +1029,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = pbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = pbsService.getLogsByTime(startTime) @@ -1074,7 +1074,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Response size $responseSize exceeded ${convertKilobyteSizeToByte(maxSize)} bytes limit" @@ -1757,7 +1757,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[Metrics.General.alert()] where: bidRequest << [BidRequest.getDefaultBidRequest(), getBidRequestWithFloors().tap { it.ext.prebid.floors = null }] @@ -1808,7 +1808,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: requestFloorEnabled << [null, true] @@ -1849,7 +1849,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[Metrics.General.alert()] } def "PBS shouldn't emit error in log and response when data is invalid and floors fetching enabled for account"() { @@ -1892,7 +1892,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[Metrics.General.alert()] where: requestEnabledFloors << [null, true] @@ -1937,7 +1937,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[Metrics.General.alert()] } def "PBS should not invalidate previously good fetched data when floors provider return invalid data"() { @@ -2031,7 +2031,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = floorsPbsService.getLogsByTime(startTime) @@ -2088,7 +2088,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor data skipRate must be in range(0-100), but was $invalidSkipRate" @@ -2146,7 +2146,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = floorsPbsService.getLogsByTime(startTime) @@ -2203,7 +2203,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[Metrics.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor modelGroup default must be positive float, but was $invalidDefaultFloor" @@ -2410,7 +2410,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -2439,7 +2439,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -2466,7 +2466,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy index 73b462576e7..a5a786e8e84 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy @@ -13,7 +13,7 @@ import org.prebid.server.functional.model.pricefloors.MediaType import org.prebid.server.functional.model.pricefloors.PriceFloorData import org.prebid.server.functional.model.pricefloors.PriceFloorSchema import org.prebid.server.functional.model.pricefloors.Rule -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.Banner import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy index 9a4e2501410..e1b8310d0a9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy @@ -16,6 +16,7 @@ import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.Video import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.MediaType +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import java.math.RoundingMode @@ -85,7 +86,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[Metrics.General.alert()] where: requestEnabled | accountEnabled @@ -600,7 +601,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[Metrics.General.alert()] } def "PBS should emit warning when request has more rules than price-floor.max-rules"() { @@ -639,7 +640,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: maxRules | maxRulesSnakeCase @@ -680,7 +681,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: maxSchemaDims | maxSchemaDimsSnakeCase @@ -732,8 +733,8 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Metrics should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 + assert metrics[Metrics.General.alert()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsFloorConfig) @@ -785,8 +786,8 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Metrics should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Account.invalidConfigFloors(bidRequest.accountId)] == 1 + assert metrics[Metrics.General.alert()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsFloorConfig) @@ -826,7 +827,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: maxSchemaDims | maxSchemaDimsSnakeCase @@ -871,7 +872,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS shouldn't fail with error and maxSchemaDims take precede over fetch.maxSchemaDims when requested both"() { @@ -946,7 +947,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: maxRules | maxRulesSnakeCase @@ -982,7 +983,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: requestSkipRate << [PBSUtils.randomNegativeNumber, PBSUtils.getRandomNumber(100)] @@ -1016,7 +1017,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: requestModelGroups << [null, []] @@ -1052,7 +1053,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: requestModelWeight << [PBSUtils.randomNegativeNumber, PBSUtils.getRandomNumber(100)] @@ -1089,7 +1090,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS should emit error in log and response when modelGroup defaultFloor is negative"() { @@ -1124,7 +1125,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS should emit error in log and response when account have disabled dynamic data config"() { @@ -1164,7 +1165,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } private static int getSchemaSize(BidRequest bidRequest) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAmpSpec.groovy index 945ee175ee1..8dc3494e0ce 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAmpSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.response.auction.ErrorType +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.privacy.BogusConsent import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent @@ -14,8 +15,6 @@ import spock.lang.PendingFeature import static org.prebid.server.functional.model.ChannelType.AMP import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -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 import static org.prebid.server.functional.model.request.amp.ConsentType.TCF_1 import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS @@ -130,12 +129,12 @@ class CcpaAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 where: ccpaConfig << [new AccountCcpaConfig(enabled: false, channelEnabled: [(AMP): true]), @@ -172,12 +171,12 @@ class CcpaAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] where: ccpaConfig << [new AccountCcpaConfig(enabled: true, channelEnabled: [(AMP): false]), diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAuctionSpec.groovy index d544c7a2788..455ed339e68 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CcpaAuctionSpec.groovy @@ -3,6 +3,7 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.ChannelType import org.prebid.server.functional.model.config.AccountCcpaConfig import org.prebid.server.functional.model.request.auction.DistributionChannel +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.privacy.BogusConsent import org.prebid.server.functional.util.privacy.CcpaConsent import spock.lang.PendingFeature @@ -10,9 +11,6 @@ import spock.lang.PendingFeature import static org.prebid.server.functional.model.ChannelType.PBJS import static org.prebid.server.functional.model.ChannelType.WEB import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD @@ -145,15 +143,15 @@ class CcpaAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 where: ccpaConfig << [new AccountCcpaConfig(enabled: false, channelEnabled: [(ChannelType.APP): true]), @@ -182,17 +180,17 @@ class CcpaAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Metrics account shouldn't be populated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] where: ccpaConfig << [new AccountCcpaConfig(enabled: false, channelEnabled: [(ChannelType.APP): true]), @@ -237,15 +235,15 @@ class CcpaAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] where: ccpaConfig << [new AccountCcpaConfig(enabled: true, channelEnabled: [(ChannelType.APP): false]), diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy index ebc3d3b2f23..3232a346f7f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy @@ -2,12 +2,10 @@ package org.prebid.server.functional.tests.privacy import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest +import org.prebid.server.functional.util.Metrics import spock.lang.PendingFeature import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD @@ -197,15 +195,15 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS should mask device and user fields for auction request when coppa = 1 was passed and trace level verbose"() { @@ -267,15 +265,15 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS should mask device and user fields for auction request when coppa = 1 was passed and trace level basic"() { @@ -337,17 +335,17 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Account metrics shouldn't be updated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] } def "PBS shouldn't mask device and user fields for amp request when coppa = 0 was passed"() { @@ -401,15 +399,15 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS should mask device and user fields for amp request when coppa = 1 was passed"() { @@ -475,11 +473,11 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } } 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 8eb190ba857..8a03a6c034d 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 @@ -13,6 +13,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Regs import org.prebid.server.functional.model.request.auction.RegsExt +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.BogusConsent import org.prebid.server.functional.util.privacy.CcpaConsent @@ -30,8 +31,6 @@ 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.pricefloors.Country.BULGARIA -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 import static org.prebid.server.functional.model.request.amp.ConsentType.TCF_1 import static org.prebid.server.functional.model.request.amp.ConsentType.US_PRIVACY @@ -394,7 +393,7 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Alerts.general metrics should be populated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Bidder should be called" assert bidder.getBidderRequest(ampStoredRequest.id) @@ -502,8 +501,8 @@ class GdprAmpSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 } def "PBS auction should update activity controls privacy metrics when tcf requirement disallow privacy fields"() { @@ -578,12 +577,12 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should not update activity controls privacy metrics when tcf requirement allow privacy fields"() { @@ -652,12 +651,12 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS amp should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() { @@ -737,8 +736,8 @@ class GdprAmpSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: gdpr | coppa | extGdpr | extCoppa @@ -820,8 +819,8 @@ class GdprAmpSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: requestCountry | accountCountry | requestIpV4 | requestIpV6 | header 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 8ccf39c1583..a21cc9d4c92 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 @@ -12,6 +12,7 @@ import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Regs import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.model.response.auction.ErrorType +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.BogusConsent import org.prebid.server.functional.util.privacy.TcfConsent @@ -33,9 +34,6 @@ import static org.prebid.server.functional.model.mock.services.vendorlist.GvlSpe 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 -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.auction.ActivityType.FETCH_BIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO @@ -342,7 +340,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Alerts.general metrics should be populated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Bid response should contain seatBid" assert response.seatbid.size() == 1 @@ -439,8 +437,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs should increment metrics when eea-country matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert metricsRequest["privacy.tcf.v2.in-geo"] == 1 - assert !metricsRequest["privacy.tcf.v2.out-geo"] + assert metricsRequest[Metrics.Privacy.tcfInGeo(2)] == 1 + assert !metricsRequest[Metrics.Privacy.tcfOutGeo(2)] } def "PBS should apply gdpr and not emit metrics when host and device.geo.country doesn't contain same eea-country"() { @@ -467,8 +465,9 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs should increment metrics when eea-country doens't matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert !metricsRequest["privacy.tcf.v2.in-geo"] - assert metricsRequest["privacy.tcf.v2.out-geo"] == 1 + assert !metricsRequest[Metrics.Privacy.tcfInGeo(2)] + assert metricsRequest[Metrics.Privacy.tcfOutGeo(2)] == 1 + } def "PBS should apply gdpr and emit metrics when account and device.geo.country contains same eea-country"() { @@ -495,8 +494,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs should increment metrics when eea-country matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert metricsRequest["privacy.tcf.v2.in-geo"] == 1 - assert !metricsRequest["privacy.tcf.v2.out-geo"] + assert metricsRequest[Metrics.Privacy.tcfInGeo(2)] == 1 + assert !metricsRequest[Metrics.Privacy.tcfOutGeo(2)] } def "PBS should apply gdpr and not emit metrics when account and device.geo.country doesn't contain same eea-country"() { @@ -523,8 +522,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs shouldn't increment metrics when eea-country matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert !metricsRequest["privacy.tcf.v2.in-geo"] - assert metricsRequest["privacy.tcf.v2.out-geo"] == 1 + assert !metricsRequest[Metrics.Privacy.tcfInGeo(2)] + assert metricsRequest[Metrics.Privacy.tcfOutGeo(2)] == 1 } def "PBS auction should update activity controls fetch bids metrics when tcf requirement disallow request"() { @@ -552,9 +551,9 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 } def "PBS auction should update activity controls privacy metrics when tcf requirement disallow privacy fields and trace level verbosity"() { @@ -624,15 +623,15 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should update activity controls privacy metrics when tcf requirement disallow privacy fields and trace level basic"() { @@ -702,17 +701,17 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Account metrics shouldn't be updated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] } def "PBS auction should not update activity controls privacy metrics when tcf requirement allow privacy fields"() { @@ -777,15 +776,15 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS auction should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() { @@ -850,8 +849,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: gdpr | coppa | extGdpr | extCoppa @@ -926,8 +925,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: requestCountry | accountCountry | requestIpV4 | requestIpV6 | header @@ -1005,8 +1004,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics buyeruid scrubbed shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics["adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] - assert !metrics["account.${account.uuid}.adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] + assert !metrics[Metrics.Adapter.buyerUidScrubbed(GENERIC)] + assert !metrics[Metrics.Account.buyerUidScrubbed(account.uuid, GENERIC)] where: verbosityLevel << [DETAILED, AccountMetricsVerbosityLevel.BASIC] @@ -1051,10 +1050,10 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics buyeruid scrubbed should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics["adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] == 1 + assert metrics[Metrics.Adapter.buyerUidScrubbed(GENERIC)] == 1 and: "Account metric shouldn't be populated" - assert !metrics["account.${account.uuid}.adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] + assert !metrics[Metrics.Account.buyerUidScrubbed(account.uuid, GENERIC)] } def "PBS auction should update buyeruid scrubbed general and account metrics when user.buyeruid requested and verbosityLevel DETAILED"() { @@ -1096,7 +1095,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics buyeruid scrubbed should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics["adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] == 1 - assert metrics["account.${account.uuid}.adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] == 1 + assert metrics[Metrics.Adapter.buyerUidScrubbed(GENERIC)] == 1 + assert metrics[Metrics.Account.buyerUidScrubbed(account.uuid, GENERIC)] == 1 } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprSetUidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprSetUidSpec.groovy index df46f493775..aa1290fec10 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprSetUidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprSetUidSpec.groovy @@ -11,6 +11,7 @@ import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.util.ResourceUtil @@ -161,7 +162,7 @@ class GdprSetUidSpec extends PrivacyBaseSpec { and: "Metric should be increased usersync.FAMILY.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${GENERIC.value}.tcf.blocked"] == 1 + assert metric[Metrics.UserSync.tcfBlocked(GENERIC)] == 1 } def "PBS setuid should failed with tcf when purpose access device enforced for account"() { @@ -202,7 +203,7 @@ class GdprSetUidSpec extends PrivacyBaseSpec { and: "Metric should be increased usersync.FAMILY.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${GENERIC.value}.tcf.blocked"] == 1 + assert metric[Metrics.UserSync.tcfBlocked(GENERIC)] == 1 } def "PBS setuid should failed with tcf when purpose access device enforced for host"() { @@ -247,7 +248,7 @@ class GdprSetUidSpec extends PrivacyBaseSpec { and: "Metric should be increased usersync.FAMILY.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${GENERIC.value}.tcf.blocked"] == 1 + assert metric[Metrics.UserSync.tcfBlocked(GENERIC)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy index d292bd9e6f1..3bda3311694 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppFetchBidActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule @@ -21,6 +22,7 @@ import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -56,11 +58,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -107,8 +104,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + Metrics.Privacy.requestProcessedActivityCount() + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(FETCH_BIDS, Activity.defaultActivity), @@ -140,9 +138,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(FETCH_BIDS, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -291,8 +289,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: regsGppSid | conditionGppSid @@ -328,9 +326,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: condition << [Condition.baseCondition.tap { @@ -383,8 +381,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: deviceGeo | conditionGeo @@ -429,9 +427,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: deviceGeo | conditionGeo @@ -474,9 +472,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 } def "PBS auction shouldn't disallowed rule when regs.ext.gpc doesn't intersect"() { @@ -512,8 +510,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should disallowed rule when header sec-gpc intersect with condition.gpc"() { @@ -548,9 +546,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: gpcHeader << [VALID_VALUE_FOR_GPC_HEADER as Integer, VALID_VALUE_FOR_GPC_HEADER] @@ -588,8 +586,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: gpcHeader << [1, "1"] @@ -780,7 +778,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 where: gppAccountsConfig << [[new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false), @@ -962,7 +960,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1159,7 +1157,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when bidder rejected in activities should skip call to restricted bidders and update disallowed metrics"() { @@ -1197,8 +1195,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 } def "PBS amp call when default activity setting set to false should skip call to restricted bidder"() { @@ -1393,7 +1391,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp should disallow rule when header gpc intersection with condition.gpc"() { @@ -1436,8 +1434,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 } def "PBS amp call when privacy regulation match should call bid adapter"() { @@ -1572,7 +1570,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid property should respond with an error"() { @@ -1771,7 +1769,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy index eac5f98fca5..2dcaee26ea2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy @@ -23,6 +23,7 @@ import org.prebid.server.functional.model.request.auction.Condition import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -55,9 +56,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -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.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -82,9 +80,6 @@ import static org.prebid.server.functional.util.privacy.model.State.MANITOBA class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { - private static final String GEO_LOCATION_REQUESTS = "geolocation_requests" - private static final String GEO_LOCATION_SUCCESSFUL = "geolocation_successful" - private final static int INVALID_STATUS_CODE = 451 private final static String INVALID_STATUS_MESSAGE = "Unavailable For Legal Reasons." @@ -114,7 +109,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.defaultActivity), @@ -144,8 +139,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -294,7 +289,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 where: gppSid | conditionGppSid @@ -336,8 +331,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 } def "PBS cookie sync call when privacy regulation match and rejecting should exclude bidders URLs"() { @@ -576,8 +571,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Response shouldn't contain warnings" assert !response.warnings @@ -623,7 +618,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 and: "Should add a warning when in debug mode" assert response.warnings.contains("GPP string invalid: Unable to decode '$invalidGpp'".toString()) @@ -740,10 +735,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[Metrics.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -783,7 +778,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS cookie sync call when privacy module contain invalid code should include proper responded with bidders URLs"() { @@ -943,7 +938,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1134,7 +1129,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS setuid request when bidder restriction by activities should reject bidders with status code invalidStatusCode and update disallowed metrics"() { @@ -1168,8 +1163,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, SYNC_USER)] == 1 } def "PBS setuid when default activity setting set to false should reject bidders with status code invalidStatusCode"() { @@ -1336,7 +1331,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 where: gppSid | conditionGppSid @@ -1600,8 +1595,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1647,7 +1642,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS setuid request when request have different gpp consent but match and rejecting should reject bidders with status code invalidStatusCode"() { @@ -1769,10 +1764,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[Metrics.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -1815,7 +1810,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS setuid request call when privacy module contain invalid code should respond with valid bidders UIDs cookies"() { @@ -1990,7 +1985,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -2199,7 +2194,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -2258,7 +2253,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -2313,8 +2308,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -2422,12 +2417,13 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 and: "Metrics processed across activities should be updated" - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 + + assert metrics[Metrics.General.geolocationRequests()] == 1 + assert metrics[Metrics.General.geolocationSuccessful()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy index ba9413a0bd7..1d9e46b769d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule @@ -21,6 +22,7 @@ import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -53,11 +55,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -103,13 +100,13 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.defaultActivity), new AllowActivities().tap { transmitEidsKebabCase = Activity.defaultActivity }, - new AllowActivities().tap { transmitEidsSnakeCase = Activity.defaultActivity },] + new AllowActivities().tap { transmitEidsSnakeCase = Activity.defaultActivity }] } def "PBS auction call when transmit EIDS activities is rejecting requests should remove EIDS fields in request and update disallowed metrics"() { @@ -137,9 +134,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -291,8 +288,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: regsGppSid | conditionGppSid @@ -338,9 +335,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS auction should process rule when device.geo doesn't intersection"() { @@ -379,8 +376,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: deviceGeo | conditionGeo @@ -430,9 +427,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 where: deviceGeo | conditionGeo @@ -475,8 +472,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -519,9 +516,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS auction should process rule when header gpc doesn't intersection with condition.gpc"() { @@ -559,8 +556,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when header gpc intersection with condition.gpc"() { @@ -602,9 +599,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS auction call when privacy regulation match and rejecting should remove EIDS fields in request"() { @@ -886,9 +883,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -936,8 +933,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction call when request have different gpp consent but match and rejecting should remove EIDS fields in request"() { @@ -1055,11 +1052,11 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[Metrics.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -1098,7 +1095,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS auction call when privacy module contain invalid property should respond with an error"() { @@ -1264,7 +1261,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Generic bidder request should have data in EIDS fields" def genericBidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1468,7 +1465,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when transmit EIDS activities is rejecting request should remove EIDS fields field in active request and update disallowed metrics"() { @@ -1508,8 +1505,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS amp call when default activity setting set to false should remove EIDS fields from request"() { @@ -1701,8 +1698,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS amp should allowed rule when gpc header doesn't intersection with condition.gpc"() { @@ -1744,7 +1741,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when privacy regulation match and rejecting should remove EIDS fields in request"() { @@ -2056,8 +2053,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Response should not contain any warnings" assert !response.ext.warnings @@ -2114,7 +2111,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 and: "Should add a warning when in debug mode" assert response.ext.warnings[PREBID]?.message.contains("GPP string invalid: Unable to decode '$invalidGpp'".toString()) @@ -2265,10 +2262,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[Metrics.General.alert()] where: regsGpp << [null, ""] @@ -2365,7 +2362,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid property should respond with an error"() { @@ -2566,7 +2563,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Generic bidder request should have data in EIDS fields" def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy index e3be1b13e98..5f62e91ed1e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitPreciseGeoActivitiesSpec.groovy @@ -20,6 +20,7 @@ import org.prebid.server.functional.model.request.auction.Condition import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -52,11 +53,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -126,8 +122,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_PRECISE_GEO, Activity.defaultActivity), @@ -185,9 +181,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_PRECISE_GEO, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -435,8 +431,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: regsGppSid | conditionGppSid @@ -505,9 +501,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should process rule when device.geo doesn't intersection"() { @@ -572,8 +568,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: deviceGeo | conditionGeo @@ -644,8 +640,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should disallowed rule when device.geo intersection"() { @@ -714,9 +710,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 where: geoCountry | geoRegion | conditionGeo @@ -782,8 +778,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -850,9 +846,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should process rule when header gpc doesn't intersection with condition.gpc"() { @@ -912,8 +908,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should process rule when header gpc intersection with condition.gpc"() { @@ -977,9 +973,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction call when privacy regulation match and rejecting should round lat/lon data to 2 digits"() { @@ -1433,7 +1429,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS auction call when privacy module contain invalid code should respond with an error"() { @@ -1670,7 +1666,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1920,7 +1916,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call with bidder rejected in activities should round lat/lon data to 2 digits and update disallowed metrics"() { @@ -1984,8 +1980,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS amp call when default activity setting set to false should round lat/lon data to 2 digits"() { @@ -2268,7 +2264,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp should disallow rule when header gpc intersection with condition.gpc"() { @@ -2338,8 +2334,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS amp call when privacy regulation match and rejecting should round lat/lon data to 2 digits"() { @@ -2773,7 +2769,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid code should respond with an error"() { @@ -3045,7 +3041,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitTidActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitTidActivitiesSpec.groovy index df0d0ab531f..1a3acf2d225 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitTidActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitTidActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity @@ -8,15 +9,11 @@ import org.prebid.server.functional.model.request.auction.AllowActivities import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Condition import org.prebid.server.functional.model.request.auction.Source +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_TID import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE @@ -55,8 +52,8 @@ class GppTransmitTidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_TID, Activity.defaultActivity), @@ -224,9 +221,9 @@ class GppTransmitTidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_TID)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_TID)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_TID)] == 1 } def "PBS auction should remove bidRequest.(source/imp[0].ext).tid and don't change schain in request when ext.prebid.createTids=#createTid and defaultAction=false and schain specified in request"() { @@ -426,7 +423,7 @@ class GppTransmitTidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_TID)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp should generate id for bidRequest.(source/imp[0].ext).tid when ext.prebid.createTids=true and transmit activity allowed"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index 321cb1bef94..bfd26f733f2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountGdprConfig import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig @@ -26,6 +27,7 @@ import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -59,11 +61,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -128,8 +125,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.defaultActivity), @@ -178,9 +175,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -401,8 +398,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: regsGppSid | conditionGppSid @@ -463,9 +460,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS auction should process rule when device.geo doesn't intersection"() { @@ -523,8 +520,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: deviceGeo | conditionGeo @@ -589,9 +586,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 where: deviceGeo | conditionGeo @@ -653,8 +650,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -712,9 +709,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS auction should process rule when header gpc doesn't intersection with condition.gpc"() { @@ -771,8 +768,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when header gpc intersection with condition.gpc"() { @@ -829,9 +826,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS auction call when privacy regulation match and rejecting should remove UFPD fields in request"() { @@ -1156,7 +1153,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1241,7 +1238,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1321,9 +1318,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1391,8 +1388,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { @@ -1565,11 +1562,11 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[Metrics.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -1628,7 +1625,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS auction call when privacy module contain invalid property should respond with an error"() { @@ -1827,7 +1824,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Generic bidder request should have data in UFPD fields" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -2085,7 +2082,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when transmit UFPD activities is rejecting request should remove UFPD fields field in active request and update disallowed metrics"() { @@ -2140,8 +2137,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS amp call when default activity setting set to false should remove UFPD fields from request"() { @@ -2398,8 +2395,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS amp should allowed rule when gpc header doesn't intersection with condition.gpc"() { @@ -2460,7 +2457,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when privacy regulation match and rejecting should remove UFPD fields in request"() { @@ -2571,7 +2568,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2935,8 +2932,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Response should not contain any warnings" assert !response.ext.warnings @@ -3013,7 +3010,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 and: "Should add a warning when in debug mode" assert response.ext.warnings[PREBID]?.message.contains("GPP string invalid: Unable to decode '$invalidGpp'".toString()) @@ -3217,10 +3214,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[Metrics.General.alert()] where: regsGpp << [null, ""] @@ -3355,7 +3352,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid property should respond with an error"() { @@ -3589,7 +3586,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[Metrics.General.alert()] == 1 and: "Generic bidder request should have data in UFPD fields" def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) @@ -3850,9 +3847,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 where: eid << [new PurposeEid(activityTransition: false), diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy index 4028fb4d05e..f7c987c82be 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy @@ -1,15 +1,14 @@ package org.prebid.server.functional.tests.privacy +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest 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.DeviceExt +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -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.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD @@ -390,15 +389,15 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should mask device and user fields for auction request and emit metrics when device.lm = 1 was passed and trace basic"() { @@ -460,17 +459,17 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Account metrics shouldn't be populated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] } def "PBS auction shouldn't mask device and user fields for auction request when device.lm = 0 was passed"() { @@ -522,15 +521,15 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS amp should mask device and user fields for auction request when device.lm = 1 was passed"() { @@ -596,15 +595,15 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS amp shouldn't mask device and user fields for auction request when device.lm = 0 was passed"() { @@ -661,12 +660,12 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[Metrics.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } private static getRandomAtts() { 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 a78d1942f93..e29b2900f98 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 @@ -41,6 +41,7 @@ import org.prebid.server.functional.model.request.auction.UserExtData import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.scaffolding.VendorList import org.prebid.server.functional.tests.BaseSpec +import org.prebid.server.functional.util.Metrics import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.ConsentString import org.prebid.server.functional.util.privacy.TcfConsent @@ -263,7 +264,7 @@ abstract class PrivacyBaseSpec extends BaseSpec { pbsService.sendAuctionRequest(bidRequest) - pbsService.sendCollectedMetricsRequest()["privacy.tcf.v2.vendorlist.missing"] == 0 + pbsService.sendCollectedMetricsRequest()[Metrics.Privacy.tcfVendorListMissing(2)] == 0 } PBSUtils.waitUntil(isVendorListCachedClosure, 10000, 1000) } diff --git a/src/test/groovy/org/prebid/server/functional/util/Metrics.groovy b/src/test/groovy/org/prebid/server/functional/util/Metrics.groovy new file mode 100644 index 00000000000..396a2149212 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/util/Metrics.groovy @@ -0,0 +1,408 @@ +package org.prebid.server.functional.util + +import org.prebid.server.functional.model.ChannelType +import org.prebid.server.functional.model.bidder.BidderName +import org.prebid.server.functional.model.config.ModuleHookImplementation +import org.prebid.server.functional.model.config.ModuleName +import org.prebid.server.functional.model.config.Stage +import org.prebid.server.functional.model.request.auction.ActivityType + +class Metrics { + + static class General { + + static String alert() { + 'alerts.general' + } + + static String impsRequested() { + 'imps_requested' + } + + static String impsDropped() { + 'imps_dropped' + } + + static String debugRequests() { + 'debug_requests' + } + + static String floorsFetchFailure() { + 'price-floors.fetch.failure' + } + + static String storedRequestFound() { + 'stored_requests_found' + } + + static String geolocationRequests() { + 'geolocation_requests' + } + + static String geolocationFail() { + 'geolocation_fail' + } + + static String geolocationSuccessful() { + 'geolocation_successful' + } + + static String requestOk(ChannelType channel) { + "requests.ok.openrtb2-${channel.value}" + } + } + + static class Module { + + static String call(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'call') + } + + static String noop(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'success.noop') + } + + static String update(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'success.update') + } + + static String noInvocation(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'success.no-invocation') + } + + static String executionError(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'execution-error') + } + + private static String getBasicModuleMetric(ModuleName name, Stage stage, String suffix) { + def hook = ModuleHookImplementation.forValue(name, stage).code + "modules.module.${name.code}.stage.${stage.metricValue}.hook.${hook}.${suffix}" + } + } + + static class Cache { + + static String requestsOk() { + 'prebid_cache.requests.ok' + } + + static String creativeSizeJson() { + 'prebid_cache.creative_size.json' + } + + static String creativeSizeXml() { + 'prebid_cache.creative_size.xml' + } + + static String creativeTtlJson() { + 'prebid_cache.creative_ttl.json' + } + + static String creativeTtlXml() { + 'prebid_cache.creative_ttl.xml' + } + + static String accountCreativeSizeJson(String accountId) { + accountMetric(accountId, "creative_size.json") + } + + static String accountCreativeSizeXml(String accountId) { + accountMetric(accountId, "creative_size.xml") + } + + static String accountCreativeTtlJson(String accountId) { + accountMetric(accountId, "creative_ttl.json") + } + + static String accountCreativeTtlXml(String accountId) { + accountMetric(accountId, "creative_ttl.xml") + } + + static String accountRequestsOk(String accountId) { + accountMetric(accountId, "requests.ok") + } + + static String creativeSizeText(ModuleName name) { + moduleStorageMetric(name, "entry_size.text") + } + + static String creativeTtlText(ModuleName name) { + moduleStorageMetric(name, "entry_ttl.text") + } + + static String readOk(ModuleName name) { + moduleStorageMetric(name, "read.ok") + } + + static String readErr(ModuleName name) { + moduleStorageMetric(name, "read.err") + } + + static String writeOk(ModuleName name) { + moduleStorageMetric(name, "write.ok") + } + + static String writeErr(ModuleName name) { + moduleStorageMetric(name, "write.err") + } + + static String vtrackCreativeSizeXml() { + vtrackMetric("creative_size.xml") + } + + static String vtrackCreativeTtlXml() { + vtrackMetric("creative_ttl.xml") + } + + static String vtrackWriteOk() { + vtrackMetric("write.ok") + } + + static String vtrackWriteErr() { + vtrackMetric("write.err") + } + + static String vtrackReadOk() { + vtrackMetric("read.ok") + } + + static String vtrackReadErr() { + vtrackMetric("read.err") + } + + private static String accountMetric(String accountId, String suffix) { + "account.${accountId}.prebid_cache.${suffix}" + } + + private static String moduleStorageMetric(ModuleName name, String suffix) { + "prebid_cache.module_storage.${name.code}.${suffix}" + } + + private static String vtrackMetric(String suffix) { + "prebid_cache.vtrack.${suffix}" + } + } + + static class Account { + + static String invalidConfigFloors(String accountId) { + "alerts.account_config.${accountId}.price-floors" + } + + static String requestType(String accountId, ChannelType channel) { + baseMetric(accountId, "requests.type.openrtb2-${channel.value}") + } + + static String debugRequests(String accountId) { + baseMetric(accountId, "debug_requests") + } + + static String cacheVtrackCreativeSizeXml(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.creative_size.xml") + } + + static String cacheVtrackCreativeTtlXml(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.creative_ttl.xml") + } + + static String cacheVtrackWriteOk(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.write.ok") + } + + static String cacheVtrackWriteErr(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.write.err") + } + + static String profilesLimitExceeded(String accountId) { + baseMetric(accountId, "profiles.limit_exceeded") + } + + static String profilesMissing(String accountId) { + baseMetric(accountId, "profiles.missing") + } + + static String rejectedInvalidAccount(String accountId) { + baseMetric(accountId, "requests.rejected.invalid-account") + } + + static String requests(String accountId) { + baseMetric(accountId, "requests") + } + + static String buyerUidScrubbed(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "requests.buyeruid_scrubbed") + } + + static String bidsReceived(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "bids_received") + } + + static String prices(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "prices") + } + + static String requestTime(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "request_time") + } + + static String requestsGotBids(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "requests.gotbids") + } + + static String validationSizeWarn(String accountId) { + baseMetric(accountId, "response.validation.size.warn") + } + + static String validationSizeError(String accountId) { + baseMetric(accountId, "response.validation.size.err") + } + + static String validationSecureWarn(String accountId) { + baseMetric(accountId, "response.validation.secure.warn") + } + + static String validationSecureError(String accountId) { + baseMetric(accountId, "response.validation.secure.err") + } + + private static String adapterMetric(String accountId, BidderName bidder, String suffix) { + baseMetric(accountId, "adapter.${bidder.value}.${suffix}") + } + + private static String baseMetric(String accountId, String suffix) { + "account.${accountId}.${suffix}" + } + } + + static class Adapter { + + private static String request(BidderName adapter, String suffix) { + metric(adapter, 'requests', suffix) + } + + static String seat(BidderName bidder) { + response(bidder, 'seat') + } + + static String requestType(BidderName bidder, ChannelType channel) { + request(bidder, "type.openrtb2-${channel.value}") + } + + static String buyerUidScrubbed(BidderName bidder) { + request(bidder, 'buyeruid_scrubbed') + } + + static String validationSizeWarn(BidderName bidder) { + response(bidder, 'validation.size.warn') + } + + static String validationSizeError(BidderName bidder) { + response(bidder, 'validation.size.err') + } + + static String validationSecureWarn(BidderName bidder) { + response(bidder, 'validation.secure.warn') + } + + static String bidValidation(BidderName bidder) { + request(bidder, 'bid_validation') + } + + static String validationSecureError(BidderName bidder) { + response(bidder, 'validation.secure.err') + } + + private static String response(BidderName adapter, String suffix) { + metric(adapter, 'response', suffix) + } + + private static String metric(BidderName adapter, String type, String suffix) { + "adapter.${adapter.value}.${type}.${suffix}" + } + } + + static class Privacy { + + static String tcfVendorListMissing(Integer version) { + tcfMetric(version, 'vendorlist.missing') + } + + static String tcfInGeo(Integer version) { + tcfMetric(version, 'in-geo') + } + + static String tcfOutGeo(Integer version) { + tcfMetric(version, 'out-geo') + } + + static String requestProcessedActivityCount() { + processedRulesMetric('requests') + } + + static String requestDisallowedActivityCount(ActivityType activity) { + activityMetric('requests', activity) + } + + static String adapterDisallowedActivityCount(BidderName bidder, ActivityType activity) { + activityMetric("adapter.${bidder.value}", activity) + } + + static String accountDisallowedActivityCount(String accountId, ActivityType activity) { + activityMetric("account.${accountId}", activity) + } + + static String accountProcessedRulesCount(String accountId) { + processedRulesMetric("account.${accountId}") + } + + private static String activityMetric(String prefix, ActivityType activity) { + "${prefix}.activity.${activity.metricValue}.disallowed.count" + } + + private static String processedRulesMetric(String prefix) { + "${prefix}.activity.processedrules.count" + } + + private static String tcfMetric(Integer version, String suffix) { + "privacy.tcf.v${version}.${suffix}" + } + } + + static class CookieSync { + + static String tcfBlocked(BidderName adapter) { + cookieBaseMetric(adapter, 'tcf.blocked') + } + + static String filtered(BidderName adapter) { + cookieBaseMetric(adapter, 'filtered') + } + + private static String cookieBaseMetric(BidderName adapter, String suffix) { + "cookie_sync.${adapter.value}.${suffix}" + } + } + + static class UserSync { + + static String sizeBlocked(BidderName adapter) { + userSyncBaseMetric(adapter, 'sizeblocked') + } + + static String sets(BidderName adapter) { + userSyncBaseMetric(adapter, 'sets') + } + + static String tcfBlocked(BidderName adapter) { + userSyncBaseMetric(adapter, 'tcf.blocked') + } + + static String sizedOut(BidderName adapter) { + userSyncBaseMetric(adapter, 'sizedout') + } + + private static String userSyncBaseMetric(BidderName adapter, String suffix) { + "usersync.${adapter.value}.${suffix}" + } + } +}