Skip to content

Commit

Permalink
Make pr-richmedia-filter global properties optional (#3612)
Browse files Browse the repository at this point in the history
  • Loading branch information
Net-burst authored Dec 11, 2024
1 parent 2513438 commit a5aa326
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
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

0 comments on commit a5aa326

Please sign in to comment.