diff --git a/src/test/groovy/org/prebid/server/functional/model/ModuleName.groovy b/src/test/groovy/org/prebid/server/functional/model/ModuleName.groovy deleted file mode 100644 index 19a29ae0058..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/ModuleName.groovy +++ /dev/null @@ -1,20 +0,0 @@ -package org.prebid.server.functional.model - -import com.fasterxml.jackson.annotation.JsonValue - -enum ModuleName { - - PB_RICHMEDIA_FILTER("pb-richmedia-filter"), - PB_RESPONSE_CORRECTION ("pb-response-correction"), - ORTB2_BLOCKING("ortb2-blocking"), - PB_REQUEST_CORRECTION('pb-request-correction'), - OPTABLE_TARGETING('optable-targeting'), - PB_RULE_ENGINE('pb-rule-engine') - - @JsonValue - final String code - - ModuleName(String code) { - this.code = code - } -} 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 eb32b75e729..82674995cfc 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 = 1000 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 af7bf670c95..d4302132a76 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/config/ModuleName.groovy b/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy new file mode 100644 index 00000000000..9632eccbbfa --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/config/ModuleName.groovy @@ -0,0 +1,24 @@ +package org.prebid.server.functional.model.config + +import com.fasterxml.jackson.annotation.JsonValue + +enum ModuleName { + + PB_RICHMEDIA_FILTER('pb-richmedia-filter'), + PB_RESPONSE_CORRECTION ('pb-response-correction'), + ORTB2_BLOCKING('ortb2-blocking'), + PB_REQUEST_CORRECTION('pb-request-correction'), + OPTABLE_TARGETING('optable-targeting'), + PB_RULE_ENGINE('pb-rule-engine'), + + @JsonValue + final String code + + 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..a3a2b3f9ca7 100644 --- a/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/config/Stage.groovy @@ -24,6 +24,13 @@ enum Stage { this.metricValue = metricValue } + static Stage forValue(ModuleHookImplementation moduleHook) { + values().collect { [stage: it, matchLength: moduleHook.code.indexOf(it.value) >= 0 ? it.value.length() : -1] } + .findAll { it.matchLength > 0 } + .max { it.matchLength } + ?.stage + } + @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/User.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy index 0104494910b..93090dd72e5 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/User.groovy @@ -1,15 +1,18 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.databind.PropertyNamingStrategies +import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) @EqualsAndHashCode class User { String id - String buyeruid + String buyerUid Integer yob String gender String keywords 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..fb7ac0a62dc 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/UserExtData.groovy @@ -1,21 +1,24 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.databind.PropertyNamingStrategies +import com.fasterxml.jackson.databind.annotation.JsonNaming import groovy.transform.ToString import org.prebid.server.functional.util.PBSUtils @ToString(includeNames = true, ignoreNulls = true) +@JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) class UserExtData { List keywords - 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 a8b737a848a..5b605b12c0f 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticResult.groovy @@ -4,11 +4,10 @@ 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 -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS_BLOCK +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS_BLOCK @ToString(includeNames = true, ignoreNulls = true) @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) @@ -16,7 +15,7 @@ import static org.prebid.server.functional.model.request.auction.FetchStatus.SUC class AnalyticResult { String name - FetchStatus status + AnalyticTagStatus status List results static AnalyticResult buildFromImp(Imp imp) { diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticTagStatus.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticTagStatus.groovy new file mode 100644 index 00000000000..f7575677ce3 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticTagStatus.groovy @@ -0,0 +1,13 @@ +package org.prebid.server.functional.model.response.auction + +import com.fasterxml.jackson.annotation.JsonValue + +enum AnalyticTagStatus { + + NONE, LOOKUP, CONTROL, SUCCESS, ERROR, SUCCESS_ALLOW, SUCCESS_BLOCK, SKIPPED, RUN + + @JsonValue + String getValue() { + name().toLowerCase().replace('_', '-') + } +} diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy index 6fd41583617..bc952b46b09 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivity.groovy @@ -10,6 +10,6 @@ import org.prebid.server.functional.model.request.auction.FetchStatus class AnalyticsTagActivity { ModuleActivityName name - FetchStatus status + AnalyticTagStatus status List results } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy index a439d6411c2..570d7271b5f 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/AnalyticsTagActivityResult.groovy @@ -9,7 +9,7 @@ import org.prebid.server.functional.model.request.auction.FetchStatus @JsonNaming(PropertyNamingStrategies.LowerCaseStrategy) class AnalyticsTagActivityResult { - FetchStatus status + AnalyticTagStatus status AnalyticsTagActivityValue values AppliedTo appliedTo } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy index 8740e415f47..e95e3ee896e 100644 --- a/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/response/auction/ImpResult.groovy @@ -11,7 +11,7 @@ import org.prebid.server.functional.model.request.auction.FetchStatus @EqualsAndHashCode class ImpResult { - FetchStatus status + AnalyticTagStatus status ModuleValue values AppliedTo appliedTo } diff --git a/src/test/groovy/org/prebid/server/functional/model/response/auction/ModuleValue.groovy b/src/test/groovy/org/prebid/server/functional/model/response/auction/ModuleValue.groovy index c780efaa422..d0368344098 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 @@ -3,7 +3,7 @@ package org.prebid.server.functional.model.response.auction import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.EqualsAndHashCode import groovy.transform.ToString -import org.prebid.server.functional.model.ModuleName +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.bidder.BidderName @ToString(includeNames = true, ignoreNulls = true) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy index ab614e0ca5f..205d9537de0 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy @@ -45,13 +45,12 @@ class Dependencies { static final NetworkServiceContainer networkServiceContainer = new NetworkServiceContainer(MOCKSERVER_VERSION) .withNetwork(network) - static LocalStackContainer localStackContainer + static LocalStackContainer localStackContainer = new LocalStackContainer(DockerImageName.parse("localstack/localstack:s3-latest")) + .withNetwork(network) + .withServices(S3) static void start() { if (IS_LAUNCH_CONTAINERS) { - localStackContainer = new LocalStackContainer(DockerImageName.parse("localstack/localstack:s3-latest")) - .withNetwork(network) - .withServices(S3) Startables.deepStart([networkServiceContainer, mysqlContainer, localStackContainer, influxdbContainer]).join() } } 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 05d6fcfa3d7..83e769a30f9 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 @@ -66,7 +66,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 66ce54a9531..36174069c02 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 @@ -115,7 +115,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/AliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AliasSpec.groovy index 9013978f76f..59dde053df1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AliasSpec.groovy @@ -79,8 +79,8 @@ class AliasSpec extends BaseSpec { def "PBS should apply compression type for bidder alias when adapters.BIDDER.endpoint-compression = gzip"() { given: "PBS with adapter configuration" def compressionType = GZIP.value - def pbsService = pbsServiceFactory.getService( - ["adapters.generic.endpoint-compression": compressionType]) + def pbsConfig = ["adapters.generic.endpoint-compression": compressionType] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with alias" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -94,6 +94,9 @@ class AliasSpec extends BaseSpec { then: "Bidder request should contain header Content-Encoding = gzip" assert response.ext?.debug?.httpcalls?.get(ALIAS.value)?.requestHeaders?.first() ?.get(CONTENT_ENCODING_HEADER)?.first() == compressionType + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should return an error when GVL Id alias refers to unknown bidder alias"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy index e376f611e84..e23009c7b6d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AmpFpdSpec.groovy @@ -75,8 +75,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" @@ -196,8 +196,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" @@ -290,8 +290,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 } } @@ -370,8 +370,8 @@ class AmpFpdSpec extends BaseSpec { it.user.gender == fpdUser.gender it.user.keywords == fpdUser.keywords it.user.ext.data.keywords == fpdUser.ext.data.keywords - it.user.ext.data.buyeruid == fpdUser.ext.data.buyeruid - it.user.ext.data.buyeruids == fpdUser.ext.data.buyeruids + it.user.ext.data.buyerUid == fpdUser.ext.data.buyerUid + it.user.ext.data.buyerUids == fpdUser.ext.data.buyerUids } and: "Bidder request shouldn't contain imp[0].ext.rp" @@ -455,8 +455,8 @@ class AmpFpdSpec extends BaseSpec { it.user.gender == fpdUser.gender it.user.keywords == fpdUser.keywords it.user.ext.data.keywords == fpdUser.ext.data.keywords - it.user.ext.data.buyeruid == fpdUser.ext.data.buyeruid - it.user.ext.data.buyeruids == fpdUser.ext.data.buyeruids + it.user.ext.data.buyerUid == fpdUser.ext.data.buyerUid + it.user.ext.data.buyerUids == fpdUser.ext.data.buyerUids } and: "Should should ignore any non FPD data" 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/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy index 1506e2e0a4d..e64090a1ebd 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy @@ -168,7 +168,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid } def "PBS shouldn't populate bidder request buyeruid from buyeruids when buyeruids without appropriate bidder present in request"() { @@ -188,9 +188,11 @@ class AuctionSpec extends BaseSpec { def "PBS should populate buyeruid from uids cookie when buyeruids with appropriate bidder but without value present in request"() { given: "PBS config" - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, - "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, + "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) + and: "Bid request with buyeruids" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -206,14 +208,18 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the uids cookie" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == uidsCookie.tempUIDs[GENERIC].uid + assert bidderRequest?.user?.buyerUid == uidsCookie.tempUIDs[GENERIC].uid + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate buyeruid from uids cookie when buyeruids with appropriate bidder but without value present in request"() { given: "PBS config" - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, - "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.usersync.${REDIRECT.value}.url" : USER_SYNC_URL, + "adapters.${GENERIC.value}.usersync.${REDIRECT.value}.support-cors": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request with buyeruids" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -228,7 +234,10 @@ class AuctionSpec extends BaseSpec { then: "Bidder request shouldn't contain buyeruid from the uids cookie" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert !bidderRequest.user.buyeruid + assert !bidderRequest.user.buyerUid + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should take precedence buyeruids whenever present valid uid cookie"() { @@ -247,7 +256,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid } def "PBS should populate buyeruid from host cookie name config when host cookie family matched with requested bidder"() { @@ -270,16 +279,17 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from cookieName" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == hostCookieUid + assert bidderRequest?.user?.buyerUid == hostCookieUid } def "PBS shouldn't populate buyeruid from cookie name config when host cookie family not matched with requested cookie-family-name"() { given: "PBS config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + GENERIC_CONFIG - + ["host-cookie.family" : APPNEXUS.value, - "host-cookie.cookie-name" : cookieName, - "adapters.generic.usersync.cookie-family-name": GENERIC.value]) + def pbsConfig = PBS_CONFIG + GENERIC_CONFIG + + ["host-cookie.family" : APPNEXUS.value, + "host-cookie.cookie-name" : cookieName, + "adapters.generic.usersync.cookie-family-name": GENERIC.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Bid request" def bidRequest = BidRequest.defaultBidRequest @@ -294,6 +304,9 @@ class AuctionSpec extends BaseSpec { then: "Bidder request shouldn't contain buyeruid from cookieName" def bidderRequest = bidder.getBidderRequest(bidRequest.id) assert !bidderRequest.user + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate buyeruid from cookie when cookie-name in cookie and config are diferent"() { @@ -408,7 +421,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid where: bidderName << [GENERIC, GENERIC_CAMEL_CASE] @@ -439,7 +452,7 @@ class AuctionSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid where: bidderName << [GENERIC, GENERIC_CAMEL_CASE] diff --git a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy index 13479030d1d..087c84880ab 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy @@ -49,6 +49,12 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper { protected static final String ALERT_GENERAL = "alerts.general" protected static final Map GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true", "adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + protected static final Map EMPTY_CACHE_TTL_CONFIG = ["cache.default-ttl-seconds.banner": "", + "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 static 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..18be37c5dcc 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidExpResponseSpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.config.AccountAuctionConfig import org.prebid.server.functional.model.config.AccountConfig +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp @@ -29,16 +30,15 @@ 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 cleanupSpec() { + pbsServiceFactory.removeContainer(CACHE_TTL_HOST_CONFIG + EMPTY_CACHE_TTL_CONFIG) + pbsServiceFactory.removeContainer(EMPTY_CACHE_TTL_CONFIG + EMPTY_CACHE_TTL_HOST_CONFIG) + pbsServiceFactory.removeContainer(CACHE_TTL_HOST_CONFIG + DEFAULT_CACHE_TTL_CONFIG) + } def "PBS auction should resolve bid.exp from response that is set by the bidder’s adapter"() { given: "Default basicResponse with exp" 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..de60c9be236 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" @@ -217,7 +217,7 @@ class BidderInsensitiveCaseSpec extends BaseSpec { then: "Bidder request should contain buyeruid from the user.ext.prebid.buyeruids" def bidderRequest = bidder.getBidderRequest(bidRequest.id) - assert bidderRequest?.user?.buyeruid == buyeruid + assert bidderRequest?.user?.buyerUid == buyeruid } def "PBS should be able to match requested bidder with original bidder name in ext.prebid.aliase"() { @@ -282,9 +282,9 @@ class BidderInsensitiveCaseSpec extends BaseSpec { def "PBS should respond errors with same bidder name which bidder name came in request with another case strategy"() { given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - ["adapter-defaults.enabled": "false", - "adapters.generic.enabled": "false"]) + def pbsConfig = ["adapter-defaults.enabled": "false", + "adapters.generic.enabled": "false"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -299,13 +299,15 @@ class BidderInsensitiveCaseSpec extends BaseSpec { then: "Response should contain error" assert response.ext?.errors[ErrorType.GENERIC_CAMEL_CASE]*.code == [2] + + } def "PBS should respond warnings with same bidder name which bidder name came in request with another case strategy"() { given: "Pbs config" - def pbsService = pbsServiceFactory.getService( - ["auction.filter-imp-media-type.enabled" : "true", - "adapters.generic.meta-info.app-media-types": ""]) + def pbsConfig = ["auction.filter-imp-media-type.enabled" : "true", + "adapters.generic.meta-info.app-media-types": ""] + def pbsService = pbsServiceFactory.getService(pbsConfig) def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { imp[0].ext.prebid.bidder.tap { @@ -324,6 +326,9 @@ class BidderInsensitiveCaseSpec extends BaseSpec { assert response.ext?.warnings[ErrorType.GENERIC_CAMEL_CASE]*.code == [2] assert response.ext?.warnings[ErrorType.GENERIC_CAMEL_CASE]*.message == ["Bidder does not support any media types."] + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should respond responsetimemillis with same bidder name which bidder name came in request with another case strategy"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy index ce17a673424..f1ea6de084c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy @@ -136,7 +136,7 @@ class CacheSpec extends BaseSpec { given: "Pbs config with disabled api-key-secured and pbc.api.key" def apiKey = PBSUtils.randomString def pbsConfig = ['pbc.api.key': apiKey, 'cache.api-key-secured': 'false'] - def pbsService = pbsServiceFactory.getService(['pbc.api.key': apiKey, 'cache.api-key-secured': 'false']) + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -160,7 +160,8 @@ class CacheSpec extends BaseSpec { def "PBS should cache bids with api-key header when targeting is specified and api-key-secured enabled"() { given: "Pbs config with api-key-secured and pbc.api.key" def apiKey = PBSUtils.randomString - def pbsConfig = ['pbc.api.key': apiKey, 'cache.api-key-secured': 'true'] + def pbsConfig = ['pbc.api.key' : apiKey, + 'cache.api-key-secured': 'true'] def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with cache, targeting" diff --git a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy index 29542fd8326..b7fce18dda6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy @@ -99,12 +99,17 @@ class CookieSyncSpec extends BaseSpec { private final PrebidServerService prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) + def cleanupSpec() { + pbsServiceFactory.removeContainer(PBS_CONFIG) + } + def "PBS cookie sync request should replace synced as family bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG + APPNEXUS_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null]) + def pbsConfig = GENERIC_CONFIG + APPNEXUS_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def requestLimit = 2 @@ -127,12 +132,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(GENERIC) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace bidder without config and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG - + ["adapters.${BOGUS.value}.enabled": "true"]) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + ["adapters.${BOGUS.value}.enabled": "true"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default Cookie sync request" def requestLimit = 2 @@ -155,11 +163,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace unknown bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request" def requestLimit = 2 @@ -182,12 +194,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace disabled bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG - + ["adapters.${GENERIC.value}.enabled": "false",]) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + ["adapters.${GENERIC.value}.enabled": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default Cookie sync request" def requestLimit = 2 @@ -210,11 +225,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should replace filtered bidder and fill up response with enabled bidders to the limit in request"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(RUBICON_CONFIG + APPNEXUS_CONFIG) + def pbsConfig = RUBICON_CONFIG + APPNEXUS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request" def requestLimit = 2 @@ -238,12 +257,15 @@ class CookieSyncSpec extends BaseSpec { and: "Response should contain coop-synced bidder" assert response.getBidderUserSync(RUBICON) assert response.getBidderUserSync(APPNEXUS) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder disabled"() { given: "PBS bidder config " - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.enabled": "false"]) + def pbsConfig = PBS_CONFIG + ["adapters.${GENERIC.value}.enabled": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -256,12 +278,15 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't return error" assert !response.getBidderUserSync(GENERIC) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder without sync config"() { given: "PBS bidder config without cookie family name" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.usersync.cookie-family-name": null]) + def pbsConfig = ["adapters.${GENERIC.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -274,6 +299,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't return error" assert !response.getBidderUserSync(GENERIC) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder family already in uids cookie"() { @@ -294,9 +322,10 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request shouldn't reflect error when coop-sync enabled and coop sync bidder synced as family"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null,]) + def pbsConfig = GENERIC_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -309,6 +338,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't return error" assert !response.getBidderUserSync(bidderAlias) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder with gdpr"() { @@ -341,13 +373,14 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder with ccpa"() { given: "PBS bidder config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${bidderName.value}.ccpa-enforced": "true"] + GENERIC_CONFIG) + def pbsConfig = ["adapters.${bidderName.value}.ccpa-enforced": "true"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with account and privacy" + def accountId = PBSUtils.randomString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { bidders = [] - account = PBSUtils.randomString + account = accountId usPrivacy = new CcpaConsent(optOutSale: ENFORCED) coopSync = true } @@ -355,7 +388,7 @@ class CookieSyncSpec extends BaseSpec { and: "Save account config into DB" def ccpaConfig = new AccountCcpaConfig(enabled: true) def accountConfig = new AccountConfig(privacy: new AccountPrivacyConfig(ccpa: ccpaConfig)) - def account = new Account(uuid: cookieSyncRequest.account, config: accountConfig) + def account = new Account(uuid: accountId, config: accountConfig) accountDao.save(account) when: "PBS processes cookie sync request" @@ -364,6 +397,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain error" def bidderStatus = response.getBidderUserSync(bidderName) assert bidderStatus.error == "Rejected by CCPA" + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder filtered"() { @@ -420,8 +456,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request should reflect error even when response is full by PBS config limit"() { given: "PBS config with expanded limit" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with coop-sync and without bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -442,6 +478,9 @@ class CookieSyncSpec extends BaseSpec { assert bogusBidderStatus?.error == "Unsupported bidder" assert bogusBidderStatus?.noCookie == null assert bogusBidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should reflect error even when response is full by request limit"() { @@ -525,8 +564,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync should be able to define cookie family name"() { given: "PBS bidder config with defined cookie family name" def bidder = BOGUS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value]) + def pbsConfig = PBS_CONFIG + ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -544,13 +583,17 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.userSync?.type == USER_SYNC_TYPE assert bidderStatus?.userSync?.supportCORS == CORS_SUPPORT assert bidderStatus?.noCookie == true + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync should be able to read custom cookie family name from uids cookie"() { given: "PBS bidder config with defined cookie family name" def bidder = BOGUS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG + - ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.usersync.cookie-family-name": bidder.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -568,6 +611,9 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus.error == "Already in sync" assert bidderStatus?.userSync == null assert bidderStatus?.noCookie == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with unknown bidder respond with an error for that bidder"() { @@ -599,8 +645,8 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request with bidder without cookie family name should emit an error"() { given: "PBS bidder config without cookie family name" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.usersync.cookie-family-name": null]) + def pbsConfig = ["adapters.${GENERIC.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -613,12 +659,15 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "No sync config" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with disabled bidder should emit an error"() { given: "PBS config with disabled bidder" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.enabled": "false"]) + def pbsConfig = ["adapters.${GENERIC.value}.enabled": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -631,13 +680,16 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "Disabled bidder" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with enabled coop-sync should sync all enabled bidders"() { given: "PBS config with expanded limit" def countOfEnabledBidders = 3 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": countOfEnabledBidders.toString()] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": countOfEnabledBidders.toString()] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with coop-sync and without bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -650,14 +702,18 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain all 3 enabled bidders" assert response.bidderStatus.size() == countOfEnabledBidders + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with alias bidder should sync as the source bidder when alias doesn't override cookie-family-name"() { given: "PBS config with alias bidder without cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -677,14 +733,18 @@ class CookieSyncSpec extends BaseSpec { assert mainBidderStatus?.userSync?.type == USER_SYNC_TYPE assert mainBidderStatus?.userSync?.supportCORS == CORS_SUPPORT assert mainBidderStatus?.noCookie == true + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with alias bidder should sync independently when alias provide cookie-family-name"() { given: "PBS config with alias bidder with cookie family name" def bidderAlias = ALIAS - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG - + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", - "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": bidderAlias.value]) + def pbsConfig = PBS_CONFIG + + ["adapters.${GENERIC.value}.aliases.${bidderAlias.value}.enabled" : "true", + "adapters.${GENERIC.value}.aliases.${bidderAlias.value}.usersync.cookie-family-name": bidderAlias.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -702,14 +762,17 @@ class CookieSyncSpec extends BaseSpec { assert it.userSync?.supportCORS == CORS_SUPPORT assert it.noCookie == true } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie should return bidder sync with host cookie uid when there is no uids cookie"() { given: "PBS bidders config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : GENERIC.value, - "host-cookie.cookie-name": cookieName] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : GENERIC.value, + "host-cookie.cookie-name": cookieName] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def uidsCookie = UidsCookie.defaultUidsCookie @@ -727,14 +790,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain uid from cookies" def bidderStatus = response.getBidderUserSync(GENERIC) assert HttpUtil.decodeUrl(bidderStatus.userSync?.url).contains("uid=${uid}") + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie should return bidder sync with host cookie uid when uids are different"() { given: "PBS bidders config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : GENERIC.value, - "host-cookie.cookie-name": cookieName] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : GENERIC.value, + "host-cookie.cookie-name": cookieName] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def uidsCookie = UidsCookie.defaultUidsCookie.tap { @@ -754,14 +820,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain uid from cookies" def bidderStatus = response.getBidderUserSync(GENERIC) assert HttpUtil.decodeUrl(bidderStatus.userSync?.url).contains("uid=${hostCookieUid}") + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie should return an error when host cookie uid matches uids cookie uid for bidder"() { given: "PBS bidders config" def cookieName = PBSUtils.randomString - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : GENERIC.value, - "host-cookie.cookie-name": cookieName] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : GENERIC.value, + "host-cookie.cookie-name": cookieName] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -783,13 +852,16 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "Already in sync" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request with host cookie shouldn't return bidder sync when host cookie doesn't match requested bidder"() { given: "PBS bidders config" - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : PBSUtils.randomString, - "host-cookie.cookie-name": PBSUtils.randomString] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : PBSUtils.randomString, + "host-cookie.cookie-name": PBSUtils.randomString] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -814,9 +886,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync request with host cookie shouldn't return bidder sync when host cookie doesn't have configured name"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["host-cookie.family" : bidderName.value, - "host-cookie.cookie-name": null] + PBS_CONFIG) + def pbsConfig = ["host-cookie.family" : bidderName.value, + "host-cookie.cookie-name": null] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request" def uidsCookie = UidsCookie.defaultUidsCookie @@ -832,6 +904,9 @@ class CookieSyncSpec extends BaseSpec { assert bidderStatus?.error == "Already in sync" assert bidderStatus?.noCookie == null assert bidderStatus?.userSync == null + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync without cookie-sync.default-limit config and with cookie sync account config limit should use limit from request"() { @@ -860,15 +935,15 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.default-limit config should use limit from cookie sync account config"() { given: "PBS bidders config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "2"] + PBS_CONFIG) + def pbsConfig = ['cookie-sync.default-limit': '2'] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def accountId = PBSUtils.randomNumber def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - bidders = [RUBICON, APPNEXUS, GENERIC] - account = accountId - debug = false + it.bidders = [RUBICON, APPNEXUS, GENERIC] + it.account = accountId + it.debug = false } and: "Save account with cookie config" @@ -882,13 +957,16 @@ class CookieSyncSpec extends BaseSpec { def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain one synced bidder" - assert response.bidderStatus.size() == accountDefaultLimit + assert response.bidderStatus.size() == 1 + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.default-limit config should use limit from request"() { given: "PBS config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "2"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": "2"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def requestLimit = 1 @@ -903,13 +981,16 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain only two synced bidder" assert response.bidderStatus.size() == requestLimit + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.default-limit config should use limit from PBS config"() { given: "PBS config" def defaultLimit = 1 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": defaultLimit.toString()] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": defaultLimit.toString()] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -922,14 +1003,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain only one synced bidder" assert response.bidderStatus.size() == defaultLimit + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.max-limit should use max-limit from PBS config"() { given: "PBS bidders config" def maxLimit = 2 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.max-limit" : maxLimit.toString(), - "cookie-sync.default-limit": "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.max-limit" : maxLimit.toString(), + "cookie-sync.default-limit": "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -943,13 +1027,16 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain only one synced bidder" assert response.bidderStatus.size() == maxLimit + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.max-limit should use max-limit from cookie sync account config"() { given: "PBS bidders config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.default-limit": "1", - "cookie-sync.max-limit" : "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.default-limit": "1", + "cookie-sync.max-limit" : "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 3 bidders" def accountId = PBSUtils.randomNumber @@ -981,9 +1068,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.pri and enabled coop-sync in config should sync bidder which present in cookie-sync.pri config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.coop-sync.default": "true", - "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.coop-sync.default": "true", + "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -998,14 +1085,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.pri and disabled coop-sync in config shouldn't sync bidder which present in cookie-sync.pir config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.coop-sync.default": "false", - "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.coop-sync.default": "false", + "cookie-sync.pri" : bidderName.value] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1023,9 +1113,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.pri and in all places disabled coop sync in account shouldn't sync bidder which present in cookie-sync.pir config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber @@ -1046,13 +1136,13 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't contain generic bidder which present in cookie-sync.pri config" assert !response.getBidderUserSync(bidderName) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync should sync bidder by limit value"() { - given: "PBS config with bidders usersync config" - def prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) - - and: "Default cookie sync request with 2 bidders and limit of 1" + given: "Default cookie sync request with 2 bidders and limit of 1" def limit = 1 def bidders = [GENERIC, RUBICON] def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1174,9 +1264,9 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with cookie-sync.pri and enabled coop sync should sync bidder which present in cookie-sync.pri"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with coop-sync" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1191,21 +1281,24 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with pri and enabled coop sync in cookie sync account should sync bidder which present in pir account config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : "null", - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : "null", + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - bidders = null - coopSync = null - account = accountId + it.bidders = null + it.coopSync = null + it.account = accountId } and: "Save account with cookie config" @@ -1221,14 +1314,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with coop-sync.default config and pri in cookie sync account should sync bidder which present in pir account config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : "null", - "cookie-sync.coop-sync.default": "true"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : "null", + "cookie-sync.coop-sync.default": "true"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber @@ -1251,21 +1347,24 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.pri and enabled coop sync in account should sync bidder which present in cookie-sync.pir config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def accountId = PBSUtils.randomNumber def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - bidders = null - coopSync = null - account = accountId + it.bidders = null + it.coopSync = null + it.account = accountId } and: "Save account with cookie config" @@ -1281,14 +1380,17 @@ class CookieSyncSpec extends BaseSpec { def genericBidder = response.getBidderUserSync(bidderName) assert genericBidder?.userSync?.url assert genericBidder?.userSync?.type + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with cookie-sync.pri and disabled coop-sync in request shouldn't sync bidder which present in cookie-sync.pri config"() { given: "PBS bidders config" def bidderName = GENERIC - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.pri" : bidderName.value, - "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG) + def pbsConfig = ["cookie-sync.pri" : bidderName.value, + "cookie-sync.coop-sync.default": "false"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request without coop-sync and bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1301,6 +1403,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't contain generic bidder" assert !response.getBidderUserSync(bidderName) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync with filter setting should reject bidder sync"() { @@ -1348,16 +1453,16 @@ class CookieSyncSpec extends BaseSpec { def "PBS cookie sync with ccpa should reject bidder sync"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.${GENERIC.value}.ccpa-enforced": "true"] + GENERIC_CONFIG) + def pbsConfig = ["adapters.${GENERIC.value}.ccpa-enforced": "true"] + GENERIC_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Flush metrics" flushMetrics(prebidServerService) and: "Cookie sync request with account and privacy" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { - account = PBSUtils.randomString - usPrivacy = new CcpaConsent(optOutSale: ENFORCED) + it.account = PBSUtils.randomString + it.usPrivacy = new CcpaConsent(optOutSale: ENFORCED) } and: "Save account config into DB" @@ -1372,14 +1477,17 @@ class CookieSyncSpec extends BaseSpec { then: "Response should contain error" def bidderStatus = response.getBidderUserSync(GENERIC) assert bidderStatus.error == "Rejected by CCPA" + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync should emit error when requested bidder rejected by limit"() { given: "PBS config with bidders usersync config" def limit = 1 - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.max-limit" : limit as String, - "cookie-sync.default-limit": limit as String] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.max-limit" : limit as String, + "cookie-sync.default-limit": limit as String] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 2 bidders" def bidders = [GENERIC, RUBICON] @@ -1398,13 +1506,16 @@ class CookieSyncSpec extends BaseSpec { def rejectedBidderUserSyncs = getRejectedBidderUserSyncs(response) assert rejectedBidderUserSyncs.size() == bidders.size() - limit assert rejectedBidderUserSyncs.every { it.value == "limit reached" } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync shouldn't emit error limit reached when bidder coop-synced"() { given: "PBS config with bidders usersync config" - def prebidServerService = pbsServiceFactory.getService( - ["cookie-sync.max-limit" : "1", - "cookie-sync.default-limit": "1"] + PBS_CONFIG) + def pbsConfig = ["cookie-sync.max-limit" : "1", + "cookie-sync.default-limit": "1"] + PBS_CONFIG + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default cookie sync request with 2 bidders" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { @@ -1417,6 +1528,9 @@ class CookieSyncSpec extends BaseSpec { then: "Response shouldn't contain generic bidder" assert !response.getBidderUserSync(GENERIC) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS cookie sync request should successful pass when request body empty"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy index 662f9423848..c9ff3d005d3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CurrencySpec.groovy @@ -26,6 +26,10 @@ class CurrencySpec extends BaseSpec { pbsService = pbsServiceFactory.getService(PbsConfig.currencyConverterConfig) } + def cleanupSpec() { + pbsServiceFactory.removeContainer(PbsConfig.currencyConverterConfig) + } + def "PBS should return currency rates"() { when: "PBS processes bidders params request" def response = pbsService.withWarmup().sendCurrencyRatesRequest() diff --git a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy index ea169ad00ee..22dd16b2b9a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy @@ -14,6 +14,7 @@ import org.prebid.server.functional.model.request.auction.StoredBidResponse import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature @@ -33,6 +34,14 @@ class DebugSpec extends BaseSpec { private static final String ACCOUNT_DEBUG_REQUESTS_METRIC = "account.%s.debug_requests" private static final String REQUEST_OK_WEB_METRICS = "requests.ok.openrtb2-web" + private static final PrebidServerService enabledDebugPbsService = pbsServiceFactory.getService("adapters.generic.debug.allow": "true") + private static final PrebidServerService disabledDebugPbsService = pbsServiceFactory.getService("adapters.generic.debug.allow": "false") + + def cleanupSpec() { + pbsServiceFactory.removeContainer("adapters.generic.debug.allow": "true") + pbsServiceFactory.removeContainer("adapters.generic.debug.allow": "false") + } + def "PBS should return debug information and emit metrics when debug flag is #debug and test flag is #test"() { given: "Default BidRequest with test flag" def bidRequest = BidRequest.defaultBidRequest @@ -92,15 +101,12 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = false"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "false"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = disabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug?.httpcalls @@ -112,15 +118,12 @@ class DebugSpec extends BaseSpec { } def "PBS should return debug information when bidder-level setting debug.allowed = true"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "true"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = enabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should contain ext.debug" assert response.ext?.debug?.httpcalls[GENERIC.value] @@ -130,10 +133,7 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = false is overridden by account-level setting debug-allowed = false"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "false"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED @@ -142,7 +142,7 @@ class DebugSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = disabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug @@ -160,10 +160,7 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = false is overridden by account-level setting debug-allowed = true"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "false"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED @@ -172,7 +169,7 @@ class DebugSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = disabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug?.httpcalls @@ -189,10 +186,7 @@ class DebugSpec extends BaseSpec { } def "PBS should not return debug information when bidder-level setting debug.allowed = true is overridden by account-level setting debug-allowed = false"() { - given: "Pbs config" - def pbsService = pbsServiceFactory.getService(["adapters.generic.debug.allow": "true"]) - - and: "Default basic generic BidRequest" + given: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest bidRequest.ext.prebid.debug = ENABLED @@ -202,7 +196,7 @@ class DebugSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = enabledDebugPbsService.sendAuctionRequest(bidRequest) then: "Response should not contain ext.debug" assert !response.ext?.debug @@ -230,7 +224,7 @@ class DebugSpec extends BaseSpec { def "PBS should return debug information when bidder-level setting debug.allowed = #debugAllowedConfig and account-level setting debug-allowed = #debugAllowedAccount is overridden by x-pbs-debug-override header"() { given: "PBS with debug configuration" - def pbsService = pbsServiceFactory.getService(pbdConfig) + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic generic BidRequest" def bidRequest = BidRequest.defaultBidRequest @@ -250,8 +244,11 @@ class DebugSpec extends BaseSpec { and: "Response should not contain ext.warnings" assert !response.ext?.warnings + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: - debugAllowedConfig | debugAllowedAccount | pbdConfig + debugAllowedConfig | debugAllowedAccount | pbsConfig false | true | ["debug.override-token" : overrideToken, "adapters.generic.debug.allow": "false"] true | false | ["debug.override-token" : overrideToken, diff --git a/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy index 46b0ff2a5aa..b4d266cd456 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/EidsSpec.groovy @@ -159,9 +159,9 @@ class EidsSpec extends BaseSpec { def "PBs eid permissions should affect only specified on source"() { given: "PBs with openx bidder" - def pbsService = pbsServiceFactory.getService( - ["adapters.openx.enabled" : "true", - "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()]) + def pbsConfig = ["adapters.openx.enabled" : "true", + "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with eidpremissions and openx bidder" def eidSource = PBSUtils.randomString @@ -186,13 +186,16 @@ class EidsSpec extends BaseSpec { and: "Openx bidder should contain two eids" assert bidderRequests[OPENX.value].user.eids.sort().last.sort() == eids.sort() + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBs eid permissions for non existing source should not stop auction"() { given: "PBs with openx bidder" - def pbsService = pbsServiceFactory.getService( - ["adapters.openx.enabled" : "true", - "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()]) + def pbsConfig = ["adapters.openx.enabled" : "true", + "adapters.openx.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with eidpremissions and openx bidder" def firstEid = new Eid(source: PBSUtils.randomString, uids: [new Uid(id: PBSUtils.randomString)]) @@ -215,6 +218,9 @@ class EidsSpec extends BaseSpec { bidderRequests.user.eids.each { assert it.sort() == [secondEid, firstEid].sort() } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBs missing bidders in eid permissions should throw an error"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy index 1d36b8beadc..7640a98bead 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/FilterMultiFormatSpec.groovy @@ -20,12 +20,25 @@ import static org.prebid.server.functional.model.response.auction.MediaType.NULL class FilterMultiFormatSpec extends BaseSpec { - def "PBS should respond with all requested media types when default adapters multi format is true in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "true") + private static final Map ENABLED_MULTI_FORMAT = ["adapter-defaults.ortb.multiformat-supported": "true"] + private static final Map DISABLED_MULTI_FORMAT = ["adapter-defaults.ortb.multiformat-supported": "false"] + private static final Map DISABLED_MULTI_FORMAT_DEFAULT = [ + "adapter-defaults.ortb.multiformat-supported": "false", + "adapters.generic.ortb.multiformat-supported": "false" + ] + + private static def enabledMultiFormatPbsService = pbsServiceFactory.getService(ENABLED_MULTI_FORMAT) + private static def disabledMultiFormatPbsService = pbsServiceFactory.getService(DISABLED_MULTI_FORMAT) + private static def disabledMultiFormatDefaultPbsService = pbsServiceFactory.getService(DISABLED_MULTI_FORMAT_DEFAULT) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(ENABLED_MULTI_FORMAT) + pbsServiceFactory.removeContainer(DISABLED_MULTI_FORMAT) + pbsServiceFactory.removeContainer(DISABLED_MULTI_FORMAT_DEFAULT) + } - and: "Default bid request with banner and audio type" + def "PBS should respond with all requested media types when default adapters multi format is true in config and preferred media type specified at account level"() { + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -37,7 +50,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -46,11 +59,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with all requested media types when default adapters multi format is true in config and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "true") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -58,7 +67,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -73,11 +82,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when default adapters multi format is false in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -89,7 +94,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -98,11 +103,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when default adapters multi format is false in config and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -110,7 +111,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -125,11 +126,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with all requested media type when multi format is true in config and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "true") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -137,7 +134,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -152,11 +149,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with all requested media type when multi format is true in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "true") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -168,7 +161,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + enabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain all requested media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -177,11 +170,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when multi format is false in config and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -193,7 +182,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -202,11 +191,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with one requested preferred media type when multi format is false in config and preferred media type preferred at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -214,7 +199,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain only requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -229,11 +214,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with warning and don't make a bidder call when multi format at request and preferred media type specified at account level with non requested media type"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type" + given: "Default bid request with audio and nativeObj type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -246,7 +227,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS shouldn't make bidder request" assert !bidder.getBidderRequests(bidRequest.id) @@ -258,11 +239,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with warning and don't make a bidder call when multi format at request and preferred media type specified at request level with non requested media type"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" + given: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -271,7 +248,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS shouldn't make bidder request" assert !bidder.getBidderRequests(bidRequest.id) @@ -289,11 +266,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and preferred media type specified at account level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type" + given: "Default bid request with audio and nativeObj type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -305,7 +278,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" def bidderRequests = bidder.getBidderRequests(bidRequest.id) @@ -316,11 +289,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and preferred media type specified at request level"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" + given: "Default bid request with audio and nativeObj type and preferredMediaType BANNER" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = null imp[0].audio = Audio.defaultAudio @@ -328,7 +297,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" def bidderRequests = bidder.getBidderRequests(bidRequest.id) @@ -345,11 +314,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and multi format is false and preferred media type specified at request level with null"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.getDefaultBanner() imp[0].audio = Audio.defaultAudio @@ -357,7 +322,7 @@ class FilterMultiFormatSpec extends BaseSpec { } when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -373,11 +338,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS shouldn't respond with warning and make a bidder call when request doesn't contain multi format and multi format is false and preferred media type specified at account level with null"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.getDefaultBanner() imp[0].audio = Audio.defaultAudio @@ -389,7 +350,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = disabledMultiFormatPbsService.sendAuctionRequest(bidRequest) then: "PBS should make bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -399,12 +360,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should respond with preferred media type that specified in request when preferred media type specified in both places"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false", - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with banner and audio type" + given: "Default bid request with banner and audio type" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].banner = Banner.defaultBanner imp[0].audio = Audio.defaultAudio @@ -417,7 +373,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatDefaultPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain requested preferred media type" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -432,12 +388,7 @@ class FilterMultiFormatSpec extends BaseSpec { } def "PBS should not preferred media type specified at request level when it's alias bidder"() { - given: "PBS with adapter configuration" - def pbsService = pbsServiceFactory.getService( - "adapter-defaults.ortb.multiformat-supported": "false", - "adapters.generic.ortb.multiformat-supported": "false") - - and: "Default bid request with alias" + given: "Default bid request with alias" def bidRequest = BidRequest.defaultBidRequest.tap { imp[0].tap { banner = Banner.defaultBanner @@ -459,7 +410,7 @@ class FilterMultiFormatSpec extends BaseSpec { accountDao.save(account) when: "PBS processes auction request" - pbsService.sendAuctionRequest(bidRequest) + disabledMultiFormatDefaultPbsService.sendAuctionRequest(bidRequest) then: "Bidder request should contain preferred media type from account config" def bidderRequest = bidder.getBidderRequest(bidRequest.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy index 3d19d9d878d..808d16ccb04 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy @@ -23,6 +23,7 @@ import static org.prebid.server.functional.util.privacy.model.State.QUEBEC class GeoSpec extends BaseSpec { + // TODO refactor containers for this spec private static final String GEO_LOCATION_REQUESTS = "geolocation_requests" private static final String GEO_LOCATION_FAIL = "geolocation_fail" private static final String GEO_LOCATION_SUCCESSFUL = "geolocation_successful" diff --git a/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy index 4a0229122b6..4c9e42bb888 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/HttpSettingsSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.UidsCookie +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.mock.services.httpsettings.HttpAccountsResponse import org.prebid.server.functional.model.request.amp.AmpRequest diff --git a/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy index 7a2f5923d56..2a00b09ce85 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/ImpRequestSpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.bidder.Generic import org.prebid.server.functional.model.bidder.Openx +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.StoredImp import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp @@ -25,9 +26,13 @@ import static org.prebid.server.functional.testcontainers.Dependencies.getNetwor class ImpRequestSpec extends BaseSpec { - private final PrebidServerService defaultPbsServiceWithAlias = pbsServiceFactory.getService(GENERIC_ALIAS_CONFIG) + private static final PrebidServerService defaultPbsServiceWithAlias = pbsServiceFactory.getService(GENERIC_ALIAS_CONFIG) private static final String EMPTY_ID = "" + def cleanupSpec() { + pbsServiceFactory.removeContainer(GENERIC_ALIAS_CONFIG) + } + def "PBS should update imp fields when imp.ext.prebid.imp contain bidder information"() { given: "Default basic BidRequest" def extPmp = Pmp.defaultPmp diff --git a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy index ee3e808a56e..7225bd170de 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy @@ -2,6 +2,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountMetricsConfig +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Dooh @@ -17,13 +18,17 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class MetricsSpec extends BaseSpec { - private final PrebidServerService softPrebidService = pbsServiceFactory.getService(['auction.strict-app-site-dooh': 'false']) + private static final PrebidServerService softPrebidService = pbsServiceFactory.getService(['auction.strict-app-site-dooh': 'false']) def setup() { flushMetrics(defaultPbsService) flushMetrics(softPrebidService) } + def cleanupSpec() { + pbsServiceFactory.removeContainer(['auction.strict-app-site-dooh': 'false']) + } + def "PBS should not populate account metric when verbosity level is none"() { given: "Default basic BidRequest with generic bidder" def bidRequest = BidRequest.defaultBidRequest diff --git a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy index 21bb80df135..213aeacf64d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/OrtbConverterSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.auction.Audio import org.prebid.server.functional.model.request.auction.BidRequest @@ -36,11 +37,18 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class OrtbConverterSpec extends BaseSpec { private final static String ORTB_PROPERTY_VERSION = "adapters.generic.ortb-version" + private static final Map ORTB_2_6 = [(ORTB_PROPERTY_VERSION): "2.6"] + private static final Map ORTB_2_5 = [(ORTB_PROPERTY_VERSION): "2.5"] @Shared - PrebidServerService prebidServerServiceWithNewOrtb = pbsServiceFactory.getService([(ORTB_PROPERTY_VERSION): "2.6"]) + PrebidServerService prebidServerServiceWithNewOrtb = pbsServiceFactory.getService(ORTB_2_6) @Shared - PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService([(ORTB_PROPERTY_VERSION): "2.5"]) + PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService(ORTB_2_5) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(ORTB_2_5) + pbsServiceFactory.removeContainer(ORTB_2_6) + } def "PBS shouldn't move regs.{gdpr,usPrivacy} to regs.ext.{gdpr,usPrivacy} when adapter support ortb 2.6"() { given: "Default bid request with regs object" diff --git a/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy index db67f6ce397..1f0994c912d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/SchainSpec.groovy @@ -23,8 +23,18 @@ class SchainSpec extends BaseSpec { rid = PBSUtils.randomString } + private static final Map SCHAIN_NODE_CONFIG = ["auction.host-schain-node": encode(GLOBAL_SUPPLY_SCHAIN_NODE)] + private static final Map ORTB_2_5_CONFIG = ["adapters.generic.ortb-version": "2.5"] + + @Shared + PrebidServerService prebidServerService = pbsServiceFactory.getService(SCHAIN_NODE_CONFIG) @Shared - PrebidServerService prebidServerService = pbsServiceFactory.getService(["auction.host-schain-node": encode(GLOBAL_SUPPLY_SCHAIN_NODE)]) + PrebidServerService prebidServerServiceWithElderOrtb = pbsServiceFactory.getService(ORTB_2_5_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(SCHAIN_NODE_CONFIG) + pbsServiceFactory.removeContainer(ORTB_2_5_CONFIG) + } def "Global schain node should be appended when only ext.prebid.schains exists"() { given: "Basic bid request" @@ -158,10 +168,7 @@ class SchainSpec extends BaseSpec { } def "PBS should use source.ext.schain when ext.prebid.schains.bidder isn't requested"() { - given: "Pbs config" - def defaultPbsService = pbsServiceFactory.getService([("adapters.generic.ortb-version"): "2.5"]) - - and: "Default basic BidRequest with schain obj" + given: "Default basic BidRequest with schain obj" def supplyChain = SupplyChain.defaultSupplyChain def bidRequest = BidRequest.defaultBidRequest.tap { source = new Source(ext: new SourceExt(schain: supplyChain)) @@ -169,7 +176,7 @@ class SchainSpec extends BaseSpec { } when: "PBS processes auction request" - defaultPbsService.sendAuctionRequest(bidRequest) + prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) then: "Bidder request should contain requested source.ext.schain" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -178,10 +185,7 @@ class SchainSpec extends BaseSpec { } def "PBS should use ext.prebid.schains.schain instead of source.ext.chain when ext.prebid.schains.bidder is requested"() { - given: "Pbs config" - def defaultPbsService = pbsServiceFactory.getService([("adapters.generic.ortb-version"): "2.5"]) - - and: "Default basic BidRequest with schain obj" + given: "Default basic BidRequest with schain obj" def supplyChain = SupplyChain.defaultSupplyChain def bidRequest = BidRequest.defaultBidRequest.tap { source = new Source(ext: new SourceExt(schain: SupplyChain.defaultSupplyChain)) @@ -189,7 +193,7 @@ class SchainSpec extends BaseSpec { } when: "PBS processes auction request" - defaultPbsService.sendAuctionRequest(bidRequest) + prebidServerServiceWithElderOrtb.sendAuctionRequest(bidRequest) then: "Bidder request should contain requested ext.prebid.schains[*].schain" def bidderRequest = bidder.getBidderRequest(bidRequest.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy index 02adb2ab5e5..8a8e5f9cbcf 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/SeatNonBidSpec.groovy @@ -147,7 +147,8 @@ class SeatNonBidSpec extends BaseSpec { def "PBS should populate seatNonBid when returnAllBidStatus=true and requested bidder responded with not secure status code"() { given: "PBS with secure-markup enforcement" - def pbsService = pbsServiceFactory.getService(["auction.validations.secure-markup": ENFORCE.value]) + def pbsConfig = ["auction.validations.secure-markup": ENFORCE.value] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "A bid request with secure and returnAllBidStatus flags set" def bidRequest = requestWithAllBidStatus.tap { @@ -177,6 +178,9 @@ class SeatNonBidSpec extends BaseSpec { and: "PBS response shouldn't contain seatBid" assert !response.seatbid + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate seatNonBid when returnAllBidStatus=true and bidder successfully bids"() { @@ -258,7 +262,8 @@ class SeatNonBidSpec extends BaseSpec { def "PBS should populate seatNonBid when bidder is rejected due to timeout"() { given: "PBS config with min and max time-out" def timeout = 50 - def pbsService = pbsServiceFactory.getService(["auction.biddertmax.min": timeout as String]) + def pbsConfig = ["auction.biddertmax.min": timeout as String] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default bid request with max timeout" def bidRequest = requestWithAllBidStatus.tap { @@ -282,13 +287,16 @@ class SeatNonBidSpec extends BaseSpec { assert seatNonBid.seat == BidderName.GENERIC assert seatNonBid.nonBid[0].impId == bidRequest.imp[0].id assert seatNonBid.nonBid[0].statusCode == ERROR_TIMED_OUT + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should populate seatNonBid when filter-imp-media-type=true and imp doesn't contain supported media type"() { given: "Pbs config" - def pbsService = pbsServiceFactory.getService( - ["auction.filter-imp-media-type.enabled" : "true", - "adapters.generic.meta-info.site-media-types": "banner"]) + def pbsConfig = ["auction.filter-imp-media-type.enabled" : "true", + "adapters.generic.meta-info.site-media-types": "banner"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with banner" def bidRequest = BidRequest.defaultVideoRequest.tap { @@ -309,6 +317,9 @@ class SeatNonBidSpec extends BaseSpec { and: "seatbid should be empty" assert response.seatbid.isEmpty() + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS shouldn't populate seatNonBid when returnAllBidStatus=true and storedAuctionResponse present"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy index 0b6f62923c7..ea4a19f8c91 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/StoredResponseSpec.groovy @@ -18,7 +18,11 @@ import static org.prebid.server.functional.model.bidder.BidderName.GENERIC class StoredResponseSpec extends BaseSpec { - private final PrebidServerService pbsService = pbsServiceFactory.getService(["cache.default-ttl-seconds.banner": ""]) + private static final PrebidServerService pbsService = pbsServiceFactory.getService(EMPTY_CACHE_TTL_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(EMPTY_CACHE_TTL_CONFIG) + } @PendingFeature def "PBS should not fail auction with storedAuctionResponse when request bidder params doesn't satisfy json-schema"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy index cff45989db1..fe246682e8b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TimeoutSpec.groovy @@ -24,6 +24,10 @@ class TimeoutSpec extends BaseSpec { @Shared PrebidServerService prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) + def cleanupSpec() { + pbsServiceFactory.removeContainer(PBS_CONFIG) + } + def "PBS should apply timeout from stored request when it's not specified in the auction request"() { given: "Default basic BidRequest with generic bidder" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -287,9 +291,9 @@ class TimeoutSpec extends BaseSpec { def "PBS should choose min timeout form config for bidder request when in request value lowest that in auction.biddertmax.min"() { given: "PBS config with percent" def minBidderTmax = PBSUtils.getRandomNumber(MIN_TIMEOUT, MAX_TIMEOUT) - def prebidServerService = pbsServiceFactory.getService( - ["auction.biddertmax.min": minBidderTmax as String, - "auction.biddertmax.max": MAX_TIMEOUT as String]) + def pbsConfig = ["auction.biddertmax.min": minBidderTmax as String, + "auction.biddertmax.max": MAX_TIMEOUT as String] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest" def timeout = PBSUtils.getRandomNumber(0, minBidderTmax) @@ -306,6 +310,9 @@ class TimeoutSpec extends BaseSpec { and: "PBS response should contain tmax from request" assert bidResponse?.ext?.tmaxrequest == timeout as Long + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should change timeout for bidder due to percent in auction.biddertmax.percent"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy index ea2bbebb67e..279d408ef83 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/TopicsHeaderSpec.groovy @@ -15,8 +15,13 @@ class TopicsHeaderSpec extends BaseSpec { private static final DEFAULT_SEGTAX_VALUE = 599 private static final PRIVACY_SENDBOX_DOMAIN = "privacy-sandbox-domain" - private final PrebidServerService prebidServerServiceWithTopicsDomain - = pbsServiceFactory.getService(["auction.privacysandbox.topicsdomain": PRIVACY_SENDBOX_DOMAIN]) + private static final Map TOPICS_DOMAIN_CONFIG = ["auction.privacysandbox.topicsdomain": PRIVACY_SENDBOX_DOMAIN] + + private static final PrebidServerService prebidServerServiceWithTopicsDomain = pbsServiceFactory.getService(TOPICS_DOMAIN_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(TOPICS_DOMAIN_CONFIG) + } def "PBS should populate user.data when Sec-Browsing-Topics header present in request"() { given: "Default basic BidRequest with generic bidder" diff --git a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy index eb988ac130b..cd4545ec6b0 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.request.auction.Source +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP @@ -14,20 +15,33 @@ import static org.prebid.server.functional.model.request.auction.DistributionCha class UUIDSpec extends BaseSpec { - def "PBS auction should generate UUID for APP BidRequest id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) + private static final Map STORED_REQUEST_ID_GEN_ENABLED_CONFIG = [ + "settings.generate-storedrequest-bidrequest-id": "true" + ] - and: "Flush metrics" - flushMetrics(pbsService) + private static final Map STORED_REQUEST_ID_GEN_DISABLED_CONFIG = [ + "settings.generate-storedrequest-bidrequest-id": "false" + ] + + private static final PrebidServerService storedRequestIdGenEnabledService = pbsServiceFactory.getService(STORED_REQUEST_ID_GEN_ENABLED_CONFIG) + private static final PrebidServerService storedRequestIdGenDisabledService = pbsServiceFactory.getService(STORED_REQUEST_ID_GEN_DISABLED_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(STORED_REQUEST_ID_GEN_ENABLED_CONFIG) + pbsServiceFactory.removeContainer(STORED_REQUEST_ID_GEN_DISABLED_CONFIG) + } - and: "Default bid request with stored request and id" + def "PBS auction should generate UUID for APP BidRequest id and merge StoredRequest when bidRequestId = #bidRequestId"() { + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { id = bidRequestId ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(pbsService) + and: "Save storedRequest into DB with cur and id" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(id: PBSUtils.randomString, cur: currencies) @@ -49,10 +63,10 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.id != bidRequestId where: - bidRequestId | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + bidRequestId | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } def "PBS auction shouldn't generate UUID for BidRequest id when BidRequest doesn't have APP"() { @@ -81,11 +95,8 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.id == bidRequestId } - def "PBS amp should generate UUID for BidRequest id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Default AMP request with custom Id" + def "PBS amp should generate UUID for BidRequest id and merge StoredRequest when bidRequestId = #bidRequestId"() { + given: "Default AMP request with custom Id" def ampRequest = AmpRequest.defaultAmpRequest.tap { tagId = bidRequestId } @@ -106,25 +117,22 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.id != bidRequestId where: - bidRequestId | generateBidRequestId - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + bidRequestId | pbsService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } - def "PBS auction should generate UUID for source.tid and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Flush metrics" - flushMetrics(pbsService) - - and: "Default bid request with stored request and id" + def "PBS auction should generate UUID for source.tid and merge StoredRequest when sourceTid= #sourceTid"() { + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { source = new Source(tid: sourceTid) ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(pbsService) + and: "Save storedRequest into DB with cur and source.tid" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(cur: currencies, source: new Source(tid: PBSUtils.randomString)) @@ -146,17 +154,14 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.source.tid != sourceTid where: - sourceTid | generateBidRequestId - null | "false" - "{{UUID}}" | "false" - PBSUtils.randomString | "true" + sourceTid | pbsService + null | storedRequestIdGenDisabledService + "{{UUID}}" | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService } - def "PBS amp should generate UUID for source.tid id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Default AMP request with custom Id" + def "PBS amp should generate UUID for source.tid id and merge StoredRequest when sourceTid = #sourceTid"() { + given: "Default AMP request with custom Id" def ampRequest = AmpRequest.defaultAmpRequest and: "Default StoredBidRequest" @@ -177,26 +182,23 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.source.tid != sourceTid where: - sourceTid | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + sourceTid | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } - def "PBS auction should generate UUID for imp[].ext.tid and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Flush metrics" - flushMetrics(pbsService) - - and: "Default bid request with stored request and id" + def "PBS auction should generate UUID for imp[].ext.tid and merge StoredRequest when impExtTid = #impExtTid"() { + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { imp[0].ext.tid = impExtTid ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(pbsService) + and: "Save storedRequest into DB with cur and source.tid" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(cur: currencies) @@ -218,17 +220,14 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.imp[0].ext.tid != impExtTid where: - impExtTid | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + impExtTid | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } - def "PBS amp should generate UUID for imp[].ext.tid id and merge StoredRequest when generate-storedrequest-bidrequest-id = #generateBidRequestId"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": (generateBidRequestId)]) - - and: "Default AMP request with custom Id" + def "PBS amp should generate UUID for imp[].ext.tid id and merge StoredRequest when impExtTid = #impExtTid"() { + given: "Default AMP request with custom Id" def ampRequest = AmpRequest.defaultAmpRequest and: "Default StoredBidRequest" @@ -249,17 +248,14 @@ class UUIDSpec extends BaseSpec { assert bidderRequest.imp[0].ext.tid != impExtTid where: - impExtTid | generateBidRequestId - null | "false" - PBSUtils.randomString | "true" - "{{UUID}}" | "false" + impExtTid | pbsService + null | storedRequestIdGenDisabledService + PBSUtils.randomString | storedRequestIdGenEnabledService + "{{UUID}}" | storedRequestIdGenDisabledService } def "PBS should generate UUID for empty imp[].id when generate-storedrequest-bidrequest-id = true"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": "true"]) - - and: "Default bid request with stored request and id" + given: "Default bid request with stored request and id" def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { imp[1] = Imp.defaultImpression.tap { it.id = null @@ -267,7 +263,7 @@ class UUIDSpec extends BaseSpec { } when: "Requesting PBS auction" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = storedRequestIdGenEnabledService.sendAuctionRequest(bidRequest) then: "BidResponse should generate UUID for imp[].id" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -275,13 +271,7 @@ class UUIDSpec extends BaseSpec { } def "PBS auction should re-assign UUID for all imp[].id and merge StoredRequest when imp[].id not different and generate-storedrequest-bidrequest-id = true"() { - given: "PBS config with settings.generate-storedrequest-bidrequest-id" - def pbsService = pbsServiceFactory.getService(["settings.generate-storedrequest-bidrequest-id": "true"]) - - and: "Flush metrics" - flushMetrics(pbsService) - - and: "Default bid request with stored request and id" + given: "Default bid request with stored request and id" def storedRequestId = PBSUtils.randomString def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { def imp = Imp.defaultImpression.tap { @@ -292,6 +282,9 @@ class UUIDSpec extends BaseSpec { ext.prebid.storedRequest = new PrebidStoredRequest(id: storedRequestId) } + and: "Flush metrics" + flushMetrics(storedRequestIdGenEnabledService) + and: "Save storedRequest into DB with cur and source.tid" def currencies = [Currency.BOGUS] def storedBidRequest = new BidRequest(cur: currencies) @@ -299,10 +292,10 @@ class UUIDSpec extends BaseSpec { storedRequestDao.save(storedRequest) when: "Requesting PBS auction" - def bidResponse = pbsService.sendAuctionRequest(bidRequest) + def bidResponse = storedRequestIdGenEnabledService.sendAuctionRequest(bidRequest) then: "Metric stored_requests_found should be updated" - def metrics = pbsService.sendCollectedMetricsRequest() + def metrics = storedRequestIdGenEnabledService.sendCollectedMetricsRequest() assert metrics["stored_requests_found"] == 1 and: "BidResponse should be merged with stored request" diff --git a/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy index b4111e551fb..ee17f1f8ebb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/UserSyncSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.HttpUtil import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -12,14 +13,32 @@ import static org.prebid.server.functional.testcontainers.Dependencies.networkSe class UserSyncSpec extends BaseSpec { - private static final Map GENERIC_USERSYNC_CONFIG = ["adapters.${GENERIC.value}.usersync.${IFRAME.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.${GENERIC.value}.usersync.${IFRAME.value}.support-cors": "false"] + private static final Map BASE_USERSYNC_CONFIG = [ + "adapters.${GENERIC.value}.usersync.${IFRAME.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.${GENERIC.value}.usersync.${IFRAME.value}.support-cors": "false" + ] + + private static final Map USERSYNC_DISABLED_CONFIG = BASE_USERSYNC_CONFIG + [ + "adapters.${GENERIC.value}.usersync.enabled": "false" + ] + + private static final Map USERSYNC_ENABLED_CONFIG = BASE_USERSYNC_CONFIG + [ + "adapters.${GENERIC.value}.usersync.enabled": "true" + ] + + private static final PrebidServerService userSyncDisabledService = pbsServiceFactory.getService(USERSYNC_DISABLED_CONFIG) + private static final PrebidServerService userSyncEnabledService = pbsServiceFactory.getService(USERSYNC_ENABLED_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(USERSYNC_DISABLED_CONFIG) + pbsServiceFactory.removeContainer(USERSYNC_ENABLED_CONFIG) + } def "PBS should return usersync url with '#formatParam' format parameter for #userSyncFormat when format-override absent"() { given: "Pbs config with usersync.#userSyncFormat" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"]) + def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default CookieSyncRequest" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -32,18 +51,21 @@ class UserSyncSpec extends BaseSpec { assert bidderStatus?.userSync?.type == userSyncFormat assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "f") == formatParam + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: - userSyncFormat || formatParam - REDIRECT || PIXEL.name - IFRAME || BLANK.name + userSyncFormat | formatParam + REDIRECT | PIXEL.name + IFRAME | BLANK.name } def "PBS should return overridden usersync url format for #userSyncFormat usersync when format-override is #formatOverride"() { given: "Pbs config with usersync.#userSyncFormat and iframe.format-override: #formatOverride" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.generic.usersync.${userSyncFormat.value}.support-cors" : "false", - "adapters.generic.usersync.${userSyncFormat.value}.format-override": formatOverride.value]) + def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.generic.usersync.${userSyncFormat.value}.support-cors" : "false", + "adapters.generic.usersync.${userSyncFormat.value}.format-override": formatOverride.value] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default CookieSyncRequest" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -56,20 +78,23 @@ class UserSyncSpec extends BaseSpec { assert bidderStatus?.userSync?.type == userSyncFormat assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "f") == formatOverride.name + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: - userSyncFormat || formatOverride - REDIRECT || BLANK - REDIRECT || PIXEL - IFRAME || BLANK - IFRAME || PIXEL + userSyncFormat | formatOverride + REDIRECT | BLANK + REDIRECT | PIXEL + IFRAME | BLANK + IFRAME | PIXEL } def "PBS should return empty uid in usersync url when uid macro is not present in config"() { given: "Pbs config with usersync.#userSyncFormat.url" - def prebidServerService = pbsServiceFactory.getService( - ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), - "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false", - "adapters.generic.usersync.${userSyncFormat.value}.uid-macro" : null]) + def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(), + "adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false", + "adapters.generic.usersync.${userSyncFormat.value}.uid-macro" : null] + def prebidServerService = pbsServiceFactory.getService(pbsConfig) and: "Default CookieSyncRequest" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -81,13 +106,16 @@ class UserSyncSpec extends BaseSpec { def bidderStatus = response.getBidderUserSync(GENERIC) assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "uid").isEmpty() + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: userSyncFormat << [REDIRECT, IFRAME] } def "PBS cookie sync should sync bidder by default when bidder.usersync.enabled not overridden"() { given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG) + def prebidServerService = pbsServiceFactory.getService(BASE_USERSYNC_CONFIG) and: "Default Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest @@ -98,18 +126,17 @@ class UserSyncSpec extends BaseSpec { then: "Response should contain synced bidder" assert response.getBidderUserSync(GENERIC) assert response.bidderStatus.size() == 1 + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(BASE_USERSYNC_CONFIG) } def "PBS cookie sync should sync bidder when bidder.usersync.enabled=true"() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "true"]) - - and: "Default Cookie sync request" + given: "Default Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncEnabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain synced bidder" assert response.getBidderUserSync(GENERIC) @@ -117,15 +144,11 @@ class UserSyncSpec extends BaseSpec { } def "PBS cookie sync shouldn't sync bidder and emit error when bidder.usersync.enabled=false"() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "false"]) - - and: "Default Cookie sync request" + given: "Default Cookie sync request" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncDisabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain bidder with error" def bidderStatus = response.getBidderUserSync(GENERIC) @@ -135,18 +158,14 @@ class UserSyncSpec extends BaseSpec { } def "PBS cookie sync shouldn't coop-sync bidder when coop-sync=true and bidder.usersync.enabled=false "() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "false"]) - - and: "Cookie sync request without bidders and coop-sync=true" + given: "Cookie sync request without bidders and coop-sync=true" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { bidders = null coopSync = true } when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncDisabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain bidder with error" def bidderStatus = response.getBidderUserSync(GENERIC) @@ -156,18 +175,14 @@ class UserSyncSpec extends BaseSpec { } def "PBS cookie sync should coop-sync bidder when coop-sync=true and bidder.usersync.enabled=true "() { - given: "PBS bidder config" - def prebidServerService = pbsServiceFactory.getService(GENERIC_USERSYNC_CONFIG - + ["adapters.${GENERIC.value}.usersync.enabled": "true"]) - - and: "Cookie sync request without bidders and coop-sync=true" + given: "Cookie sync request without bidders and coop-sync=true" def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { bidders = null coopSync = true } when: "PBS processes cookie sync request without cookies" - def response = prebidServerService.sendCookieSyncRequest(cookieSyncRequest) + def response = userSyncEnabledService.sendCookieSyncRequest(cookieSyncRequest) then: "Response should contain bidder" assert response.getBidderUserSync(GENERIC) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index 1582f3b200d..1b3b4407b0b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -1,21 +1,21 @@ 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 import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.auction.FetchStatus import org.prebid.server.functional.model.request.auction.TraceLevel import org.prebid.server.functional.model.response.auction.AnalyticResult +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus 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 @@ -33,6 +33,7 @@ import static org.prebid.server.functional.model.response.auction.ResponseAction class AbTestingModuleSpec extends ModuleBaseSpec { + private final static String NOOP_METRIC = "modules.module.%s.stage.%s.hook.%s.success.noop" private final static String NO_INVOCATION_METRIC = "modules.module.%s.stage.%s.hook.%s.success.no-invocation" private final static String CALL_METRIC = "modules.module.%s.stage.%s.hook.%s.call" private final static String EXECUTION_ERROR_METRIC = "modules.module.%s.stage.%s.hook.%s.execution-error" @@ -45,15 +46,13 @@ 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 static final PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings()) - private static final PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG) + private static final PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) def cleanupSpec() { - pbsServiceFactory.removeContainer(getOrtb2BlockingSettings()) - pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG) + pbsServiceFactory.removeContainer(getModuleBaseSettings(ModuleName.ORTB2_BLOCKING)) } def "PBS shouldn't apply a/b test config when config of ab test is disabled"() { @@ -64,7 +63,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 { @@ -91,8 +90,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -100,7 +100,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" @@ -111,7 +111,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) @@ -131,10 +131,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be with error call" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert metrics[EXECUTION_ERROR_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[EXECUTION_ERROR_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 @@ -154,7 +152,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) @@ -175,8 +173,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for specified module should be as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 + assert metrics[NOOP_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 + assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 @@ -195,10 +194,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 { @@ -218,8 +217,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].sort() - it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].sort() + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -229,8 +228,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.RUN] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.RUN] it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -243,8 +242,7 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for allowed to run response-correction module should be updated based on ab test config" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] + assert metrics[NOOP_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] } @@ -256,10 +254,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 { @@ -279,8 +277,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -290,8 +288,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -300,13 +298,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 and: "Metric for skipped response-correction module should be updated based on ab test config" assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 } def "PBS should apply a/b test config for each module when multiple config are presents with different percentage"() { @@ -317,10 +311,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 { @@ -340,8 +334,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -351,8 +345,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_ACTION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.RUN] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.RUN] it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -365,7 +359,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] } def "PBS should ignore accounts property for a/b test config when ab test config specialize for specific account"() { @@ -377,7 +370,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 }] } @@ -394,8 +387,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -414,7 +407,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 }] @@ -432,8 +425,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].sort() - it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].sort() + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -441,8 +434,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -463,7 +454,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 }] @@ -481,8 +472,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -506,7 +497,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 }] @@ -528,8 +519,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -553,7 +544,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 }] @@ -576,8 +567,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten().sort() == [ORTB2_BLOCKING, AB_TESTING, AB_TESTING].value.sort() - it.analyticsTags.activities.status.flatten().sort() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS].sort() - it.analyticsTags.activities.results.status.flatten().sort() == [FetchStatus.SUCCESS_ALLOW, FetchStatus.RUN, FetchStatus.RUN].sort() + it.analyticsTags.activities.status.flatten().sort() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten().sort() == [AnalyticTagStatus.SUCCESS_ALLOW, AnalyticTagStatus.RUN, AnalyticTagStatus.RUN].sort() it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -585,8 +576,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -606,7 +595,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 @@ -625,8 +614,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -651,7 +640,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 @@ -694,7 +683,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 @@ -721,8 +710,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = ortbModulePbsService.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] @@ -742,7 +729,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) }] } @@ -769,10 +756,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 }] } @@ -795,8 +782,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -816,9 +803,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -832,7 +816,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 }] } @@ -858,8 +842,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -879,9 +863,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -891,10 +872,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 { @@ -922,8 +903,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -933,8 +914,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS] it.action == [NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } @@ -942,13 +923,9 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 and: "Metric for skipped response-correction module should be updated based on ab test config" assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert !metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] - assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 assert metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 cleanup: "Stop and remove pbs container" @@ -958,7 +935,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 }] } @@ -982,8 +959,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.action == [NO_ACTION, NO_ACTION] it.analyticsTags.activities.name.flatten() == [ORTB2_BLOCKING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SUCCESS_ALLOW] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SUCCESS_ALLOW] it.analyticsTags.activities.results.values.module.flatten().every { it == null } } @@ -1000,17 +977,12 @@ class AbTestingModuleSpec extends ModuleBaseSpec { def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1 - assert metrics[CALL_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1 assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(ModuleName.ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -1020,7 +992,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 }] } @@ -1029,7 +1001,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)] @@ -1051,8 +1023,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS, SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION, NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING, AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED, FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -1072,9 +1044,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 2 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 2 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" @@ -1083,7 +1052,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) } @@ -1100,7 +1069,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 }] } @@ -1120,8 +1089,8 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.status == [SUCCESS, SUCCESS] it.action == [NO_INVOCATION, NO_INVOCATION] it.analyticsTags.activities.name.flatten() == [AB_TESTING, AB_TESTING].value - it.analyticsTags.activities.status.flatten() == [FetchStatus.SUCCESS, FetchStatus.SUCCESS] - it.analyticsTags.activities.results.status.flatten() == [FetchStatus.SKIPPED, FetchStatus.SKIPPED] + it.analyticsTags.activities.status.flatten() == [AnalyticTagStatus.SUCCESS, AnalyticTagStatus.SUCCESS] + it.analyticsTags.activities.results.status.flatten() == [AnalyticTagStatus.SKIPPED, AnalyticTagStatus.SKIPPED] it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.ORTB2_BLOCKING, ModuleName.ORTB2_BLOCKING] } @@ -1141,9 +1110,6 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Metric for non specified module should be as default call" assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - assert metrics[CALL_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] == 1 - - assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] assert !metrics[NO_INVOCATION_METRIC.formatted(PB_RESPONSE_CORRECTION.code, ALL_PROCESSED_BID_RESPONSES.metricValue, RESPONSE_CORRECTION_ALL_PROCESSED_RESPONSES.code)] cleanup: "Stop and remove pbs container" 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 23316766a7d..8aa26625f5f 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,8 +40,8 @@ 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 static final PrebidServerService pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG) @@ -145,7 +144,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 { @@ -153,10 +152,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) { @@ -166,7 +165,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 @@ -301,7 +300,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 { @@ -309,10 +308,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) { @@ -322,7 +321,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 @@ -336,7 +335,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 { @@ -344,16 +343,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)] @@ -369,8 +368,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 { @@ -383,16 +382,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)] @@ -408,7 +407,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 { @@ -421,10 +420,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) { @@ -434,7 +433,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 @@ -450,7 +449,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 { @@ -463,16 +462,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)] @@ -495,7 +494,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 { @@ -508,10 +507,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) { @@ -521,7 +520,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 c0933a238e7..e2e08fd662e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy @@ -1,30 +1,84 @@ 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.model.response.auction.AnalyticResult import org.prebid.server.functional.model.response.auction.BidResponse -import org.prebid.server.functional.model.response.auction.InvocationResult +import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.BaseSpec import org.prebid.server.functional.util.PBSUtils +import spock.lang.Shared -import static org.prebid.server.functional.model.ModuleName.OPTABLE_TARGETING -import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING -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.ModuleName.PB_REQUEST_CORRECTION -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.bidder.BidderName.AMX +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC +import static org.prebid.server.functional.model.bidder.BidderName.IX +import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION -import static org.prebid.server.functional.model.config.Stage.ALL_PROCESSED_BID_RESPONSES -import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST +import static org.prebid.server.functional.model.config.ModuleHookImplementation.PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES +import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGETING +import static org.prebid.server.functional.model.config.ModuleName.ORTB2_BLOCKING +import static org.prebid.server.functional.model.config.ModuleName.PB_REQUEST_CORRECTION +import static org.prebid.server.functional.model.config.ModuleName.PB_RESPONSE_CORRECTION +import static org.prebid.server.functional.model.config.ModuleName.PB_RICHMEDIA_FILTER +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer +import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID class ModuleBaseSpec extends BaseSpec { + protected static final String WILDCARD = '*' + protected static final String RANDOM_DATACENTER_REGION = PBSUtils.randomString + + protected static final Map GENERIC_CONFIG = [ + "adapters.${GENERIC.value}.usersync.redirect.url" : "$networkServiceContainer.rootUri/generic-usersync".toString(), + "adapters.${GENERIC.value}.usersync.redirect.support-cors": 'false', + "adapters.${GENERIC.value}.meta-info.vendor-id" : GENERIC_VENDOR_ID.toString()] + + protected static final Map IX_CONFIG = ["adapters.${IX}.enabled" : "true", + "adapters.${IX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + protected static final Map AMX_CONFIG = ["adapters.${AMX}.enabled" : "true", + "adapters.${AMX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + protected static final Map OPENX_CONFIG = ["adapters.${OPENX}.enabled" : "true", + "adapters.${OPENX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + + protected static final Map OPENX_ALIAS_CONFIG = ["adapters.${OPENX}.aliases.${OPENX_ALIAS}.enabled" : "true", + "adapters.${OPENX}.aliases.${OPENX_ALIAS}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] + + private static final Map ENABLED_DEBUG_LOG_MODE = ["logging.level.root": "debug"] + + private static final Map ORTB_ADAPTER_CONFIG = ['adapter-defaults.ortb.multiformat-supported': 'false'] + + private static final Map MODIFYING_VAST_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false", + "adapters.generic.modifying-vast-xml-allowed": "false"] + + private static final Map CACHE_STORAGE_CONFIG = ['storage.pbc.path' : "$networkServiceContainer.rootUri/stored-cache".toString(), + 'storage.pbc.call-timeout-ms': '1000', + 'storage.pbc.enabled' : 'true', + 'cache.module.enabled' : 'true', + 'pbc.api.key' : PBSUtils.randomString, + 'cache.api-key-secured' : 'false'] + + protected final static Map EXTERNAL_MODULES_CONFIG = getModuleBaseSettings(PB_RICHMEDIA_FILTER) + + getModuleBaseSettings(PB_RESPONSE_CORRECTION) + + getModuleBaseSettings(ORTB2_BLOCKING) + + getModuleBaseSettings(PB_REQUEST_CORRECTION) + + getOptableTargetingSettings() + + getRulesEngineSettings() + + @Shared + protected static PrebidServerService pbsServiceWithMultipleModules + def setupSpec() { prebidCache.setResponse() bidder.setResponse() + pbsServiceWithMultipleModules = pbsServiceFactory.getService(getDefaultMultipleModulesConfig()) } def cleanupSpec() { @@ -33,59 +87,63 @@ 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 Map getDefaultMultipleModulesConfig() { + ['datacenter-region': RANDOM_DATACENTER_REGION] + + EMPTY_CACHE_TTL_CONFIG + + EXTERNAL_MODULES_CONFIG + + ENABLED_DEBUG_LOG_MODE + + ORTB_ADAPTER_CONFIG + + MODIFYING_VAST_CONFIG + + CACHE_STORAGE_CONFIG + + GENERIC_CONFIG + + IX_CONFIG + + AMX_CONFIG + + OPENX_CONFIG + + OPENX_ALIAS_CONFIG } - protected static Map getRichMediaFilterSettings(String scriptPattern, - Boolean filterMraidEnabled = true, - Endpoint endpoint = OPENRTB2_AUCTION) { + 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) { ["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] + protected static Map getOptableTargetingSettings(boolean isEnabled = true) { + ["hooks.${OPTABLE_TARGETING.code}.enabled" : isEnabled as String, + "hooks.modules.${OPTABLE_TARGETING.code}.api-endpoint": "$networkServiceContainer.rootUri/stored-cache".toString(), + "hooks.modules.${OPTABLE_TARGETING.code}.tenant" : PBSUtils.randomString, + "hooks.modules.${OPTABLE_TARGETING.code}.origin" : PBSUtils.randomString] .collectEntries { key, value -> [(key.toString()): value.toString()] } } - protected static Map getOptableTargetingSettings(boolean isEnabled = true, Endpoint endpoint = OPENRTB2_AUCTION) { - ["hooks.${OPTABLE_TARGETING.code}.enabled": isEnabled as String, - "hooks.modules.${OPTABLE_TARGETING.code}.api-endpoint" : "$networkServiceContainer.rootUri/stored-cache".toString(), - "hooks.modules.${OPTABLE_TARGETING.code}.tenant" : PBSUtils.randomString, - "hooks.modules.${OPTABLE_TARGETING.code}.origin" : PBSUtils.randomString, - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, [(PROCESSED_AUCTION_REQUEST): [OPTABLE_TARGETING]]))] - .collectEntries { key, value -> [(key.toString()): value.toString()] } - } - - protected static Map getOrtb2BlockingSettings(boolean isEnabled = true) { - ["hooks.${ORTB2_BLOCKING.code}.enabled": isEnabled as String] - } - - protected static Map getRequestCorrectionSettings(Endpoint endpoint = OPENRTB2_AUCTION, Stage stage = PROCESSED_AUCTION_REQUEST) { - ["hooks.${PB_REQUEST_CORRECTION.code}.enabled": "true", - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, PB_REQUEST_CORRECTION, [stage]))] - } - - protected static Map getRulesEngineSettings(Endpoint endpoint = OPENRTB2_AUCTION, Stage stage = PROCESSED_AUCTION_REQUEST) { + protected static Map getRulesEngineSettings() { ["hooks.${PB_RULE_ENGINE.code}.enabled" : "true", "hooks.${PB_RULE_ENGINE.code}.rule-cache.expire-after-minutes" : "10000", "hooks.${PB_RULE_ENGINE.code}.rule-cache.max-size" : "20000", "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-initial-delay-millis": "10000", "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-max-delay-millis" : "10000", "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-factor" : "1.2", - "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-jitter" : "1.2", - "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, PB_RULE_ENGINE, [stage]))] + "hooks.${PB_RULE_ENGINE.code}.rule-parsing.retry-exponential-jitter" : "1.2"] + .collectEntries { key, value -> [(key.toString()): value.toString()] } + } + + protected static Account getAccountWithModuleConfig(String accountId, + List modulesHooks, + Endpoint endpoint = OPENRTB2_AUCTION) { + + 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 List getAnalyticResults(BidResponse response) { 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 82355a47996..6e29a4a2f1f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy @@ -13,14 +13,15 @@ import org.prebid.server.functional.model.request.auction.FetchStatus import org.prebid.server.functional.model.request.auction.PrebidAnalytics import org.prebid.server.functional.model.request.auction.RichmediaFilter import org.prebid.server.functional.model.request.auction.StoredBidResponse +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ModuleActivityName import org.prebid.server.functional.service.PrebidServerService 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,12 +31,6 @@ import static org.prebid.server.functional.model.response.auction.ErrorType.PREB class AnalyticsTagsModuleSpec extends ModuleBaseSpec { - private static final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(getOrtb2BlockingSettings()) - - def cleanupSpec() { - pbsServiceFactory.removeContainer(getOrtb2BlockingSettings()) - } - 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 { @@ -50,7 +45,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 @@ -59,12 +54,12 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.ORTB2_BLOCKING and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_ALLOW + it.status == AnalyticTagStatus.SUCCESS_ALLOW it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } @@ -109,15 +104,18 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.REJECT_RICHMEDIA and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_BLOCK + it.status == AnalyticTagStatus.SUCCESS_BLOCK it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(getRichMediaFilterSettings(PATTERN_NAME)) } def "PBS should include analytics tag in response when request and default account allow client details"() { @@ -127,7 +125,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" @@ -145,12 +143,12 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.ORTB2_BLOCKING and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_ALLOW + it.status == AnalyticTagStatus.SUCCESS_ALLOW it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } @@ -166,7 +164,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" @@ -191,12 +189,12 @@ class AnalyticsTagsModuleSpec extends ModuleBaseSpec { and: "Analytics tag should contain results with name and success status" def analyticResult = analyticsTagPrebid.analyticsTags.activities.first - assert analyticResult.status == FetchStatus.SUCCESS + assert analyticResult.status == AnalyticTagStatus.SUCCESS assert analyticResult.name == ModuleActivityName.ORTB2_BLOCKING and: "Should include appliedTo information in analytics tags results" verifyAll(analyticResult.results.first) { - it.status == FetchStatus.SUCCESS_ALLOW + it.status == AnalyticTagStatus.SUCCESS_ALLOW it.appliedTo.bidders == [GENERIC.value] it.appliedTo.impIds == bidRequest.imp.id } @@ -242,7 +240,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 @@ -265,7 +263,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 @@ -289,7 +287,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/optabletargeting/CacheStorageSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy index 9a71d42ba7f..3d551a00139 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy @@ -3,6 +3,7 @@ package org.prebid.server.functional.tests.module.optabletargeting import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.IdentifierType +import org.prebid.server.functional.model.config.ModuleHookImplementation import org.prebid.server.functional.model.config.OperatingSystem import org.prebid.server.functional.model.config.OptableTargetingConfig import org.prebid.server.functional.model.config.PbsModulesConfig @@ -14,14 +15,14 @@ import org.prebid.server.functional.model.request.auction.Eid import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.PublicCountryIp import org.prebid.server.functional.model.request.auction.User -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.scaffolding.StoredCache import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils import static org.apache.commons.codec.binary.Base64.encodeBase64 import static org.mockserver.model.HttpStatusCode.NOT_FOUND_404 -import static org.prebid.server.functional.model.ModuleName.OPTABLE_TARGETING +import static org.prebid.server.functional.model.config.ModuleHookImplementation.OPTABLE_TARGETING_PROCESSED_AUCTION_REQUEST +import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGETING import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer class CacheStorageSpec extends ModuleBaseSpec { @@ -36,23 +37,10 @@ class CacheStorageSpec extends ModuleBaseSpec { private static final StoredCache storedCache = new StoredCache(networkServiceContainer) - private static final Map CACHE_STORAGE_CONFIG = ['storage.pbc.path' : "$networkServiceContainer.rootUri/stored-cache".toString(), - 'storage.pbc.call-timeout-ms': '1000', - 'storage.pbc.enabled' : 'true', - 'cache.module.enabled' : 'true', - 'pbc.api.key' : PBSUtils.randomString, - 'cache.api-key-secured' : 'false'] - private static final Map MODULE_STORAGE_CACHE_CONFIG = getOptableTargetingSettings() + CACHE_STORAGE_CONFIG - private static final PrebidServerService prebidServerStoredCacheService = pbsServiceFactory.getService(MODULE_STORAGE_CACHE_CONFIG) - def setup() { storedCache.reset() } - def cleanupSpec() { - pbsServiceFactory.removeContainer(MODULE_STORAGE_CACHE_CONFIG) - } - def "PBS should update error metrics when no cached requests present"() { given: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -65,13 +53,13 @@ class CacheStorageSpec extends ModuleBaseSpec { accountDao.save(account) and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update metrics for new saved text storage cache" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_READ_ERR] == 1 and: "No updates for success metrics" @@ -96,13 +84,13 @@ class CacheStorageSpec extends ModuleBaseSpec { storedCache.setCachingResponse(NOT_FOUND_404) and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update error metrics" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_WRITE_ERR] == 1 and: "No updates for success metrics" @@ -111,7 +99,7 @@ class CacheStorageSpec extends ModuleBaseSpec { def "PBS should update metrics for new saved text storage cache when no cached requests"() { given: "Current value of metric prebid cache" - def okInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_OK) + def okInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_OK) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -128,13 +116,13 @@ class CacheStorageSpec extends ModuleBaseSpec { storedCache.setCachingResponse() and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update metrics for new saved text storage cache" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_SIZE_TEXT] == new String(encodeBase64(encode(targetingResult).bytes)).size() assert metrics[METRIC_CREATIVE_WRITE_OK] == okInitialValue + 1 @@ -144,11 +132,11 @@ class CacheStorageSpec extends ModuleBaseSpec { def "PBS should update metrics for stored cached requests cache when proper record present"() { given: "Current value of metric prebid cache" - def textInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_SIZE_TEXT) - def ttlInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_TTL_TEXT) - def writeInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_OK) - def readErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_READ_ERR) - def writeErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_ERR) + def textInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_SIZE_TEXT) + def ttlInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_TTL_TEXT) + def writeInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_OK) + def readErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_READ_ERR) + def writeErrorInitialValue = getCurrentMetricValue(pbsServiceWithMultipleModules, METRIC_CREATIVE_WRITE_ERR) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -165,13 +153,13 @@ class CacheStorageSpec extends ModuleBaseSpec { storedCache.setCachingResponse() and: "Flash metrics" - flushMetrics(prebidServerStoredCacheService) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - prebidServerStoredCacheService.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should update metrics for stored cached requests" - def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[METRIC_CREATIVE_READ_OK] == 1 and: "No updates for new saved text storage metrics" @@ -199,9 +187,8 @@ class CacheStorageSpec extends ModuleBaseSpec { private static Account createAccountWithRequestCorrectionConfig(BidRequest bidRequest, OptableTargetingConfig optableTargetingConfig) { - def pbsModulesConfig = new PbsModulesConfig(optableTargeting: optableTargetingConfig) - def accountHooksConfig = new AccountHooksConfiguration(modules: pbsModulesConfig) - def accountConfig = new AccountConfig(hooks: accountHooksConfig) - new Account(uuid: bidRequest.accountId, config: accountConfig) + getAccountWithModuleConfig(bidRequest.accountId, [OPTABLE_TARGETING_PROCESSED_AUCTION_REQUEST]).tap { + it.config.hooks.modules.optableTargeting = optableTargetingConfig + } } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy index a7a97bc8816..e4d04a6695b 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,28 +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 static final Map PBS_CONFIG = getOrtb2BlockingSettings() + IX_CONFIG + - ['adapter-defaults.ortb.multiformat-supported': 'false'] - - private static final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(PBS_CONFIG) - - def cleanupSpec() { - pbsServiceFactory.removeContainer(PBS_CONFIG) - } - def "PBS should send original array ortb2 attribute to bidder when enforce blocking is disabled"() { given: "Default bid request with proper ortb attribute" def bidRequest = getBidRequestForOrtbAttribute(attributeName) @@ -83,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) @@ -122,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) @@ -152,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) @@ -197,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) @@ -243,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) @@ -282,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 @@ -315,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 @@ -357,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 @@ -397,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 @@ -463,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 @@ -501,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() @@ -548,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 @@ -579,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 @@ -622,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 @@ -653,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 @@ -689,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 @@ -730,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() @@ -774,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 @@ -822,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 @@ -872,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 @@ -926,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() @@ -969,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 @@ -1018,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) @@ -1061,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) @@ -1110,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 @@ -1147,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 @@ -1186,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 @@ -1221,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 @@ -1256,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 @@ -1299,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) @@ -1349,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) @@ -1392,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) @@ -1437,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 @@ -1473,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) @@ -1515,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 @@ -1531,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 1f6bbcaf13d..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,12 +27,6 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec { private static final String ANDROID = "android" private static final String IOS = "IOS" - private static final PrebidServerService pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(getRequestCorrectionSettings()) - - def cleanupSpec() { - pbsServiceFactory.removeContainer(getRequestCorrectionSettings()) - } - def "PBS should remove positive instl from imps for android app when request correction is enabled for account"() { given: "Android APP bid request with version lover then version threshold" def prebid = new AppPrebid(source: PBSUtils.getRandomCase(PREBID_MOBILE), version: ACCEPTABLE_DEVICE_INSTL_VERSION_THRESHOLD) @@ -47,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) @@ -80,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) @@ -108,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) @@ -138,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) @@ -167,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) @@ -189,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) @@ -211,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) @@ -241,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) @@ -261,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) @@ -289,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) @@ -319,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) @@ -348,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) @@ -377,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) @@ -398,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) @@ -419,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) @@ -441,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/pbruleengine/RuleEngineAliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy index 4477e6d9d38..b07003a0fbb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineAliasSpec.groovy @@ -2,7 +2,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.request.auction.Imp -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -11,7 +11,7 @@ import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineAliasSpec extends RuleEngineBaseSpec { @@ -35,7 +35,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.size() == 1 @@ -97,7 +97,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -157,7 +157,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seat" assert bidResponse.seatbid.seat == [ALIAS] @@ -219,7 +219,7 @@ class RuleEngineAliasSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy index d27d44e0fc0..1ac39666347 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineBaseSpec.groovy @@ -3,10 +3,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.bidder.Generic import org.prebid.server.functional.model.bidder.Openx -import org.prebid.server.functional.model.config.AccountConfig -import org.prebid.server.functional.model.config.AccountHooksConfiguration import org.prebid.server.functional.model.config.PbRulesEngine -import org.prebid.server.functional.model.config.PbsModulesConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.pricefloors.Country import org.prebid.server.functional.model.request.auction.Amx @@ -16,12 +13,10 @@ import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.ImpUnitCode -import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.tests.module.ModuleBaseSpec import org.prebid.server.functional.util.PBSUtils -import spock.lang.Retry -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC @@ -38,14 +33,10 @@ import static org.prebid.server.functional.model.request.auction.ImpUnitCode.PB_ import static org.prebid.server.functional.model.request.auction.ImpUnitCode.STORED_REQUEST import static org.prebid.server.functional.model.request.auction.ImpUnitCode.TAG_ID import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE -import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer -import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID -@Retry //TODO remove in 3.34+ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { protected static final List MULTI_BID_ADAPTERS = [GENERIC, OPENX, AMX].sort() - protected static final String APPLIED_FOR_ALL_IMPS = "*" protected static final String DEFAULT_CONDITIONS = "default" protected final static String CALL_METRIC = "modules.module.${PB_RULE_ENGINE.code}.stage.${PROCESSED_AUCTION_REQUEST.metricValue}.hook.${PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST.code}.call" protected final static String NOOP_METRIC = "modules.module.${PB_RULE_ENGINE.code}.stage.${PROCESSED_AUCTION_REQUEST.metricValue}.hook.${PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST.code}.success.noop" @@ -74,23 +65,6 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { "Field '$functionType.fieldName' is required and has to be an array of integers" } - protected static final Map ENABLED_DEBUG_LOG_MODE = ["logging.level.root": "debug"] - protected static final Map OPENX_CONFIG = ["adapters.${OPENX}.enabled" : "true", - "adapters.${OPENX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - protected static final Map AMX_CONFIG = ["adapters.${AMX}.enabled" : "true", - "adapters.${AMX}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - protected static final Map OPENX_ALIAS_CONFIG = ["adapters.${OPENX}.aliases.${OPENX_ALIAS}.enabled" : "true", - "adapters.${OPENX}.aliases.${OPENX_ALIAS}.endpoint": "$networkServiceContainer.rootUri/auction".toString()] - protected static final String CONFIG_DATA_CENTER = PBSUtils.randomString - private static final String USER_SYNC_URL = "$networkServiceContainer.rootUri/generic-usersync" - private static final Map GENERIC_CONFIG = [ - "adapters.${GENERIC.value}.usersync.redirect.url" : USER_SYNC_URL, - "adapters.${GENERIC.value}.usersync.redirect.support-cors": false as String, - "adapters.${GENERIC.value}.meta-info.vendor-id" : GENERIC_VENDOR_ID as String] - protected static final PrebidServerService pbsServiceWithRulesEngineModule = pbsServiceFactory.getService(GENERIC_CONFIG + - getRulesEngineSettings() + AMX_CONFIG + OPENX_CONFIG + OPENX_ALIAS_CONFIG + ['datacenter-region': CONFIG_DATA_CENTER] + - ENABLED_DEBUG_LOG_MODE) - protected static BidRequest getDefaultBidRequestWithMultiplyBidders(DistributionChannel distributionChannel = SITE) { BidRequest.getDefaultBidRequest(distributionChannel).tap { it.tmax = 5_000 // prevents timeout issues on slow pipelines @@ -118,8 +92,9 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { } protected static Account getAccountWithRulesEngine(String accountId, PbRulesEngine ruleEngine) { - def accountHooksConfiguration = new AccountHooksConfiguration(modules: new PbsModulesConfig(pbRuleEngine: ruleEngine)) - new Account(uuid: accountId, config: new AccountConfig(hooks: accountHooksConfiguration)) + getAccountWithModuleConfig(accountId, [PB_RULES_ENGINE_PROCESSED_AUCTION_REQUEST]).tap { + it.config.hooks.modules.pbRuleEngine = ruleEngine + } } protected static BidRequest createBidRequestWithDomains(DistributionChannel type, String domain, boolean usePublisher = true) { @@ -182,15 +157,15 @@ abstract class RuleEngineBaseSpec extends ModuleBaseSpec { protected static waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) { PBSUtils.waitUntil({ - pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) - pbsServiceWithRulesEngineModule.isContainLogsByValue("Successfully parsed rule-engine config for account $bidRequest.accountId") + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.isContainLogsByValue("Successfully parsed rule-engine config for account $bidRequest.accountId") }) } protected static waitUntilFailedParsedAndCacheAccount(bidRequest) { PBSUtils.waitUntil({ - pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) - pbsServiceWithRulesEngineModule.isContainLogsByValue("Failed to parse rule-engine config for account $bidRequest.accountId") + pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) + pbsServiceWithMultipleModules.isContainLogsByValue("Failed to parse rule-engine config for account $bidRequest.accountId") }) } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy index 5bea040218e..e82a78754da 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineContextSpec.groovy @@ -16,7 +16,7 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant import static org.prebid.server.functional.model.ChannelType.WEB -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX @@ -33,11 +33,11 @@ import static org.prebid.server.functional.model.pricefloors.MediaType.BANNER import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP import static org.prebid.server.functional.model.request.auction.DistributionChannel.DOOH import static org.prebid.server.functional.model.request.auction.DistributionChannel.SITE -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS import static org.prebid.server.functional.model.request.auction.ImpUnitCode.GPID import static org.prebid.server.functional.model.request.auction.ImpUnitCode.PB_AD_SLOT import static org.prebid.server.functional.model.request.auction.ImpUnitCode.STORED_REQUEST import static org.prebid.server.functional.model.request.auction.ImpUnitCode.TAG_ID +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineContextSpec extends RuleEngineBaseSpec { @@ -62,7 +62,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -122,7 +122,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -164,7 +164,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -229,7 +229,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -274,7 +274,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -293,7 +293,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, DOMAIN_IN)) where: @@ -339,7 +339,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -405,7 +405,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -468,7 +468,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -530,7 +530,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -574,7 +574,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -593,7 +593,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors then: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, BUNDLE_IN)) } @@ -620,7 +620,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -682,7 +682,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -724,7 +724,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -743,7 +743,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) then: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, MEDIA_TYPE_IN)) where: @@ -774,7 +774,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -834,7 +834,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -882,7 +882,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -953,7 +953,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -1006,7 +1006,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -1025,7 +1025,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, AD_UNIT_CODE_IN)) where: @@ -1062,7 +1062,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -1125,7 +1125,7 @@ class RuleEngineContextSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy index 8e9de1807c9..ab264a09c27 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineCoreSpec.groovy @@ -6,9 +6,10 @@ import org.prebid.server.functional.model.config.RuleSet import org.prebid.server.functional.model.config.RulesEngineModelGroup import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.request.auction.Imp +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX @@ -20,8 +21,8 @@ import static org.prebid.server.functional.model.config.RuleEngineModelRuleResul import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithLogATagResult import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST import static org.prebid.server.functional.model.pricefloors.Country.BULGARIA -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.ERROR_NO_BID import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE @@ -44,10 +45,10 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) and: "Flush metric" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Response should contain seat bid" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -63,7 +64,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors and: "PBs should populate call and update metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[CALL_METRIC] == 1 assert metrics[UPDATE_METRIC] == 1 @@ -94,7 +95,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -158,7 +159,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -211,7 +212,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.size() == 0 @@ -244,7 +245,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -277,7 +278,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat == [OPENX] @@ -337,7 +338,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seatBids" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -396,7 +397,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat == [GENERIC] @@ -454,7 +455,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -486,7 +487,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { it.values.resultFunction == groups.rules.first.results.first.function.value it.values.conditionFired == groups.rules.first.conditions.first - it.appliedTo.impIds == [APPLIED_FOR_ALL_IMPS] + it.appliedTo.impIds == [WILDCARD] } verifyAll(impResult) { @@ -513,7 +514,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Response should contain seat bid" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -577,7 +578,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Response should contain seat bid" assert bidResponse.seatbid.seat.sort() == [GENERIC, OPENX].sort() @@ -645,7 +646,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX].sort() @@ -705,7 +706,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -765,7 +766,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -796,7 +797,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { it.values.analyticsValue == analyticsValue it.values.resultFunction == LOG_A_TAG.value it.values.conditionFired == DEFAULT_CONDITIONS - it.appliedTo.impIds == [APPLIED_FOR_ALL_IMPS] + it.appliedTo.impIds == [WILDCARD] } and: "Analytics imp result shouldn't contain remove info" @@ -825,7 +826,7 @@ class RuleEngineCoreSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain two seat" assert bidResponse.seatbid.size() == 2 diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy index 229e54a0ff0..3891eafd32c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineDeviceSpec.groovy @@ -6,11 +6,10 @@ import org.prebid.server.functional.model.pricefloors.Country import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.DeviceType import org.prebid.server.functional.util.PBSUtils -import spock.lang.RepeatUntilFailure import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX @@ -20,7 +19,7 @@ import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVIC import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_TYPE import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_TYPE_IN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineDeviceSpec extends RuleEngineBaseSpec { @@ -47,7 +46,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -109,7 +108,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -151,7 +150,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -214,7 +213,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -258,7 +257,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -277,7 +276,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, DEVICE_COUNTRY_IN)) } @@ -306,7 +305,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -325,7 +324,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_INTEGERS_LOG_WARNING(bidRequest.accountId, DEVICE_TYPE_IN)) } @@ -352,7 +351,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -414,7 +413,7 @@ class RuleEngineDeviceSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy index f710ba39f93..dd7dcd2bdc6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineInfrastructureSpec.groovy @@ -6,14 +6,14 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER_IN -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { @@ -29,7 +29,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { def pbRuleEngine = createRulesEngineWithRule().tap { it.ruleSets[0].modelGroups[0].schema[0].tap { it.function = DATA_CENTER_IN - it.args = new RuleEngineFunctionArgs(countries: [CONFIG_DATA_CENTER]) + it.args = new RuleEngineFunctionArgs(countries: [RANDOM_DATACENTER_REGION]) } } @@ -41,7 +41,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -60,7 +60,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, DATA_CENTER_IN)) } @@ -72,7 +72,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { def pbRuleEngine = createRulesEngineWithRule().tap { it.ruleSets[0].modelGroups[0].schema[0].tap { it.function = DATA_CENTER_IN - it.args = new RuleEngineFunctionArgs(datacenters: [CONFIG_DATA_CENTER]) + it.args = new RuleEngineFunctionArgs(datacenters: [RANDOM_DATACENTER_REGION]) } } @@ -84,7 +84,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -144,7 +144,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -171,7 +171,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { def pbRuleEngine = createRulesEngineWithRule().tap { it.ruleSets[0].modelGroups[0].tap { schema = [new RuleEngineModelSchema(function: DATA_CENTER)] - rules[0].conditions = [CONFIG_DATA_CENTER] + rules[0].conditions = [RANDOM_DATACENTER_REGION] } } @@ -183,7 +183,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -243,7 +243,7 @@ class RuleEngineInfrastructureSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy index c4f207544b5..367027fc609 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEnginePrivacySpec.groovy @@ -14,12 +14,13 @@ import org.prebid.server.functional.model.request.auction.SiteExtData import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.model.request.auction.UserExtData +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX @@ -32,7 +33,7 @@ import static org.prebid.server.functional.model.config.RuleEngineFunction.GPP_S import static org.prebid.server.functional.model.config.RuleEngineFunction.TCF_IN_SCOPE import static org.prebid.server.functional.model.config.RuleEngineFunction.USER_FPD_AVAILABLE import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE import static org.prebid.server.functional.util.privacy.TcfConsent.GENERIC_VENDOR_ID import static org.prebid.server.functional.util.privacy.TcfConsent.PurposeId.BASIC_ADS @@ -58,7 +59,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -120,7 +121,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -167,7 +168,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -186,7 +187,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_STRINGS_LOG_WARNING(bidRequest.accountId, EID_IN)) } @@ -213,7 +214,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -275,7 +276,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -313,7 +314,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -377,7 +378,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -416,7 +417,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -492,7 +493,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -554,7 +555,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -613,7 +614,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -660,7 +661,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -679,7 +680,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_INTEGERS_LOG_WARNING(bidRequest.accountId, GPP_SID_IN)) } @@ -705,7 +706,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -770,7 +771,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -818,7 +819,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -889,7 +890,7 @@ class RuleEnginePrivacySpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy index cce9631e1b9..416590b010f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSpecialSpec.groovy @@ -5,14 +5,14 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.PERCENT import static org.prebid.server.functional.model.config.RuleEngineFunction.PREBID_KEY -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineSpecialSpec extends RuleEngineBaseSpec { @@ -40,7 +40,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -59,7 +59,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_SINGLE_INTEGER_LOG_WARNING(bidRequest.accountId, PERCENT)) } @@ -83,7 +83,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -143,7 +143,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -188,7 +188,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -207,7 +207,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, INVALID_CONFIGURATION_FOR_SINGLE_STRING_LOG_WARNING(bidRequest.accountId, PREBID_KEY)) } @@ -236,7 +236,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [GENERIC, AMX].sort() @@ -300,7 +300,7 @@ class RuleEngineSpecialSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy index 881a8211ca4..0f902b7b31b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineSyncSpec.groovy @@ -1,16 +1,17 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.UidsCookie +import org.prebid.server.functional.model.response.auction.AnalyticTagStatus import org.prebid.server.functional.util.HttpUtil -import static org.prebid.server.functional.model.ModuleName.PB_RULE_ENGINE +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult -import static org.prebid.server.functional.model.request.auction.FetchStatus.SUCCESS +import static org.prebid.server.functional.model.response.auction.AnalyticTagStatus.SUCCESS import static org.prebid.server.functional.model.response.auction.BidRejectionReason.REQUEST_BIDDER_REMOVED_BY_RULE_ENGINE_MODULE class RuleEngineSyncSpec extends RuleEngineBaseSpec { @@ -35,7 +36,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == [OPENX, AMX] @@ -92,7 +93,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -128,7 +129,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -167,7 +168,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response shouldn't contain seat" assert bidResponse.seatbid.seat == [GENERIC] @@ -227,7 +228,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest, cookieHeader) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest, cookieHeader) then: "Bid response shouldn't contain seat" assert !bidResponse.seatbid.seat @@ -277,7 +278,7 @@ class RuleEngineSyncSpec extends RuleEngineBaseSpec { accountDao.save(accountWithRulesEngine) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy index dbf7395c1f0..6cc940023b9 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/RuleEngineValidationSpec.groovy @@ -35,10 +35,10 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) and: "Flush metrics" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -57,7 +57,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBs should populate call and noop metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[CALL_METRIC] == 1 assert metrics[NOOP_METRIC] == 1 @@ -89,10 +89,10 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) and: "Flush metrics" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -111,7 +111,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBs should populate noop metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[NOOP_METRIC] == 1 } @@ -130,10 +130,10 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) and: "Flush metrics" - flushMetrics(pbsServiceWithRulesEngineModule) + flushMetrics(pbsServiceWithMultipleModules) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -149,7 +149,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS and: "PBs should populate failer metrics" - def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() + def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() assert metrics[NOOP_METRIC] == 1 } @@ -171,7 +171,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -187,7 +187,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS and: "PBs should emit failed logs" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, "Failed to parse rule-engine config for account $bidRequest.accountId:" + " Weighted list cannot be empty") } @@ -209,7 +209,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -239,7 +239,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { accountDao.save(accountWithRulesEngine) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -278,7 +278,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilSuccessfullyParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -312,7 +312,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { accountDao.save(accountWithRulesEngine) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -331,7 +331,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBs should emit failed logs" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, "Parsing rule for account $bidRequest.accountId").size() == 1 } @@ -357,7 +357,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "Bid response should contain seats" assert bidResponse.seatbid.seat.sort() == MULTI_BID_ADAPTERS @@ -376,7 +376,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !getAnalyticResults(bidResponse) and: "PBS should emit log" - def logsByTime = pbsServiceWithRulesEngineModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) assert getLogsByText(logsByTime, "Failed to parse rule-engine config for account $bidRequest.accountId:" + " Weight must be greater than zero") @@ -407,7 +407,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { waitUntilFailedParsedAndCacheAccount(bidRequest) when: "PBS processes auction request" - def bidResponse = pbsServiceWithRulesEngineModule.sendAuctionRequest(bidRequest) + def bidResponse = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBs should perform bidder request" assert bidder.getBidderRequests(bidRequest.id) @@ -426,7 +426,7 @@ class RuleEngineValidationSpec extends RuleEngineBaseSpec { assert !bidResponse.ext?.errors and: "Logs should contain error" - def logs = pbsServiceWithRulesEngineModule.getLogsByTime(startTime) + def logs = pbsServiceWithMultipleModules.getLogsByTime(startTime) assert getLogsByText(logs, "Failed to parse rule-engine config for account ${bidRequest.accountId}: " + "Function '${function.value}' configuration is invalid: No arguments allowed") diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy index 2426a3fd316..d7f105b050d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy @@ -6,7 +6,6 @@ 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 @@ -15,13 +14,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 @@ -35,15 +34,6 @@ import static org.prebid.server.functional.model.response.auction.MediaType.VIDE class ResponseCorrectionSpec extends ModuleBaseSpec { private final static int OPTIMAL_MAX_LENGTH = 20 - private static final Map PBS_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false", - "adapters.generic.modifying-vast-xml-allowed": "false"] + - getResponseCorrectionConfig() - - private static final PrebidServerService pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService(PBS_CONFIG) - - def cleanupSpec() { - pbsServiceFactory.removeContainer(PBS_CONFIG) - } def "PBS shouldn't modify response when in account correction module disabled"() { given: "Start up time" @@ -63,10 +53,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" @@ -106,10 +96,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" @@ -148,10 +138,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" @@ -183,10 +173,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) @@ -222,10 +212,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" @@ -265,10 +255,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) @@ -306,10 +296,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" @@ -343,10 +333,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" @@ -390,10 +380,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 @@ -445,10 +435,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 @@ -500,10 +490,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 @@ -548,10 +538,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 @@ -598,10 +588,10 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { accountDao.save(accountWithResponseCorrectionModule) when: "PBS processes auction request" - def response = pbsServiceWithResponseCorrectionModule.sendAuctionRequest(bidRequest) + def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest) then: "PBS should emit log" - def logsByTime = pbsServiceWithResponseCorrectionModule.getLogsByTime(start) + def logsByTime = pbsServiceWithMultipleModules.getLogsByTime(start) def bidId = bidResponse.seatbid[0].bid[0].id def responseCorrection = getLogsByText(logsByTime, bidId) assert responseCorrection.size() == 1 @@ -633,10 +623,13 @@ class ResponseCorrectionSpec extends ModuleBaseSpec { ] } - 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 517da393668..a31b16c340a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy @@ -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 @@ -34,9 +35,15 @@ class RichMediaFilterSpec extends ModuleBaseSpec { endpoints.values().first().stages.values().first().groups.first.hookSequenceSnakeCase = [new HookId(moduleCodeSnakeCase: PB_RICHMEDIA_FILTER.code, hookImplCodeSnakeCase: "${PB_RICHMEDIA_FILTER.code}-${ALL_PROCESSED_BID_RESPONSES.value}-hook")] })]).collectEntries { key, value -> [(key.toString()): value.toString()] } - private static final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) - private static final PrebidServerService pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG) - private static final PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG) + private static PrebidServerService pbsServiceWithDisabledMediaFilter + private static PrebidServerService pbsServiceWithEnabledMediaFilter + private static PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy + + def setupSpec() { + pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG) + pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG) + } def cleanupSpec() { pbsServiceFactory.removeContainer(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG) @@ -45,10 +52,7 @@ class RichMediaFilterSpec extends ModuleBaseSpec { } 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) - - and: "BidRequest with stored response" + given: "BidRequest with stored response" def storedResponseId = PBSUtils.randomNumber def bidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.returnAllBidStatus = true @@ -63,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 @@ -79,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"() { @@ -106,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" @@ -142,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" @@ -169,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 { @@ -186,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" @@ -217,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" @@ -263,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" @@ -301,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" @@ -344,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" @@ -371,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 @@ -384,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" @@ -406,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] } @@ -427,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" @@ -453,4 +451,10 @@ class RichMediaFilterSpec extends ModuleBaseSpec { where: admValue << [PATTERN_NAME, "${PBSUtils.randomString}-${PATTERN_NAME}", "${PATTERN_NAME}.${PBSUtils.randomString}"] } + + 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/pricefloors/PriceFloorsBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy index 95ef1318637..84b1202214e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy @@ -4,6 +4,7 @@ import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountAuctionConfig import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountPriceFloorsConfig +import org.prebid.server.functional.model.config.ModuleName import org.prebid.server.functional.model.config.PriceFloorsFetch import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.pricefloors.Country @@ -70,6 +71,10 @@ abstract class PriceFloorsBaseSpec extends BaseSpec { floorsProvider.setResponse() } + def cleanupSpec() { + pbsServiceFactory.removeContainer(FLOORS_CONFIG + GENERIC_ALIAS_CONFIG) + } + protected static AccountConfig getDefaultAccountConfigSettings() { def fetch = new PriceFloorsFetch(enabled: false, timeoutMs: 5000, diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy index b569514d0c4..0e9d84b29e2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsCurrencySpec.groovy @@ -167,8 +167,8 @@ class PriceFloorsCurrencySpec extends PriceFloorsBaseSpec { def "PBS should not update bidFloor, bidFloorCur for signalling when currency conversion is not available"() { given: "Pbs config with disabled conversion" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["currency-converter.external-rates.enabled": "false"]) + def pbsConfig = FLOORS_CONFIG + ["currency-converter.external-rates.enabled": "false"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "BidRequest with floorMinCur" def requestFloorCur = USD @@ -231,6 +231,9 @@ class PriceFloorsCurrencySpec extends PriceFloorsBaseSpec { ext?.prebid?.floors?.location == FETCH ext?.prebid?.floors?.fetchStatus == SUCCESS } + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should forward bidFloor and bidFloorCur for signalling when they come in the bid request"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy index cec8bb8fa41..67bbaa0324f 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsEnforcementSpec.groovy @@ -781,14 +781,14 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should suppress deal that are below the matched floor when enforce-deal-floors = true"() { given: "Pbs with PF configuration with enforceDealFloors" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.tap { enforceDealFloors = defaultAccountEnforeDealFloors enforceDealFloorsSnakeCase = defaultAccountEnforeDealFloorsSnakeCase } } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with generic bidder with preferdeals = true" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -833,6 +833,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.collect { it.id } == [bidResponse.seatbid.first().bid.last().id] assert response.seatbid.first().bid.collect { it.price } == [floorValue] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: defaultAccountEnforeDealFloors | defaultAccountEnforeDealFloorsSnakeCase | accountEnforeDealFloors | accountEnforeDealFloorsSnakeCase false | null | true | null @@ -843,11 +846,11 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should not suppress deal that are below the matched floor according to ext.prebid.floors.enforcement.enforcePBS"() { given: "Pbs with PF configuration with enforceDealFloors" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.enforceDealFloors = pbsConfigEnforceDealFloors } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default basic BidRequest with generic bidder with preferdeals = true" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -890,6 +893,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.first()?.id == bidResponse.seatbid.first().bid.first().id assert response.seatbid.first().bid.collect { it.price } == [dealBidPrice] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigEnforceDealFloors | enforcePbs | accountEnforceDealFloors | floorDeals true | null | false | true @@ -899,11 +905,11 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should suppress any bids below the matched floor when fetch.enforce-floors-rate = 100 in account config"() { given: "Pbs with PF configuration with minMaxAgeSec" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.enforceFloorsRate = pbsConfigEnforceRate } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -945,6 +951,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.first()?.id == bidResponse.seatbid.first().bid.last().id assert response.seatbid.first().bid.collect { it.price } == [floorValue] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigEnforceRate | requestEnforceRate | accountEnforceRate PBSUtils.getRandomNumber(0, 100) | null | 100 @@ -954,11 +963,11 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { def "PBS should not suppress any bids below the matched floor when fetch.enforce-floors-rate = 0 in account config"() { given: "Pbs with PF configuration with minMaxAgeSec" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.enforceFloorsRate = pbsConfigEnforceFloorsRate } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -999,6 +1008,9 @@ class PriceFloorsEnforcementSpec extends PriceFloorsBaseSpec { assert response.seatbid?.first()?.bid?.size() == 2 assert response.seatbid.first().bid.collect { it.price } == [floorValue, floorValue - 0.1] + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigEnforceFloorsRate | enforceRate | accountEnforceFloorsRate PBSUtils.getRandomNumber(0, 100) | null | 0 diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy index b40f6e8cac2..4cfdfc80097 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy @@ -57,7 +57,8 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def "PBS should activate floors feature when price-floors.enabled = true in PBS config"() { given: "Pbs with PF configuration" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + ["price-floors.enabled": "true"]) + def pbsConfig = FLOORS_CONFIG + ["price-floors.enabled": "true"] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.getDefaultBidRequest(APP) @@ -78,11 +79,15 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "PBS should signal bids" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert bidderRequest.imp[0].bidFloor + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should not activate floors feature when price-floors.enabled = false in #description config"() { given: "Pbs with PF configuration" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + ["price-floors.enabled": pbdConfigEnabled]) + def pbsConfig = FLOORS_CONFIG + ["price-floors.enabled": pbdConfigEnabled] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest" def bidRequest = BidRequest.getDefaultBidRequest(APP) @@ -104,6 +109,9 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert !bidderRequest.imp[0].bidFloor + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: description | pbdConfigEnabled | accountConfigEnabled "PBS" | "false" | true @@ -344,14 +352,15 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def "PBS should fetch data from provider when use-dynamic-data enabled"() { given: "Pbs with PF configuration with useDynamicData" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { + def accountConfig = defaultAccountConfigSettings.tap { auction.priceFloors.tap { useDynamicData = pbsConfigUseDynamicData useDynamicDataSnakeCase = pbsConfigUseDynamicDataSnakeCase } } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) + def pbsConfig = FLOORS_CONFIG + + ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) and: "Default BidRequest with ext.prebid.floors" def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { @@ -382,6 +391,9 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert bidderRequest.imp[0].bidFloor == floorValue + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) + where: pbsConfigUseDynamicData | accountUseDynamicData | pbsConfigUseDynamicDataSnakeCase | accountUseDynamicDataSnakeCase false | true | null | null diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy index b586688398b..73b462576e7 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy @@ -930,10 +930,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { } def "PBS should populate seatNonBid when bid rejected due to floor"() { - given: "PBS config with floors config" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG) - - and: "Default BidRequest" + given: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(enforcePbs: enforcePbs)) ext.prebid.returnAllBidStatus = true @@ -951,7 +948,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { floorsProvider.setResponse(bidRequest.site.publisher.id, floorsResponse) and: "PBS cache rules" - cacheFloorsProviderRules(bidRequest, floorValue, pbsService) + cacheFloorsProviderRules(bidRequest, floorValue, floorsPbsService) and: "Set bidder response" def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { @@ -960,7 +957,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = floorsPbsService.sendAuctionRequest(bidRequest) then: "PBS response should contain seatNonBid and contain errors" def seatNonBids = response.ext.seatnonbid @@ -977,10 +974,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { } def "PBS shouldn't populate seatNonBid when rejected due to floor and returnAllBidStatus is false"() { - given: "PBS config with floors config" - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG) - - and: "Default BidRequest" + given: "Default BidRequest" def bidRequest = BidRequest.defaultBidRequest.tap { ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(enforcePbs: enforcePbs)) ext.prebid.returnAllBidStatus = false @@ -998,7 +992,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { floorsProvider.setResponse(bidRequest.site.publisher.id, floorsResponse) and: "PBS cache rules" - cacheFloorsProviderRules(bidRequest, floorValue, pbsService) + cacheFloorsProviderRules(bidRequest, floorValue, floorsPbsService) and: "Set bidder response" def bidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap { @@ -1007,7 +1001,7 @@ class PriceFloorsRulesSpec extends PriceFloorsBaseSpec { bidder.setResponse(bidRequest.id, bidResponse) when: "PBS processes auction request" - def response = pbsService.sendAuctionRequest(bidRequest) + def response = floorsPbsService.sendAuctionRequest(bidRequest) then: "PBS response shouldn't contain seatNonBid and contain errors" assert !response.ext.seatnonbid diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy index b06c2530242..9a4e2501410 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy @@ -356,19 +356,12 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { } def "PBS should update imp[0].bidFloor when ext.prebid.bidadjustmentfactors is defined"() { - given: "Pbs with PF configuration with minMaxAgeSec" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { - auction.priceFloors.adjustForBidAdjustment = pbsConfigBidAdjustmentFlag - } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) - - and: "BidRequest with bidAdjustment" + given: "BidRequest with bidAdjustment" def floorsProviderFloorValue = PBSUtils.randomFloorValue BigDecimal bidAdjustment = 0.1 def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) - ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) + it.ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) + it.ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) } and: "Account with adjustForBidAdjustment in the DB" @@ -384,7 +377,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { floorsProvider.setResponse(bidRequest.app.publisher.id, floorsResponse) when: "PBS cache rules and processes auction request" - cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue / bidAdjustment, pbsService) + cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue / bidAdjustment, floorsPbsService) then: "Bidder request bidFloor should be update according to bidAdjustment" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() @@ -394,47 +387,37 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { assert !bidderRequest.imp[0].ext.prebid.floors where: - pbsConfigBidAdjustmentFlag | requestBidAdjustmentFlag | accountBidAdjustmentFlag - true | true | null - true | null | null - false | null | true + requestBidAdjustmentFlag | accountBidAdjustmentFlag + true | null + null | null + null | true } def "PBS should not update imp[0].bidFloor when bidadjustment is disallowed"() { - given: "Pbs with PF configuration with adjustForBidAdjustment" - def defaultAccountConfigSettings = defaultAccountConfigSettings.tap { - auction.priceFloors.tap { - adjustForBidAdjustment = pbsConfigBidAdjustmentFlag - adjustForBidAdjustmentSnakeCase = pbsConfigBidAdjustmentFlagSnakeCase - } - } - def pbsService = pbsServiceFactory.getService(FLOORS_CONFIG + - ["settings.default-account-config": encode(defaultAccountConfigSettings)]) - - and: "Default BidRequest" + given: "Default BidRequest" def floorsProviderFloorValue = 0.8 def bidAdjustment = 0.1 def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { - ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) - ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) + it.ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: requestBidAdjustmentFlag)) + it.ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) } and: "Account in the DB" def accountId = bidRequest.app.publisher.id def account = getAccountWithEnabledFetch(accountId).tap { - config.auction.priceFloors.adjustForBidAdjustment = accountBidAdjustmentFlag - config.auction.priceFloors.adjustForBidAdjustmentSnakeCase = accountBidAdjustmentFlagSnakeCase + it.config.auction.priceFloors.adjustForBidAdjustment = accountBidAdjustmentFlag + it.config.auction.priceFloors.adjustForBidAdjustmentSnakeCase = accountBidAdjustmentFlagSnakeCase } accountDao.save(account) and: "Set Floors Provider response" def floorsResponse = PriceFloorData.priceFloorData.tap { - modelGroups[0].values = [(rule): floorsProviderFloorValue] + it.modelGroups[0].values = [(rule): floorsProviderFloorValue] } floorsProvider.setResponse(accountId, floorsResponse) when: "PBS cache rules and processes auction request" - cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue, pbsService) + cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue, floorsPbsService) then: "Bidder request bidFloor should be changed" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() @@ -444,11 +427,56 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { assert !bidderRequest.imp[0].ext.prebid.floors where: - pbsConfigBidAdjustmentFlagSnakeCase | pbsConfigBidAdjustmentFlag | requestBidAdjustmentFlag | accountBidAdjustmentFlag | accountBidAdjustmentFlagSnakeCase - null | false | false | null | false - null | true | null | false | null - false | null | false | null | false - true | null | null | false | null + requestBidAdjustmentFlag | accountBidAdjustmentFlag | accountBidAdjustmentFlagSnakeCase + false | null | false + null | false | null + false | null | false + null | false | null + } + + def "PBS should priorities account config over default account config and update imp[0].bidFloor"() { + given: "Pbs with PF configuration with adjustForBidAdjustment" + def accountConfig = defaultAccountConfigSettings.tap { + it.auction.priceFloors.tap { + it.adjustForBidAdjustment = false + adjustForBidAdjustmentSnakeCase = null + } + } + def pbsConfig = FLOORS_CONFIG + + ["settings.default-account-config": encode(accountConfig)] + def pbsService = pbsServiceFactory.getService(pbsConfig) + + and: "BidRequest with bidAdjustment" + def floorsProviderFloorValue = PBSUtils.randomFloorValue + BigDecimal bidAdjustment = 0.1 + def bidRequest = BidRequest.getDefaultBidRequest(APP).tap { + ext.prebid.floors = new ExtPrebidFloors(enforcement: new ExtPrebidPriceFloorEnforcement(bidAdjustment: null)) + ext.prebid.bidAdjustmentFactors = new BidAdjustmentFactors(adjustments: [(GENERIC): bidAdjustment]) + } + and: "Account with adjustForBidAdjustment in the DB" + def account = getAccountWithEnabledFetch(bidRequest.app.publisher.id).tap { + config.auction.priceFloors.adjustForBidAdjustment = null + config.auction.priceFloors.adjustForBidAdjustmentSnakeCase = true + } + accountDao.save(account) + + and: "Set Floors Provider response" + def floorsResponse = PriceFloorData.priceFloorData.tap { + modelGroups[0].values = [(rule): floorsProviderFloorValue] + } + floorsProvider.setResponse(bidRequest.app.publisher.id, floorsResponse) + when: "PBS cache rules and processes auction request" + cacheFloorsProviderRules(bidRequest, floorsProviderFloorValue / bidAdjustment, pbsService) + + then: "Bidder request bidFloor should be update according to bidAdjustment" + def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() + assert bidderRequest.imp[0].bidFloor == floorsProviderFloorValue / bidAdjustment + + and: "Bidder request shouldn't include imp.ext.prebid.floors" + assert !bidderRequest.imp[0].ext.prebid.floors + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should choose most aggressive adjustment when request contains multiple media-types"() { @@ -717,10 +745,10 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Floor config with default account" def accountConfig = getDefaultAccountConfigSettings().tap { - auction.priceFloors.fetch.enabled = false - auction.priceFloors.fetch.url = BASIC_FETCH_URL + bidRequest.site.publisher.id - auction.priceFloors.fetch.maxSchemaDims = MAX_SCHEMA_DIMENSIONS_SIZE - auction.priceFloors.maxSchemaDims = MAX_SCHEMA_DIMENSIONS_SIZE + it.auction.priceFloors.fetch.enabled = false + it.auction.priceFloors.fetch.url = BASIC_FETCH_URL + bidRequest.site.publisher.id + it.auction.priceFloors.fetch.maxSchemaDims = MAX_SCHEMA_DIMENSIONS_SIZE + it.auction.priceFloors.maxSchemaDims = MAX_SCHEMA_DIMENSIONS_SIZE } def pbsFloorConfig = GENERIC_ALIAS_CONFIG + ["price-floors.enabled" : "true", "settings.default-account-config": encode(accountConfig)] 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..ebc3d3b2f23 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/CoppaSpec.groovy @@ -185,14 +185,14 @@ class CoppaSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == bidRequest.device.geo.ext bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source 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" @@ -254,7 +254,7 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -324,7 +324,7 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -389,14 +389,14 @@ class CoppaSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source 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" @@ -462,7 +462,7 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy index 717c9f32d5b..8eb190ba857 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAmpSpec.groovy @@ -565,7 +565,7 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -640,14 +640,14 @@ class GdprAmpSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source 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 299d911a398..8ccf39c1583 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GdprAuctionSpec.groovy @@ -611,7 +611,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -689,7 +689,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -765,14 +765,14 @@ class GdprAuctionSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == bidRequest.device.geo.ext bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source 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" @@ -969,7 +969,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { given: "Default bid requests with personal data" def bidRequest = bidRequestWithPersonalData.tap { regs.gdpr = 1 - user.buyeruid = null + user.buyerUid = null user.ext.consent = new TcfConsent.Builder().build() ext.prebid.trace = VERBOSE } @@ -992,7 +992,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -1038,7 +1038,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -1083,7 +1083,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { def bidderRequest = bidder.getBidderRequest(bidRequest.id) verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy index d0282d48ddd..cdf0b1e1d01 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppAuctionSpec.groovy @@ -108,7 +108,7 @@ class GppAuctionSpec extends PrivacyBaseSpec { def "PBS should emit warning when GPP string is invalid"() { given: "Default bid request with invalid gpp" - def invalidGpp = "Invalid_GPP_Consent_String" + def invalidGpp = invalidGppString def bidRequest = BidRequest.defaultBidRequest.tap { regs = new Regs(gpp: invalidGpp) } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy index 87d23a3d740..eac5f98fca5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppSyncUserActivitiesSpec.groovy @@ -591,7 +591,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { def "PBS cookie sync call when privacy module contain invalid GPP string should respond with required bidder URL and emit warning in response"() { given: "Cookie sync request with link to account" def accountId = PBSUtils.randomString - def invalidGpp = PBSUtils.randomString + def invalidGpp = invalidGppString def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap { it.gppSid = US_NAT_V1.value it.account = accountId diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy index 1db77ef0b90..ba9413a0bd7 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy @@ -898,7 +898,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain invalid GPP string shouldn't remove EIDS fields in request and emit warning in response"() { given: "Default Generic BidRequests with EIDS fields and account id" def accountId = PBSUtils.randomNumber as String - def invalidGpp = PBSUtils.randomString + def invalidGpp = invalidGppString def bidRequest = getBidRequestWithPersonalData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = invalidGpp @@ -2076,7 +2076,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = getBidRequestWithPersonalData(accountId) and: "Default amp request with link to account" - def invalidGpp = PBSUtils.randomString + def invalidGpp = invalidGppString def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId it.gppSid = US_NAT_V1.value diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy index b648a4fe91c..321cb1bef94 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 @@ -115,12 +115,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -165,7 +165,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -217,7 +217,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -293,12 +293,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -336,7 +336,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -388,12 +388,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -450,7 +450,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -510,12 +510,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -576,7 +576,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -640,12 +640,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -699,7 +699,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -758,12 +758,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.zip == bidRequest.user.geo.zip - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -816,7 +816,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.geo @@ -868,7 +868,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -919,7 +919,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1089,7 +1089,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1302,12 +1302,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.zip == bidRequest.user.geo.zip - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1334,7 +1334,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def "PBS auction call when privacy module contain invalid GPP string shouldn't remove UFPD fields in request and emit warning in response"() { given: "Default Generic BidRequests with UFPD fields and account id" def accountId = PBSUtils.randomNumber as String - def invalidGpp = PBSUtils.randomString + def invalidGpp = invalidGppString def bidRequest = getBidRequestWithPersonalData(accountId).tap { regs.gppSid = [US_NAT_V1.intValue] regs.gpp = invalidGpp @@ -1372,12 +1372,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo.zip == bidRequest.user.geo.zip - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1431,7 +1431,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1487,12 +1487,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1546,12 +1546,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1615,12 +1615,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1701,12 +1701,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1760,7 +1760,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -1842,12 +1842,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -1901,7 +1901,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2072,12 +2072,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2127,7 +2127,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2181,7 +2181,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2275,12 +2275,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2327,7 +2327,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2385,7 +2385,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2447,12 +2447,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2506,7 +2506,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2663,7 +2663,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2843,7 +2843,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -2922,12 +2922,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -2956,7 +2956,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { def ampStoredRequest = getBidRequestWithPersonalData(accountId) and: "Default amp request with link to account" - def invalidGpp = PBSUtils.randomString + def invalidGpp = invalidGppString def ampRequest = AmpRequest.defaultAmpRequest.tap { it.account = accountId it.gppSid = US_NAT_V1.value @@ -3000,12 +3000,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3067,7 +3067,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3131,12 +3131,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3198,12 +3198,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3272,12 +3272,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3342,12 +3342,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3446,12 +3446,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3514,7 +3514,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3602,12 +3602,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == ampStoredRequest.device.macmd5 bidderRequest.device.dpidmd5 == ampStoredRequest.device.dpidmd5 bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.data == ampStoredRequest.user.data bidderRequest.user.geo == ampStoredRequest.user.geo - bidderRequest.user.ext.data.buyeruid == ampStoredRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == ampStoredRequest.user.ext.data.buyerUid } and: "Generic bidder request should have data in EIDS fields" @@ -3672,7 +3672,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3837,7 +3837,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3892,7 +3892,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -3940,7 +3940,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { !bidderRequest.device.macmd5 !bidderRequest.device.dpidmd5 !bidderRequest.user.id - !bidderRequest.user.buyeruid + !bidderRequest.user.buyerUid !bidderRequest.user.yob !bidderRequest.user.gender !bidderRequest.user.data @@ -4006,12 +4006,12 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { bidderRequest.device.macmd5 == bidRequest.device.macmd5 bidderRequest.device.dpidmd5 == bidRequest.device.dpidmd5 bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.data == bidRequest.user.data bidderRequest.user.geo == bidRequest.user.geo - bidderRequest.user.ext.data.buyeruid == bidRequest.user.ext.data.buyeruid + bidderRequest.user.ext.data.buyerUid == bidRequest.user.ext.data.buyerUid } and: "Bidder request should have data in EIDS fields" diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy index 4966fe43ddf..4028fb4d05e 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/LmtSpec.groovy @@ -377,7 +377,7 @@ class LmtSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -447,7 +447,7 @@ class LmtSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -510,14 +510,14 @@ class LmtSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == bidRequest.device.geo.ext bidderRequest.user.id == bidRequest.user.id - bidderRequest.user.buyeruid == bidRequest.user.buyeruid + bidderRequest.user.buyerUid == bidRequest.user.buyerUid bidderRequest.user.yob == bidRequest.user.yob bidderRequest.user.gender == bidRequest.user.gender bidderRequest.user.eids[0].source == bidRequest.user.eids[0].source 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" @@ -583,7 +583,7 @@ class LmtSpec extends PrivacyBaseSpec { and: "Bidder request should mask user personal data" verifyAll(bidderRequest.user) { !id - !buyeruid + !buyerUid !yob !gender !eids @@ -649,14 +649,14 @@ class LmtSpec extends PrivacyBaseSpec { bidderRequest.device.geo.ext == ampStoredRequest.device.geo.ext bidderRequest.user.id == ampStoredRequest.user.id - bidderRequest.user.buyeruid == ampStoredRequest.user.buyeruid + bidderRequest.user.buyerUid == ampStoredRequest.user.buyerUid bidderRequest.user.yob == ampStoredRequest.user.yob bidderRequest.user.gender == ampStoredRequest.user.gender bidderRequest.user.eids[0].source == ampStoredRequest.user.eids[0].source 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 7d8ed79de7d..a78d1942f93 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 @@ -186,11 +186,11 @@ abstract class PrivacyBaseSpec extends BaseSpec { customdata = PBSUtils.randomString eids = [Eid.defaultEid] data = [new Data(name: PBSUtils.randomString)] - buyeruid = PBSUtils.randomString + buyerUid = PBSUtils.randomString yob = PBSUtils.randomNumber gender = PBSUtils.randomString geo = Geo.FPDGeo - ext = new UserExt(data: new UserExtData(buyeruid: PBSUtils.randomString)) + ext = new UserExt(data: new UserExtData(buyerUid: PBSUtils.randomString)) } } } @@ -670,6 +670,16 @@ abstract class PrivacyBaseSpec extends BaseSpec { }) } + protected static String getInvalidGppString(int stringLength = 20) { + // Random string can potentially generate deprecated v1 value with specific starting values + def gppV1Prefix = ['A', 'B', 'C', 'D'] + def invalidGPPValue + do { + invalidGPPValue = PBSUtils.getRandomString(stringLength) + } while (gppV1Prefix.contains(invalidGPPValue[0].toUpperCase())) + return invalidGPPValue + } + private static Purpose getRandomPurposeWithExclusion(Purpose excludeFromRandom) { def availablePurposes = Purpose.values().toList() - excludeFromRandom availablePurposes.shuffled().first() 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..e699eca908b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/prometheus/PrometheusSpec.groovy @@ -19,8 +19,8 @@ class PrometheusSpec extends BaseSpec { def "PBS should add custom labels to Prometheus metrics when custom labels are enabled in config"() { given: "PBS config with set up Prometheus and enabled Promethues custom labels" - def prometheusPbsService = pbsServiceFactory.getService(basePrometheusConfig + - ["metrics.prometheus.custom-labels-enabled": "true"]) + def pbsConfig = basePrometheusConfig + ["metrics.prometheus.custom-labels-enabled": "true"] + def prometheusPbsService = pbsServiceFactory.getService(pbsConfig) and: "Labels config metric matcher and an appropriate PBS metric to it are specified" def pbsMetricMatcher = "requests.*.*" @@ -44,15 +44,19 @@ class PrometheusSpec extends BaseSpec { def expectedLabelsString = "$normalizedMapperName$metricLabels" assert prometheusMetrics.contains(expectedLabelsString) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should add namespace, subsystem and custom labels info to Prometheus metrics when those are set in config"() { given: "PBS config with set up Prometheus with enabled custom labels" def namespace = "namespace_01" def subsystem = "subsystem_01" - def prometheusPbsService = pbsServiceFactory.getService(basePrometheusConfig + + def pbsConfig = basePrometheusConfig + getNamespaceSubsystemConfig(namespace, subsystem) + - ["metrics.prometheus.custom-labels-enabled": "true"]) + ["metrics.prometheus.custom-labels-enabled": "true"] + def prometheusPbsService = pbsServiceFactory.getService(pbsConfig) and: "Labels config metric matcher and an appropriate PBS metric to it are specified" def pbsMetricMatcher = "requests.*.*" @@ -77,6 +81,9 @@ class PrometheusSpec extends BaseSpec { def expectedLabelsString = "$namespaceSubsystemMapperName$metricLabels" assert prometheusMetrics.contains(expectedLabelsString) + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(pbsConfig) } def "PBS should add namespace and subsystem parts to Prometheus metric names when those are config provided"() { @@ -101,6 +108,10 @@ class PrometheusSpec extends BaseSpec { then: "Prometheus metrics response contains each of PBS metric with added namespace and subsystem" prometheusFormatPbsMetricNames.each { assert prometheusMetrics.contains(it) } + + + cleanup: "Stop and remove pbs container" + pbsServiceFactory.removeContainer(config) } def "PBS service fails to start when invalid symbols by namespace and subsystem in Prometheus config are present"() { @@ -122,17 +133,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/AccountS3Spec.groovy b/src/test/groovy/org/prebid/server/functional/tests/storage/AccountS3Spec.groovy index 3a87be7b9e7..3ca62d3d849 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/storage/AccountS3Spec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/storage/AccountS3Spec.groovy @@ -2,6 +2,8 @@ package org.prebid.server.functional.tests.storage import org.prebid.server.functional.model.AccountStatus import org.prebid.server.functional.model.config.AccountConfig +import org.prebid.server.functional.model.config.ModuleName +import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService @@ -13,9 +15,15 @@ import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED class AccountS3Spec extends StorageBaseSpec { - protected PrebidServerService s3StorageAccountPbsService = PbsServiceFactory.getService(s3StorageConfig + - mySqlDisabledConfig + - ['settings.enforce-valid-account': 'true']) + private final static Map> S3_CONFIG = s3StorageConfig + + mySqlDisabledConfig + + ['settings.enforce-valid-account': 'true'] + + private static final PrebidServerService s3StorageAccountPbsService = PbsServiceFactory.getService(S3_CONFIG) + + def cleanupSpec() { + pbsServiceFactory.removeContainer(S3_CONFIG) + } def "PBS should process request when active account is present in S3 storage"() { given: "Default BidRequest with account" diff --git a/src/test/groovy/org/prebid/server/functional/tests/storage/AmpS3Spec.groovy b/src/test/groovy/org/prebid/server/functional/tests/storage/AmpS3Spec.groovy index cf5e68bbc90..15830fc434a 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..ba10f4e72e1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/storage/StorageBaseSpec.groovy @@ -51,6 +51,5 @@ class StorageBaseSpec extends BaseSpec { 'settings.database.stored-responses-query' : null ].asImmutable() as Map - - protected PrebidServerService s3StoragePbsService = PbsServiceFactory.getService(s3StorageConfig + mySqlDisabledConfig) + protected static final PrebidServerService s3StoragePbsService = PbsServiceFactory.getService(s3StorageConfig + mySqlDisabledConfig) } 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/PBSUtils.groovy b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy index 748071dd10f..46633e32453 100644 --- a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy @@ -48,7 +48,7 @@ class PBSUtils implements ObjectMapperWrapper { static String getRandomString(int stringLength = 20) { RandomStringUtils.randomAlphanumeric(stringLength) - } + } static String getRandomSpecialChars(int stringLength = 20) { RandomStringUtils.random(stringLength, "!@#\$%^&*()-_=+[]{}|;:'\",.<>/?") 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