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

New Adapter: AAX #1819

Merged
merged 3 commits into from
May 5, 2022
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
@@ -0,0 +1,47 @@
package org.prebid.server.spring.config.bidder;

import org.prebid.server.bidder.BidderDeps;
import org.prebid.server.bidder.GenericBidder;
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties;
import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler;
import org.prebid.server.spring.config.bidder.util.UsersyncerCreator;
import org.prebid.server.spring.env.YamlPropertySourceFactory;
import org.prebid.server.util.HttpUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import javax.validation.constraints.NotBlank;

@Configuration
@PropertySource(value = "classpath:/bidder-config/aax.yaml", factory = YamlPropertySourceFactory.class)
public class AaxConfiguration {

private static final String BIDDER_NAME = "aax";
private static final String EXTERNAL_URL_MACRO = "{{PREBID_SERVER_ENDPOINT}}";

@Bean("aaxConfigurationProperties")
@ConfigurationProperties("adapters.aax")
BidderConfigurationProperties configurationProperties() {
return new BidderConfigurationProperties();
}

@Bean
BidderDeps aaxBidderDeps(BidderConfigurationProperties aaxConfigurationProperties,
@NotBlank @Value("${external-url}") String externalUrl,
JacksonMapper mapper) {

return BidderDepsAssembler.forBidder(BIDDER_NAME)
.withConfig(aaxConfigurationProperties)
.usersyncerCreator(UsersyncerCreator.create(externalUrl))
.bidderCreator(config -> new GenericBidder(resolveEndpoint(config.getEndpoint(), externalUrl), mapper))
.assemble();
}

private String resolveEndpoint(String configEndpoint, String externalUrl) {
return configEndpoint.replace(EXTERNAL_URL_MACRO, HttpUtil.encodeUrl(externalUrl));
}
}
21 changes: 21 additions & 0 deletions src/main/resources/bidder-config/aax.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
adapters:
aax:
endpoint: https://prebid.aaxads.com/rtb/pb/aax-prebid?src={{PREBID_SERVER_ENDPOINT}}
meta-info:
maintainer-email: product@aax.media
app-media-types:
- banner
- video
And1sS marked this conversation as resolved.
Show resolved Hide resolved
- native
site-media-types:
- banner
- video
- native
supported-vendors:
vendor-id: 720
usersync:
url: https://c.aaxads.com/aacxc.php?fv=1&wbsh=psa&ryvlg=setstatuscode&redirect=
redirect-url: /setuid?bidder=aax&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&uid=<vsid>
cookie-family-name: aax
type: redirect
support-cors: false
20 changes: 20 additions & 0 deletions src/main/resources/static/bidder-params/aax.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Aax Adapter Params",
"description": "A schema which validates params accepted by the Aax adapter",
"type": "object",
"properties": {
"cid": {
"type": "string",
"description": "The customer id provided by AAX."
},
"crid": {
"type": "string",
"description": "The placement id provided by AAX."
}
},
"required": [
"cid",
"crid"
]
}
36 changes: 36 additions & 0 deletions src/test/java/org/prebid/server/it/AaxTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.prebid.server.it;

import io.restassured.response.Response;
import org.json.JSONException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.prebid.server.model.Endpoint;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static java.util.Collections.singletonList;

@RunWith(SpringRunner.class)
public class AaxTest extends IntegrationTest {

@Test
public void openrtb2AuctionShouldRespondWithBidsFromTheAax() throws IOException, JSONException {
// given
WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/aax-exchange"))
.withRequestBody(equalToJson(jsonFrom("openrtb2/aax/test-aax-bid-request.json")))
.willReturn(aResponse().withBody(jsonFrom("openrtb2/aax/test-aax-bid-response.json"))));

// when
final Response response = responseFor("openrtb2/aax/test-auction-aax-request.json",
Endpoint.openrtb2_auction);

// then
assertJsonEquals("openrtb2/aax/test-auction-aax-response.json", response,
singletonList("aax"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"w": 300,
"h": 250
},
"ext": {
"bidder": {
"cid": "AAXCID",
"crid": "12345678"
}
}
}
],
"site": {
"domain": "www.example.com",
"page": "http://www.example.com",
"publisher": {
"domain": "example.com"
},
"ext": {
"amp": 0
}
},
"device": {
"ua": "userAgent",
"ip": "193.168.244.1"
},
"at": 1,
"tmax": 5000,
"cur": [
"USD"
],
"regs": {
"ext": {
"gdpr": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"id": "tid",
"seatbid": [
{
"seat": "aax",
"bid": [
{
"id": "randomid",
"impid": "test-imp-id",
"price": 0.500000,
"adid": "12345678",
"adm": "some-test-ad",
"cid": "987",
"crid": "12345678",
"h": 250,
"w": 300
}
]
}
],
"bidid": "bid01"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"w": 300,
"h": 250
},
"ext": {
"aax": {
"cid": "AAXCID",
"crid": "12345678"
}
}
}
],
"tmax": 5000,
"regs": {
"ext": {
"gdpr": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"id": "test-request-id",
"seatbid": [
{
"bid": [
{
"id": "randomid",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-ad",
"adid": "12345678",
"cid": "987",
"crid": "12345678",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "banner"
},
"origbidcpm": 0.5
}
}
],
"seat": "aax",
"group": 0
}
],
"cur": "USD",
"ext": {
"responsetimemillis": {
"aax": "{{ aax.response_time_ms }}"
},
"prebid": {
"auctiontimestamp": 0
},
"tmaxrequest": 5000
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ adapters.yieldone.enabled=true
adapters.yieldone.endpoint=http://localhost:8090/yieldone-exchange
adapters.zeroclickfraud.enabled=true
adapters.zeroclickfraud.endpoint=http://{{Host}}/zeroclickfraud-exchange?sid={{SourceId}}
adapters.aax.enabled=true
adapters.aax.endpoint=http://localhost:8090/aax-exchange
http-client.circuit-breaker.enabled=true
http-client.circuit-breaker.idle-expire-hours=24
http-client.circuit-breaker.opening-threshold=1
Expand Down