diff --git a/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java new file mode 100644 index 00000000000..4a232c39bec --- /dev/null +++ b/src/main/java/org/prebid/server/spring/config/bidder/AaxConfiguration.java @@ -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)); + } +} diff --git a/src/main/resources/bidder-config/aax.yaml b/src/main/resources/bidder-config/aax.yaml new file mode 100644 index 00000000000..e6bda296d94 --- /dev/null +++ b/src/main/resources/bidder-config/aax.yaml @@ -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 + - 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= + cookie-family-name: aax + type: redirect + support-cors: false diff --git a/src/main/resources/static/bidder-params/aax.json b/src/main/resources/static/bidder-params/aax.json new file mode 100644 index 00000000000..83cdfc59406 --- /dev/null +++ b/src/main/resources/static/bidder-params/aax.json @@ -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" + ] +} diff --git a/src/test/java/org/prebid/server/it/AaxTest.java b/src/test/java/org/prebid/server/it/AaxTest.java new file mode 100644 index 00000000000..01f4061995f --- /dev/null +++ b/src/test/java/org/prebid/server/it/AaxTest.java @@ -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")); + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aax/test-aax-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-aax-bid-request.json new file mode 100644 index 00000000000..ba09e5f9846 --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-aax-bid-request.json @@ -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 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aax/test-aax-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-aax-bid-response.json new file mode 100644 index 00000000000..4b1ecda6ece --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-aax-bid-response.json @@ -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" +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aax/test-auction-aax-request.json b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-auction-aax-request.json new file mode 100644 index 00000000000..7e76123f01b --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-auction-aax-request.json @@ -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 + } + } +} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/aax/test-auction-aax-response.json b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-auction-aax-response.json new file mode 100644 index 00000000000..510834b5e2e --- /dev/null +++ b/src/test/resources/org/prebid/server/it/openrtb2/aax/test-auction-aax-response.json @@ -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 + } +} diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index d9f05a99a54..825bcc910e3 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -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