Skip to content

Commit

Permalink
Fix issue with connection for tests (#3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
osulzhenko authored Jan 29, 2025
1 parent 02ab379 commit 3e91c96
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper {
protected static final Map<String, String> GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true",
"adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()]

protected final PrebidServerService defaultPbsService = pbsServiceFactory.getService([:])
protected static final PrebidServerService defaultPbsService = pbsServiceFactory.getService([:])

def setupSpec() {
prebidCache.setResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ class AbTestingModuleSpec extends ModuleBaseSpec {
private final static Map<String, String> MULTI_MODULE_CONFIG = getResponseCorrectionConfig() + getOrtb2BlockingSettings() +
['hooks.host-execution-plan': null]

private final static PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings())
private final static PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG)
private static final PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings())
private static final PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG)

def cleanupSpec() {
pbsServiceFactory.removeContainer(getOrtb2BlockingSettings())
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG)
}

def "PBS shouldn't apply a/b test config when config of ab test is disabled"() {
given: "Default bid request with verbose trace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ class GeneralModuleSpec extends ModuleBaseSpec {
getOrtb2BlockingSettings() +
['hooks.host-execution-plan': encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES))]

private final static PrebidServerService pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
private final static PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
private static final PrebidServerService pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
private static final PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)

def cleanupSpec() {
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
}

def "PBS should call all modules and traces response when account config is empty and require-config-to-invoke is disabled"() {
given: "Default bid request with verbose trace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import static org.prebid.server.functional.model.response.auction.ErrorType.PREB

class AnalyticsTagsModuleSpec extends ModuleBaseSpec {

private final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings)
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ 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 final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings + 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec {
private static final String ANDROID = "android"
private static final String IOS = "IOS"

private PrebidServerService pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(requestCorrectionSettings)
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ import static org.prebid.server.functional.model.response.auction.MediaType.VIDE

class ResponseCorrectionSpec extends ModuleBaseSpec {

private final PrebidServerService pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService(
["adapter-defaults.modifying-vast-xml-allowed": "false",
"adapters.generic.modifying-vast-xml-allowed": "false"] +
responseCorrectionConfig)

private final static int OPTIMAL_MAX_LENGTH = 20
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,22 @@ class RichMediaFilterSpec extends ModuleBaseSpec {

private static final String PATTERN_NAME = PBSUtils.randomString
private static final String PATTERN_NAME_ACCOUNT = PBSUtils.randomString
private final PrebidServerService pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME))
private final PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(
(getRichMediaFilterSettings(PATTERN_NAME) + ["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap {
private static final Map<String, String> DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME, false)
private static final Map<String, String> SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME)
private static final Map<String, String> SNAKE_SPECIFIC_PATTERN_NAME_CONFIG = (getRichMediaFilterSettings(PATTERN_NAME) +
["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap {
endpoints.values().first().stages.values().first().groups.first.hookSequenceSnakeCase = [new HookId(moduleCodeSnakeCase: PB_RICHMEDIA_FILTER.code, hookImplCodeSnakeCase: "${PB_RICHMEDIA_FILTER.code}-${ALL_PROCESSED_BID_RESPONSES.value}-hook")]
})])
.collectEntries { key, value -> [(key.toString()): value.toString()] })
private final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME, false))
})]).collectEntries { key, value -> [(key.toString()): value.toString()] }

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)

def cleanupSpec() {
pbsServiceFactory.removeContainer(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG)
pbsServiceFactory.removeContainer(SPECIFIC_PATTERN_NAME_CONFIG)
pbsServiceFactory.removeContainer(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG)
}

def "PBS should process request without rich media module when host config have empty settings"() {
given: "Prebid server with empty settings for module"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class GdprSetUidSpec extends PrivacyBaseSpec {

private static final PrebidServerService prebidServerService = pbsServiceFactory.getService(VENDOR_GENERIC_PBS_CONFIG)

def cleanupSpec() {
pbsServiceFactory.removeContainer(VENDOR_GENERIC_PBS_CONFIG)
}

def "PBS setuid shouldn't failed with tcf when purpose access device not enforced"() {
given: "Default setuid request with account"
def setuidRequest = SetuidRequest.defaultSetuidRequest.tap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class GppCookieSyncSpec extends BaseSpec {
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL,
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.support-cors": CORS_SUPPORT.toString()]

private PrebidServerService prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG)
private static PrebidServerService prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG)

def cleanupSpec() {
pbsServiceFactory.removeContainer(GENERIC_CONFIG)
}

def "PBS cookie sync request should set GDPR to 1 when gpp_sid contains 2"() {
given: "Request without GDPR and GPP SID"
Expand Down Expand Up @@ -204,9 +208,9 @@ class GppCookieSyncSpec extends BaseSpec {

def "PBS should return empty gpp and gppSid in usersync url when gpp and gppSid is not present in request"() {
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"])
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 without gpp and gppSid"
def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap {
Expand All @@ -222,15 +226,18 @@ class GppCookieSyncSpec extends BaseSpec {
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp").isEmpty()
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp_sid").isEmpty()

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)

where:
userSyncFormat << [REDIRECT, IFRAME]
}

def "PBS should populate gpp and gppSid in usersync url when gpp and gppSid is present in request"() {
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"])
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 with gpp and gppSid"
def gpp = PBSUtils.randomString
Expand All @@ -248,6 +255,9 @@ class GppCookieSyncSpec extends BaseSpec {
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp") == gpp
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp_sid") == gppSid

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)

where:
userSyncFormat << [REDIRECT, IFRAME]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1778,9 +1778,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS cookie sync should process rule when geo doesn't intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
def pbsConfig = GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.geo-info.[0].country": countyConfig,
"geolocation.configurations.geo-info.[0].region" : regionConfig])
"geolocation.configurations.geo-info.[0].region" : regionConfig]
def prebidServerService = pbsServiceFactory.getService(pbsConfig)

and: "Cookie sync request with account connection"
def accountId = PBSUtils.randomNumber as String
Expand Down Expand Up @@ -1819,6 +1820,9 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
def metrics = prebidServerService.sendCollectedMetricsRequest()
assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)

where:
countyConfig | regionConfig | conditionGeo
null | null | ["$USA.ISOAlpha3".toString()]
Expand All @@ -1830,9 +1834,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS setuid should process rule when geo doesn't intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
def pbsConfig = GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": countyConfig,
"geolocation.configurations.[0].geo-info.region" : regionConfig])
"geolocation.configurations.[0].geo-info.region" : regionConfig]
def prebidServerService = pbsServiceFactory.getService(pbsConfig)

and: "Default set uid request"
def accountId = PBSUtils.randomString
Expand Down Expand Up @@ -1875,6 +1880,9 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
def metrics = prebidServerService.sendCollectedMetricsRequest()
assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)

where:
countyConfig | regionConfig | conditionGeo
null | null | [USA.ISOAlpha3]
Expand All @@ -1885,9 +1893,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS cookie sync should disallowed rule when device.geo intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
def pbsConfig = GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": countyConfig,
"geolocation.configurations.[0].geo-info.region" : regionConfig])
"geolocation.configurations.[0].geo-info.region" : regionConfig]
def prebidServerService = pbsServiceFactory.getService(pbsConfig)

and: "Cookie sync request with account connection"
def accountId = PBSUtils.randomNumber as String
Expand Down Expand Up @@ -1928,6 +1937,9 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1
assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)

where:
countyConfig | regionConfig | conditionGeo
USA.ISOAlpha3 | null | [USA.ISOAlpha3]
Expand All @@ -1936,9 +1948,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS setuid should disallowed rule when device.geo intersection"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
def pbsConfig = GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": countyConfig,
"geolocation.configurations.[0].geo-info.region" : regionConfig])
"geolocation.configurations.[0].geo-info.region" : regionConfig]
def prebidServerService = pbsServiceFactory.getService(pbsConfig)

and: "Default set uid request"
def accountId = PBSUtils.randomString
Expand Down Expand Up @@ -1978,6 +1991,9 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
assert exception.statusCode == INVALID_STATUS_CODE
assert exception.responseBody == INVALID_STATUS_MESSAGE

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)

where:
countyConfig | regionConfig | conditionGeo
USA.ISOAlpha3 | null | [USA.ISOAlpha3]
Expand All @@ -1986,9 +2002,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {

def "PBS cookie sync should fetch geo once when gpp sync user and account require geo look up"() {
given: "Pbs config with geo location"
def prebidServerService = pbsServiceFactory.getService(GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
def pbsConfig = GENERAL_PRIVACY_CONFIG + GEO_LOCATION +
["geolocation.configurations.[0].geo-info.country": USA.ISOAlpha3,
"geolocation.configurations.[0].geo-info.region" : ALABAMA.abbreviation])
"geolocation.configurations.[0].geo-info.region" : ALABAMA.abbreviation]
def prebidServerService = pbsServiceFactory.getService(pbsConfig)

and: "Cookie sync request with account connection"
def accountId = PBSUtils.randomNumber as String
Expand Down Expand Up @@ -2034,5 +2051,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec {
and: "Metrics processed across activities should be updated"
assert metrics[GEO_LOCATION_REQUESTS] == 1
assert metrics[GEO_LOCATION_SUCCESSFUL] == 1

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)
}
}
Loading

0 comments on commit 3e91c96

Please sign in to comment.