From c6ddf01a460ef3dd16161db698ff635ee086a831 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Sun, 5 Jan 2025 20:09:27 +0200 Subject: [PATCH 1/2] 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 2/2] 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