Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pb-richmedia-filter global properties optional #3612

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class PbRichmediaFilterModuleConfiguration {

@Bean
PbRichmediaFilterModule pbRichmediaFilterModule(
@Value("${hooks.modules.pb-richmedia-filter.filter-mraid}") Boolean filterMraid,
@Value("${hooks.modules.pb-richmedia-filter.mraid-script-pattern}") String mraidScriptPattern) {
@Value("${hooks.modules.pb-richmedia-filter.filter-mraid:false}") boolean filterMraid,
@Value("${hooks.modules.pb-richmedia-filter.mraid-script-pattern:#{null}}") String mraidScriptPattern) {

final ObjectMapper mapper = ObjectMapperProvider.mapper();
final PbRichMediaFilterProperties globalProperties = PbRichMediaFilterProperties.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ class ModuleBaseSpec extends BaseSpec {
}

protected static Map<String, String> getRichMediaFilterSettings(String scriptPattern,
boolean filterMraidEnabled = true,
Boolean filterMraidEnabled = true,
Endpoint endpoint = OPENRTB2_AUCTION) {

["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]]))]
.findAll { it.value != null }
.collectEntries { key, value -> [(key.toString()): value.toString()] }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,51 @@ class RichMediaFilterSpec extends ModuleBaseSpec {
.collectEntries { key, value -> [(key.toString()): value.toString()] })
private final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME, false))

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"
def storedResponseId = PBSUtils.randomNumber
def bidRequest = BidRequest.defaultBidRequest.tap {
ext.prebid.returnAllBidStatus = true
it.ext.prebid.trace = VERBOSE
it.imp.first().ext.prebid.storedBidResponse = [new StoredBidResponse(id: storedResponseId, bidder: GENERIC)]
}

and: "Stored bid response in DB"
def storedBidResponse = BidResponse.getDefaultBidResponse(bidRequest).tap {
it.seatbid[0].bid[0].adm = PBSUtils.randomString
}
def storedResponse = new StoredResponse(responseId: storedResponseId, storedBidResponse: storedBidResponse)
storedResponseDao.save(storedResponse)

and: "Account in the DB"
def account = new Account(uuid: bidRequest.getAccountId())
accountDao.save(account)

when: "PBS processes auction request"
def response = prebidServerService.sendAuctionRequest(bidRequest)

then: "Response header should contain seatbid"
assert response.seatbid.size() == 1

and: "Response shouldn't contain errors of invalid creation"
assert !response.ext.errors

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)]
}

def "PBS should process request without analytics when adm matches with pattern name and filter set to disabled in host config"() {
given: "BidRequest with stored response"
def storedResponseId = PBSUtils.randomNumber
Expand Down
Loading