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

Skip bids with invalid extension and add error #1135

Merged
merged 3 commits into from
Feb 17, 2021
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
5 changes: 3 additions & 2 deletions src/main/java/org/prebid/server/bidder/amx/AmxBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class AmxBidder implements Bidder<BidRequest> {
new TypeReference<ExtPrebid<?, ExtImpAmx>>() {
};

private static final String ADAPTER_VERSION = "pbs1.0";
private static final String ADAPTER_VERSION = "pbs1.1";
private static final String VERSION_PARAM = "v";
private static final String VAST_SEARCH_POINT = "</Impression>";
private static final String VAST_IMPRESSION_FORMAT = "<Impression><![CDATA[%s]]></Impression>";
Expand Down Expand Up @@ -162,11 +162,12 @@ private List<BidderBid> bidsFromResponse(BidResponse bidResponse, List<BidderErr
}

private BidderBid createBidderBid(Bid bid, String cur, List<BidderError> errors) {
AmxBidExt amxBidExt = null;
final AmxBidExt amxBidExt;
try {
amxBidExt = parseBidderExt(bid.getExt());
} catch (PreBidException e) {
errors.add(BidderError.badInput(e.getMessage()));
return null;
}

final BidType bidType = getMediaType(amxBidExt);
Expand Down
27 changes: 26 additions & 1 deletion src/test/java/org/prebid/server/bidder/amx/AmxBidderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() {
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1)
.extracting(HttpRequest::getUri)
.containsExactly("https://test.com/prebid/bid?v=pbs1.0");
.containsExactly("https://test.com/prebid/bid?v=pbs1.1");
}

@Test
Expand Down Expand Up @@ -215,6 +215,31 @@ public void makeBidsShouldReturnErrorIfAdmNotContainSearchPoint() throws JsonPro
BidderError.badServerResponse("Adm should contain vast search point in bidder: bidId"));
}

@Test
public void makeBidsShouldSkipBidAndAddErrorIfFailedToParseBidExt() throws JsonProcessingException {
// given
final ObjectNode bidExt = mapper.createObjectNode();
bidExt.put("startdelay", "2");
final HttpCall<BidRequest> httpCall = givenHttpCall(BidRequest.builder().build(),
mapper.writeValueAsString(
givenBidResponse(bidBuilder -> bidBuilder
.id("bidId")
.adm("</Impression>")
.ext(mapper.createObjectNode().set("startdelay", mapper.createObjectNode())))));

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

// then
assertThat(result.getErrors()).hasSize(1)
.satisfies(error -> {
assertThat(error).extracting(BidderError::getType).containsExactly(BidderError.Type.bad_input);
assertThat(error).extracting(BidderError::getMessage)
.element(0).asString().startsWith("Cannot deserialize instance");
});
assertThat(result.getValue()).isEmpty();
}

@Test
public void makeBidsShouldReturnErrorIfAdmIsNotPresent() throws JsonProcessingException {
// given
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/prebid/server/it/AmxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void openrtb2AuctionShouldRespondWithBidsFromAmx() throws IOException, JS
// given
// Amx bid response for imp
WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/amx-exchange"))
.withQueryParam("v", equalTo("pbs1.0"))
.withQueryParam("v", equalTo("pbs1.1"))
.withHeader("Content-Type", equalToIgnoreCase("application/json;charset=UTF-8"))
.withRequestBody(equalToJson(jsonFrom("openrtb2/amx/test-amx-bid-request.json")))
.willReturn(aResponse().withBody(
Expand Down