Skip to content

Commit

Permalink
Merge branch 'master' into fpd-update
Browse files Browse the repository at this point in the history
  • Loading branch information
RossGoncharuk committed Jan 16, 2020
2 parents 3b728dd + 0d2835e commit 7e59386
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Future<BidResponse> create(List<BidderResponse> bidderResponses, BidRequest bidR
result = Future.succeededFuture(BidResponse.builder()
.id(bidRequest.getId())
.cur(bidRequest.getCur().get(0))
.nbr(2) // signal "Invalid Request"
.nbr(0) // signal "Unknown Error"
.seatbid(Collections.emptyList())
.ext(Json.mapper.valueToTree(toExtBidResponse(
bidderResponses, bidRequest, CacheServiceResult.empty(), debugEnabled, null)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ public class FacebookBidder implements Bidder<BidRequest> {

private final String endpointUrl;
private final String platformId;
private final String appId;
private final String appSecret;

public FacebookBidder(String endpointUrl, String platformId, String appId, String appSecret) {
public FacebookBidder(String endpointUrl, String platformId, String appSecret) {
this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl));
this.platformId = checkBlankString(Objects.requireNonNull(platformId), "platform-id");
this.appId = checkBlankString(Objects.requireNonNull(appId), "app-id");
this.appSecret = checkBlankString(Objects.requireNonNull(appSecret), "app-secret");
}

Expand All @@ -85,7 +83,6 @@ public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest bidRequ
}

final MultiMap headers = HttpUtil.headers()
.add("Auth-Token", appId + "|" + appSecret)
.add("X-Fb-Pool-Routing-Token", bidRequest.getUser().getBuyeruid());

final List<BidderError> errors = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ BidderDeps facebookBidderDeps() {
.usersyncerCreator(UsersyncerCreator.create(usersync, null))
.bidderCreator(configProperties.getEnabled()
? () -> new FacebookBidder(configProperties.getEndpoint(), configProperties.getPlatformId(),
configProperties.getAppId(), configProperties.getAppSecret())
configProperties.getAppSecret())
: null)
.assemble();
}
Expand All @@ -61,9 +61,6 @@ private static class FacebookConfigurationProperties extends BidderConfiguration
@NotNull
private String platformId;

@NotNull
private String appId;

@NotNull
private String appSecret;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ geolocation:
type: maxmind
maxmind:
remote-file-syncer:
download-url: https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz
save-filepath: /var/tmp/prebid/GeoLite2-Country.tar.gz
download-url: https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
save-filepath: /var/tmp/prebid/GeoLite2-City.tar.gz
retry-count: 3
retry-interval-ms: 3000
timeout-ms: 300000
Expand All @@ -101,4 +101,4 @@ health-check:
database:
enabled: false
geolocation:
enabled: false
enabled: false
1 change: 0 additions & 1 deletion src/main/resources/bidder-config/facebook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ adapters:
enabled: false
endpoint: https://an.facebook.com/placementbid.ortb
platform-id:
app-id:
app-secret:
pbs-enforces-gdpr: true
modifying-vast-xml-allowed: true
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bidder-config/pubmatic.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
adapters:
pubmatic:
enabled: false
endpoint: http://hbopenbid.pubmatic.com/translator?source=prebid-server
endpoint: https://hbopenbid.pubmatic.com/translator?source=prebid-server
pbs-enforces-gdpr: true
modifying-vast-xml-allowed: true
deprecated-names:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void shouldSetNbrValueTwoAndEmptySeatbidWhenIncomingBidResponsesAreEmpty(
null, ACCOUNT, timeout, false).result();

// then
assertThat(bidResponse).returns(2, BidResponse::getNbr);
assertThat(bidResponse).returns(0, BidResponse::getNbr);
assertThat(bidResponse).returns(emptyList(), BidResponse::getSeatbid);

verify(cacheService, never()).cacheBidsOpenrtb(anyList(), anyList(), any(), any(), any());
Expand All @@ -314,7 +314,7 @@ public void shouldSetNbrValueTwoAndEmptySeatbidWhenIncomingBidResponsesDoNotCont
null, ACCOUNT, timeout, false).result();

// then
assertThat(bidResponse).returns(2, BidResponse::getNbr);
assertThat(bidResponse).returns(0, BidResponse::getNbr);
assertThat(bidResponse).returns(emptyList(), BidResponse::getSeatbid);

verify(cacheService, never()).cacheBidsOpenrtb(anyList(), anyList(), any(), any(), any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.iab.openrtb.response.SeatBid;
import io.vertx.core.MultiMap;
import io.vertx.core.http.HttpMethod;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.prebid.server.VertxTest;
Expand Down Expand Up @@ -49,47 +48,40 @@ public class FacebookBidderTest extends VertxTest {

private static final String ENDPOINT_URL = "https://test/auction";
private static final String PLATFORM_ID = "101";
private static final String APP_ID = "123";
private static final String APP_SECRET = "6237";
private static final String DEFAULT_BID_CURRENCY = "USD";

private FacebookBidder facebookBidder;

@Before
public void setUp() {
facebookBidder = new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, APP_ID, APP_SECRET);
facebookBidder = new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, APP_SECRET);
}

@Test
public void creationShouldFailOnNullArguments() {
assertThatNullPointerException().isThrownBy(
() -> new FacebookBidder(null, PLATFORM_ID, APP_ID, APP_SECRET));
() -> new FacebookBidder(null, PLATFORM_ID, APP_SECRET));
assertThatNullPointerException().isThrownBy(
() -> new FacebookBidder(ENDPOINT_URL, null, APP_ID, APP_SECRET));
() -> new FacebookBidder(ENDPOINT_URL, null, APP_SECRET));
assertThatNullPointerException().isThrownBy(
() -> new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, null, APP_SECRET));
assertThatNullPointerException().isThrownBy(
() -> new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, APP_ID, null));
() -> new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, null));
}

@Test
public void creationShouldFailOnBlankArguments() {
assertThatIllegalArgumentException().isThrownBy(
() -> new FacebookBidder(ENDPOINT_URL, " ", APP_ID, APP_SECRET))
() -> new FacebookBidder(ENDPOINT_URL, " ", APP_SECRET))
.withMessageStartingWith("No facebook platform-id specified.");
assertThatIllegalArgumentException().isThrownBy(
() -> new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, " ", APP_SECRET))
.withMessageStartingWith("No facebook app-id specified.");
assertThatIllegalArgumentException().isThrownBy(
() -> new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, APP_ID, " "))
() -> new FacebookBidder(ENDPOINT_URL, PLATFORM_ID, " "))
.withMessageStartingWith("No facebook app-secret specified.");
}

@Test
public void creationShouldFailOnInvalidEndpoints() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new FacebookBidder("invalid_url", PLATFORM_ID,
APP_ID, APP_SECRET))
.isThrownBy(() -> new FacebookBidder("invalid_url", PLATFORM_ID, APP_SECRET))
.withMessage("URL supplied is not valid: invalid_url");
}

Expand Down Expand Up @@ -268,7 +260,6 @@ public void makeHttpRequestsShouldReturnRequestWithExpectedHeaders() {
.containsOnly(
tuple("Content-Type", "application/json;charset=utf-8"),
tuple("Accept", "application/json"),
tuple("Auth-Token", "123|6237"),
tuple("X-Fb-Pool-Routing-Token", "bUid"));
}

Expand Down Expand Up @@ -501,8 +492,8 @@ public void makeBidsShouldReturnEmptyListIfBidResponseIsNull() throws JsonProces
final Result<List<BidderBid>> result = facebookBidder.makeBids(httpCall, BidRequest.builder().build());

// then
Assertions.assertThat(result.getErrors()).isEmpty();
Assertions.assertThat(result.getValue()).isEmpty();
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).isEmpty();
}

@Test
Expand All @@ -514,8 +505,8 @@ public void makeBidsShouldReturnEmptyListIfBidResponseSeatBidIsNull() throws Jso
final Result<List<BidderBid>> result = facebookBidder.makeBids(httpCall, BidRequest.builder().build());

// then
Assertions.assertThat(result.getErrors()).isEmpty();
Assertions.assertThat(result.getValue()).isEmpty();
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).isEmpty();
}

@Test
Expand Down
4 changes: 0 additions & 4 deletions src/test/java/org/prebid/server/it/FacebookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static io.restassured.RestAssured.given;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;

@RunWith(SpringRunner.class)
public class FacebookTest extends IntegrationTest {
Expand All @@ -28,21 +27,18 @@ public void openrtb2AuctionShouldRespondWithBidsFromFacebook() throws IOExceptio
// facebook bid response for impId001
wireMockRule.stubFor(post(urlPathEqualTo("/audienceNetwork-exchange"))
.withHeader("X-Fb-Pool-Routing-Token", equalTo("FB-UID"))
.withHeader("Auth-Token", equalTo("123|67234"))
.withRequestBody(equalToJson(jsonFrom("openrtb2/facebook/test-facebook-bid-request-1.json")))
.willReturn(aResponse().withBody(jsonFrom("openrtb2/facebook/test-facebook-bid-response-1.json"))));

// facebook bid response for impId002
wireMockRule.stubFor(post(urlPathEqualTo("/audienceNetwork-exchange"))
.withHeader("X-Fb-Pool-Routing-Token", equalTo("FB-UID"))
.withHeader("Auth-Token", equalTo("123|67234"))
.withRequestBody(equalToJson(jsonFrom("openrtb2/facebook/test-facebook-bid-request-2.json")))
.willReturn(aResponse().withBody(jsonFrom("openrtb2/facebook/test-facebook-bid-response-2.json"))));

// facebook bid response for impId003
wireMockRule.stubFor(post(urlPathEqualTo("/audienceNetwork-exchange"))
.withHeader("X-Fb-Pool-Routing-Token", equalTo("FB-UID"))
.withHeader("Auth-Token", equalTo("123|67234"))
.withRequestBody(equalToJson(jsonFrom("openrtb2/facebook/test-facebook-bid-request-3.json")))
.willReturn(aResponse().withBody(jsonFrom("openrtb2/facebook/test-facebook-bid-response-3.json"))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ adapters.facebook.enabled=true
adapters.facebook.endpoint=http://localhost:8090/audienceNetwork-exchange
adapters.facebook.pbs-enforces-gdpr=true
adapters.facebook.platform-id=101
adapters.facebook.app-id=123
adapters.facebook.app-secret=67234
adapters.facebook.usersync.url=//facebook-usersync
adapters.gamma.enabled=true
Expand Down

0 comments on commit 7e59386

Please sign in to comment.