Skip to content
Open
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
@@ -1,4 +1,4 @@
package org.prebid.server.bidder.sspbc;
package org.prebid.server.bidder.gopl;

import com.iab.openrtb.request.BidRequest;
import com.iab.openrtb.response.Bid;
Expand All @@ -25,14 +25,14 @@
import java.util.List;
import java.util.Objects;

public class SspbcBidder implements Bidder<SspbcRequest> {
public class GoplBidder implements Bidder<GoplRequest> {

private static final String ADAPTER_VERSION = "6.0";
private static final String ADAPTER_VERSION = "7.0";

private final String endpointUrl;
private final JacksonMapper mapper;

public SspbcBidder(String endpointUrl, JacksonMapper mapper) {
public GoplBidder(String endpointUrl, JacksonMapper mapper) {
this.endpointUrl = resolveEndpointUrl(endpointUrl);
this.mapper = Objects.requireNonNull(mapper);
}
Expand All @@ -42,13 +42,13 @@ private static String resolveEndpointUrl(String base) {
}

@Override
public Result<List<HttpRequest<SspbcRequest>>> makeHttpRequests(BidRequest request) {
public Result<List<HttpRequest<GoplRequest>>> makeHttpRequests(BidRequest request) {
return Result.withValue(createHttpRequest(request));
}

private HttpRequest<SspbcRequest> createHttpRequest(BidRequest request) {
final SspbcRequest outgoingRequest = SspbcRequest.of(request);
return HttpRequest.<SspbcRequest>builder()
private HttpRequest<GoplRequest> createHttpRequest(BidRequest request) {
final GoplRequest outgoingRequest = GoplRequest.of(request);
return HttpRequest.<GoplRequest>builder()
.method(HttpMethod.POST)
.uri(endpointUrl)
.headers(HttpUtil.headers())
Expand All @@ -59,7 +59,7 @@ private HttpRequest<SspbcRequest> createHttpRequest(BidRequest request) {
}

@Override
public Result<List<BidderBid>> makeBids(BidderCall<SspbcRequest> httpCall, BidRequest bidRequest) {
public Result<List<BidderBid>> makeBids(BidderCall<GoplRequest> httpCall, BidRequest bidRequest) {
try {
final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class);
return Result.withValues(extractBids(bidResponse));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.prebid.server.bidder.sspbc;
package org.prebid.server.bidder.gopl;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iab.openrtb.request.BidRequest;
import lombok.Value;

@Value(staticConstructor = "of")
public class SspbcRequest {
public class GoplRequest {

@JsonProperty("bidRequest")
BidRequest bidRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.prebid.server.proto.openrtb.ext.request.sspbc;
package org.prebid.server.proto.openrtb.ext.request.gopl;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Value;

@Value(staticConstructor = "of")
public class ExtImpSspbc {
public class ExtImpGopl {

@JsonProperty("siteId")
String siteId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.prebid.server.spring.config.bidder;

import org.prebid.server.bidder.BidderDeps;
import org.prebid.server.bidder.sspbc.SspbcBidder;
import org.prebid.server.bidder.gopl.GoplBidder;
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties;
import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler;
Expand All @@ -12,24 +12,24 @@
import org.springframework.context.annotation.PropertySource;

@Configuration
@PropertySource(value = "classpath:/bidder-config/sspbc.yaml", factory = YamlPropertySourceFactory.class)
public class SspbcBidderConfiguration {
@PropertySource(value = "classpath:/bidder-config/gopl.yaml", factory = YamlPropertySourceFactory.class)
public class GoplBidderConfiguration {

private static final String BIDDER_NAME = "sspbc";
private static final String BIDDER_NAME = "gopl";

@Bean("sspbcConfigurationProperties")
@ConfigurationProperties("adapters.sspbc")
@Bean("goplConfigurationProperties")
@ConfigurationProperties("adapters.gopl")
BidderConfigurationProperties configurationProperties() {
return new BidderConfigurationProperties();
}

@Bean
BidderDeps sspbcBidderDeps(BidderConfigurationProperties sspbcConfigurationProperties,
BidderDeps goplBidderDeps(BidderConfigurationProperties goplConfigurationProperties,
JacksonMapper mapper) {

return BidderDepsAssembler.forBidder(BIDDER_NAME)
.withConfig(sspbcConfigurationProperties)
.bidderCreator(config -> new SspbcBidder(config.getEndpoint(), mapper))
.withConfig(goplConfigurationProperties)
.bidderCreator(config -> new GoplBidder(config.getEndpoint(), mapper))
.assemble();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
adapters:
sspbc:
gopl:
endpoint: https://ssp.wp.pl/v2/bidder/prebidserver
meta-info:
maintainer-email: prebid-dev@grupawp.pl
app-media-types:
site-media-types:
- banner
supported-vendors:
vendor-id: 676
vendor-id: 690
usersync:
cookie-family-name: sspbc
cookie-family-name: gopl
iframe:
url: https://ssp.wp.pl/bidder/usersync?tcf=2&redirect={redirect_url}
support-cors: false
uid-macro: '$UID'
redirect:
url: https://ssp.wp.pl/v1/sync/prebid-server/pixel?gdpr={gdpr}&gdpr_consent={gdpr_consent}&redirect={redirect_url}
support-cors: false
uid-macro: '$UID'
aliases:
sspbc:
meta-info:
vendor-id: 676
usersync:
cookie-family-name: sspbc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "sspBC Bid Adapter Params",
"description": "A schema which validates params accepted by the sspBC bid adapter",
"title": "gopl Bid Adapter Params",
"description": "A schema which validates params accepted by the gopl bid adapter",
"type": "object",
"properties": {
"siteid": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.bidder.sspbc;
package org.prebid.server.bidder.gopl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.iab.openrtb.request.BidRequest;
Expand All @@ -25,15 +25,15 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

public class SspbcBidderTest extends VertxTest {
public class GoplBidderTest extends VertxTest {

private static final String ENDPOINT_URL = "https://randomurl.com";

private final SspbcBidder target = new SspbcBidder(ENDPOINT_URL, jacksonMapper);
private final GoplBidder target = new GoplBidder(ENDPOINT_URL, jacksonMapper);

@Test
public void creationShouldFailOnInvalidEndpointUrl() {
assertThatIllegalArgumentException().isThrownBy(() -> new SspbcBidder("invalid_url", jacksonMapper));
assertThatIllegalArgumentException().isThrownBy(() -> new GoplBidder("invalid_url", jacksonMapper));
}

@Test
Expand All @@ -42,13 +42,13 @@ public void makeHttpRequestsShouldCreateExpectedUrl() {
final BidRequest bidRequest = givenBidRequest(identity());

// when
final Result<List<HttpRequest<SspbcRequest>>> result = target.makeHttpRequests(bidRequest);
final Result<List<HttpRequest<GoplRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1)
.extracting(HttpRequest::getUri)
.containsExactly("https://randomurl.com?bdver=6.0");
.containsExactly("https://randomurl.com?bdver=7.0");
}

@Test
Expand All @@ -57,18 +57,18 @@ public void makeHttpRequestsShouldCreateValidPayload() {
final BidRequest bidRequest = givenBidRequest(identity());

//when
final Result<List<HttpRequest<SspbcRequest>>> result = target.makeHttpRequests(bidRequest);
final Result<List<HttpRequest<GoplRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1);
assertThat(result.getValue().getFirst().getPayload()).isEqualTo(SspbcRequest.of(bidRequest));
assertThat(result.getValue().getFirst().getPayload()).isEqualTo(GoplRequest.of(bidRequest));
}

@Test
public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() {
// given
final BidderCall<SspbcRequest> httpCall = givenHttpCall(null, "invalid");
final BidderCall<GoplRequest> httpCall = givenHttpCall(null, "invalid");

// when
final Result<List<BidderBid>> result = target.makeBids(httpCall, null);
Expand All @@ -85,7 +85,7 @@ public void makeBidsShouldReturnErrorIfResponseBodyCouldNotBeParsed() {
@Test
public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProcessingException {
// given
final BidderCall<SspbcRequest> httpCall = givenHttpCall(null, mapper.writeValueAsString(null));
final BidderCall<GoplRequest> httpCall = givenHttpCall(null, mapper.writeValueAsString(null));

// when
final Result<List<BidderBid>> result = target.makeBids(httpCall, null);
Expand All @@ -98,7 +98,7 @@ public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProces
@Test
public void makeBidsShouldReturnErrorWhenAdmIsEmpty() throws JsonProcessingException {
// given
final BidderCall<SspbcRequest> httpCall = givenHttpCall(givenBidRequest(identity(),
final BidderCall<GoplRequest> httpCall = givenHttpCall(givenBidRequest(identity(),
impBuilder -> impBuilder.id("id").tagid("tagId")),
mapper.writeValueAsString(givenBidResponse(bidBuilder ->
bidBuilder
Expand All @@ -117,7 +117,7 @@ public void makeBidsShouldReturnErrorWhenAdmIsEmpty() throws JsonProcessingExcep
@Test
public void makeBidsShouldReturnErrorWhenMTypeIsIncorrect() throws JsonProcessingException {
// given
final BidderCall<SspbcRequest> httpCall = givenHttpCall(givenBidRequest(identity(),
final BidderCall<GoplRequest> httpCall = givenHttpCall(givenBidRequest(identity(),
impBuilder -> impBuilder.id("id").tagid("tagId")),
mapper.writeValueAsString(givenBidResponse(bidBuilder ->
bidBuilder
Expand All @@ -137,7 +137,7 @@ public void makeBidsShouldReturnErrorWhenMTypeIsIncorrect() throws JsonProcessin
@Test
public void makeBidsShouldParseBid() throws JsonProcessingException {
// given
final BidderCall<SspbcRequest> httpCall = givenHttpCall(givenBidRequest(
final BidderCall<GoplRequest> httpCall = givenHttpCall(givenBidRequest(
bidRequestBuilder -> bidRequestBuilder
.id("bidRequestId")
.site(Site.builder()
Expand Down Expand Up @@ -169,6 +169,69 @@ public void makeBidsShouldParseBid() throws JsonProcessingException {
.containsExactly(BidType.banner);
}

@Test
public void makeBidsShouldParseVideoBid() throws JsonProcessingException {
// given
final BidderCall<GoplRequest> httpCall = givenHttpCall(givenBidRequest(identity(),
impBuilder -> impBuilder.id("id").tagid("tagId")),
mapper.writeValueAsString(givenBidResponse(bidBuilder ->
bidBuilder
.impid("id")
.adm("anyAdm")
.mtype(2))));

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

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(BidderBid::getType)
.containsExactly(BidType.video);
}

@Test
public void makeBidsShouldParseAudioBid() throws JsonProcessingException {
// given
final BidderCall<GoplRequest> httpCall = givenHttpCall(givenBidRequest(identity(),
impBuilder -> impBuilder.id("id").tagid("tagId")),
mapper.writeValueAsString(givenBidResponse(bidBuilder ->
bidBuilder
.impid("id")
.adm("anyAdm")
.mtype(3))));

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

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(BidderBid::getType)
.containsExactly(BidType.audio);
}

@Test
public void makeBidsShouldParseNativeBid() throws JsonProcessingException {
// given
final BidderCall<GoplRequest> httpCall = givenHttpCall(givenBidRequest(identity(),
impBuilder -> impBuilder.id("id").tagid("tagId")),
mapper.writeValueAsString(givenBidResponse(bidBuilder ->
bidBuilder
.impid("id")
.adm("anyAdm")
.mtype(4))));

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

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(BidderBid::getType)
.containsExactly(BidType.xNative);
}

private static BidRequest givenBidRequest(UnaryOperator<Imp.ImpBuilder> impCustomizer) {
return givenBidRequest(identity(), impCustomizer);
}
Expand All @@ -191,9 +254,9 @@ private static BidResponse givenBidResponse(UnaryOperator<Bid.BidBuilder> bidCus
.build();
}

private static BidderCall<SspbcRequest> givenHttpCall(BidRequest bidRequest, String body) {
private static BidderCall<GoplRequest> givenHttpCall(BidRequest bidRequest, String body) {
return BidderCall.succeededHttp(
HttpRequest.<SspbcRequest>builder().payload(SspbcRequest.of(bidRequest)).build(),
HttpRequest.<GoplRequest>builder().payload(GoplRequest.of(bidRequest)).build(),
HttpResponse.of(200, null, body),
null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static java.util.Collections.singletonList;

public class SspbcTest extends IntegrationTest {
public class GoplTest extends IntegrationTest {

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

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

// then
assertJsonEquals("openrtb2/sspbc/test-auction-sspbc-response.json", response,
singletonList("sspbc"));
assertJsonEquals("openrtb2/gopl/test-auction-gopl-response.json", response,
singletonList("gopl"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"h": 250
},
"ext": {
"sspbc": {
"gopl": {
"siteId": "siteId",
"id": "anyId",
"test": 1
Expand Down
Loading