Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into port-3574-driftpixel
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 committed Dec 16, 2024
2 parents 46c1eb4 + b9ed378 commit 3048d26
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 30 deletions.
2 changes: 1 addition & 1 deletion extra/bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
<relativePath>../../extra/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion extra/modules/confiant-ad-quality/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
</parent>

<artifactId>confiant-ad-quality</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extra/modules/fiftyone-devicedetection/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
</parent>

<artifactId>fiftyone-devicedetection</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extra/modules/greenbids-real-time-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
</parent>

<artifactId>greenbids-real-time-data</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
Expand Down Expand Up @@ -87,13 +88,15 @@ public class GreenbidsRealTimeDataProcessedAuctionRequestHookTest {
@Mock(strictness = LENIENT)
private DatabaseReaderFactory databaseReaderFactory;

@Mock
private DatabaseReader dbReader;

private GreenbidsRealTimeDataProcessedAuctionRequestHook target;

@BeforeEach
public void setUp() throws IOException {
final Storage storage = StorageOptions.newBuilder()
.setProjectId("test_project").build().getService();
final DatabaseReader dbReader = givenDatabaseReader();
final FilterService filterService = new FilterService();
final OnnxModelRunnerFactory onnxModelRunnerFactory = new OnnxModelRunnerFactory();
final ThrottlingThresholdsFactory throttlingThresholdsFactory = new ThrottlingThresholdsFactory();
Expand Down Expand Up @@ -159,6 +162,7 @@ public void callShouldExitEarlyWhenPartnerNotActivatedInBidRequest() {
assertThat(result.analyticsTags()).isNull();
}

@Disabled("Broken until dbReader is mocked")
@Test
public void callShouldNotFilterBiddersAndReturnAnalyticsTagWhenExploration() throws OrtException, IOException {
// given
Expand Down Expand Up @@ -213,6 +217,7 @@ public void callShouldNotFilterBiddersAndReturnAnalyticsTagWhenExploration() thr
assertThat(fingerprint).isNotNull();
}

@Disabled("Broken until dbReader is mocked")
@Test
public void callShouldFilterBiddersBasedOnModelWhenAnyFeatureNotAvailable() throws OrtException, IOException {
// given
Expand Down Expand Up @@ -273,6 +278,7 @@ public void callShouldFilterBiddersBasedOnModelWhenAnyFeatureNotAvailable() thro
assertThat(resultBidRequest).usingRecursiveComparison().isEqualTo(expectedBidRequest);
}

@Disabled("Broken until dbReader is mocked")
@Test
public void callShouldFilterBiddersBasedOnModelResults() throws OrtException, IOException {
// given
Expand Down Expand Up @@ -335,19 +341,6 @@ public void callShouldFilterBiddersBasedOnModelResults() throws OrtException, IO
.isEqualTo(expectedBidRequest);
}

static DatabaseReader givenDatabaseReader() throws IOException {
final URL url = new URL("https://git.io/GeoLite2-Country.mmdb");
final Path databasePath = Files.createTempFile("GeoLite2-Country", ".mmdb");

try (
InputStream inputStream = url.openStream();
FileOutputStream outputStream = new FileOutputStream(databasePath.toFile())) {
inputStream.transferTo(outputStream);
}

return new DatabaseReader.Builder(databasePath.toFile()).build();
}

static ExtRequest givenExtRequest(Double explorationRate) {
final ObjectNode greenbidsNode = TestBidRequestProvider.MAPPER.createObjectNode();
greenbidsNode.put("pbuid", "test-pbuid");
Expand Down
2 changes: 1 addition & 1 deletion extra/modules/ortb2-blocking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
</parent>

<artifactId>ortb2-blocking</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extra/modules/pb-request-correction/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
</parent>

<artifactId>pb-request-correction</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extra/modules/pb-response-correction/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
</parent>

<artifactId>pb-response-correction</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extra/modules/pb-richmedia-filter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
</parent>

<artifactId>pb-richmedia-filter</artifactId>
Expand Down
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
2 changes: 1 addition & 1 deletion extra/modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
<relativePath>../../extra/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion extra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
<packaging>pom</packaging>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>3.17.0-SNAPSHOT</version>
<version>3.18.0-SNAPSHOT</version>
<relativePath>extra/pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public <T> Future<Void> processEvent(T event) {
}

final AuctionContext auctionContext = contextAndType.getLeft();
final String eventType = contextAndType.getRight();
if (auctionContext == null) {
return Future.succeededFuture();
}

final BidRequest bidRequest = auctionContext.getBidRequest();
final TimeoutContext timeoutContext = auctionContext.getTimeoutContext();
final PrivacyContext privacyContext = auctionContext.getPrivacyContext();
Expand All @@ -134,7 +139,7 @@ public <T> Future<Void> processEvent(T event) {
}

final AgmaEvent agmaEvent = AgmaEvent.builder()
.eventType(contextAndType.getRight())
.eventType(eventType)
.accountCode(accountCode)
.requestId(bidRequest.getId())
.app(bidRequest.getApp())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ private Bid updateBidWithId(Bid bid) {
private static BidType getType(String impId, List<Imp> imps) {
for (Imp imp : imps) {
if (imp.getId().equals(impId)) {
return imp.getVideo() != null ? BidType.video : BidType.banner;
if (imp.getVideo() != null) {
return BidType.video;
} else if (imp.getAudio() != null) {
return BidType.audio;
} else {
return BidType.banner;
}
}
}
return BidType.banner;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/bidder-config/epsilon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ adapters:
app-media-types:
- banner
- video
- audio
site-media-types:
- banner
- video
- audio
supported-vendors:
vendor-id: 24
usersync:
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
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ public void setUp() {
target = new AgmaAnalyticsReporter(properties, versionProvider, jacksonMapper, clock, httpClient, vertx);
}

@Test
public void processEventShouldNotSendAnythingWhenAuctionContextIsNull() {
// given
final AuctionEvent auctionEvent = AuctionEvent.builder()
.auctionContext(null)
.build();

// when
final Future<Void> result = target.processEvent(auctionEvent);

// then
verifyNoInteractions(httpClient);
assertThat(result.succeeded()).isTrue();
}

@Test
public void processEventShouldSendEventWhenEventIsAuctionEvent() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.iab.openrtb.request.App;
import com.iab.openrtb.request.Audio;
import com.iab.openrtb.request.Banner;
import com.iab.openrtb.request.BidRequest;
import com.iab.openrtb.request.Imp;
Expand Down Expand Up @@ -41,6 +42,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.prebid.server.proto.openrtb.ext.response.BidType.audio;
import static org.prebid.server.proto.openrtb.ext.response.BidType.banner;
import static org.prebid.server.proto.openrtb.ext.response.BidType.video;

Expand Down Expand Up @@ -610,6 +612,25 @@ public void makeBidsShouldReturnVideoBidIfRequestImpHasVideo() throws JsonProces
.containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD"));
}

@Test
public void makeBidsShouldReturnAudioBidIfRequestImpHasAudio() throws JsonProcessingException {
// given
final BidderCall<BidRequest> httpCall = givenHttpCall(
givenBidRequest(builder -> builder.id("123")
.audio(Audio.builder().build())
.banner(Banner.builder().build())),
mapper.writeValueAsString(
givenBidResponse(bidBuilder -> bidBuilder.impid("123"))));

// when
final Result<List<BidderBid>> result = target.makeBids(httpCall, null);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.containsExactly(BidderBid.of(Bid.builder().impid("123").build(), audio, "USD"));
}

@Test
public void makeBidsShouldUpdateBidWithUUIDIfGenerateBidIdIsTrue() throws JsonProcessingException {
// given
Expand Down

0 comments on commit 3048d26

Please sign in to comment.