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

Bizzclick: host parameter update #2962

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -9,6 +9,7 @@
import io.vertx.core.MultiMap;
import io.vertx.core.http.HttpMethod;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.prebid.server.bidder.Bidder;
import org.prebid.server.bidder.model.BidderBid;
import org.prebid.server.bidder.model.BidderCall;
Expand All @@ -33,6 +34,8 @@ public class BizzclickBidder implements Bidder<BidRequest> {
private static final TypeReference<ExtPrebid<?, ExtImpBizzclick>> BIZZCLICK_EXT_TYPE_REFERENCE =
new TypeReference<>() {
};
private static final String DEFAULT_HOST = "us-e-node1";
private static final String URL_HOST_MACRO = "{{.Host}}";
VeryExtraordinaryUsername marked this conversation as resolved.
Show resolved Hide resolved
private static final String URL_SOURCE_ID_MACRO = "{{.SourceId}}";
private static final String URL_ACCOUNT_ID_MACRO = "{{.AccountID}}";
private static final String DEFAULT_CURRENCY = "USD";
Expand Down Expand Up @@ -100,7 +103,11 @@ private static MultiMap headers(Device device) {
}

private String buildEndpointUrl(ExtImpBizzclick ext) {
return endpointUrl.replace(URL_SOURCE_ID_MACRO, HttpUtil.encodeUrl(ext.getPlacementId()))
final String host = StringUtils.isEmpty(ext.getHost()) ? DEFAULT_HOST : ext.getHost();
VeryExtraordinaryUsername marked this conversation as resolved.
Show resolved Hide resolved
final String sourceId = StringUtils.isEmpty(ext.getSourceId()) ? ext.getPlacementId() : ext.getSourceId();
VeryExtraordinaryUsername marked this conversation as resolved.
Show resolved Hide resolved
return endpointUrl
.replace(URL_HOST_MACRO, HttpUtil.encodeUrl(host))
.replace(URL_SOURCE_ID_MACRO, HttpUtil.encodeUrl(sourceId))
.replace(URL_ACCOUNT_ID_MACRO, HttpUtil.encodeUrl(ext.getAccountId()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
@Value(staticConstructor = "of")
public class ExtImpBizzclick {

@JsonProperty("host")
String host;

@JsonProperty("accountId")
String accountId;

@JsonProperty("placementId")
String placementId;

@JsonProperty("sourceId")
String sourceId;
}
2 changes: 1 addition & 1 deletion src/main/resources/bidder-config/bizzclick.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
adapters:
bizzclick:
endpoint: http://us-e-node1.bizzclick.com/bid?rtb_seat_id={{.SourceId}}&secret_key={{.AccountID}}
endpoint: http://{{.Host}}.bizzclick.com/bid?rtb_seat_id={{.SourceId}}&secret_key={{.AccountID}}
VeryExtraordinaryUsername marked this conversation as resolved.
Show resolved Hide resolved
meta-info:
maintainer-email: [email protected]
app-media-types:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@

public class BizzclickBidderTest extends VertxTest {

private static final String ENDPOINT = "https://test.domain.dm/uri?source={{.SourceId}}&account={{.AccountID}}";
private static final String ENDPOINT = "https://{{.Host}}/uri?source={{.SourceId}}&account={{.AccountID}}";
private static final String DEFAULT_HOST = "host";
private static final String DEFAULT_ACCOUNT_ID = "accountId";
private static final String DEFAULT_SOURCE_ID = "sourceId";
private static final String DEFAULT_PLACEMENT_ID = "placementId";

private final BizzclickBidder target = new BizzclickBidder(ENDPOINT, jacksonMapper);

Expand Down Expand Up @@ -65,7 +69,7 @@ public void makeHttpRequestsShouldReturnErrorWhenImpExtCouldNotBeParsed() {
public void makeHttpRequestsShouldRelyOnlyOnFirstImpExt() {
// given
final BidRequest bidRequest = givenBidRequest(
givenImp("accountId", "placementId"),
givenImp(),
givenImp(imp -> imp.ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))));

// when
Expand All @@ -83,8 +87,8 @@ public void makeHttpRequestsShouldRelyOnlyOnFirstImpExt() {
public void makeHttpRequestsShouldRemoveExtFromEachImp() {
// given
final BidRequest bidRequest = givenBidRequest(
givenImp("accountId1", "placementId1"),
givenImp("accountId2", "placementId2"));
givenImp("host", "accountId1", "placementId1", "sourceId1"),
givenImp("host", "accountId2", "placementId2", "sourceId2"));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand All @@ -101,7 +105,7 @@ public void makeHttpRequestsShouldRemoveExtFromEachImp() {
@Test
public void makeHttpRequestsShouldCreateRequestWithXOpenRtbVersionHeader() {
// given
final BidRequest bidRequest = givenBidRequest(givenImp("accountId", "placementId"));
final BidRequest bidRequest = givenBidRequest(givenImp());

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand All @@ -120,7 +124,7 @@ public void makeHttpRequestsShouldCreateRequestWithUserAgentHeaderIfDeviceUaPres
// given
final BidRequest bidRequest = givenBidRequest(
device -> device.ua("ua"),
givenImp("accountId", "placementId"));
givenImp());

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand All @@ -139,7 +143,7 @@ public void makeHttpRequestsShouldCreateRequestWithXForwardedForHeaderIfDeviceIp
// given
final BidRequest bidRequest = givenBidRequest(
device -> device.ipv6("ipv6"),
givenImp("accountId", "placementId"));
givenImp());

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand All @@ -158,7 +162,7 @@ public void makeHttpRequestsShouldCreateRequestWithXForwardedForHeaderIfDeviceIp
// given
final BidRequest bidRequest = givenBidRequest(
device -> device.ip("ip"),
givenImp("accountId", "placementId"));
givenImp());

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand All @@ -177,7 +181,7 @@ public void makeHttpRequestsShouldCreateRequestWithXForwardedForHeaderWithDevice
// given
final BidRequest bidRequest = givenBidRequest(
device -> device.ip("ip").ipv6("ipv6"),
givenImp("accountId", "placementId"));
givenImp());

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand All @@ -194,23 +198,49 @@ public void makeHttpRequestsShouldCreateRequestWithXForwardedForHeaderWithDevice
@Test
public void makeHttpRequestsShouldCreateSingleRequestWithExpectedUri() {
// given
final BidRequest bidRequest = givenBidRequest(givenImp("account id", "placement id"));
final BidRequest bidRequest = givenBidRequest(givenImp());

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

// then
assertThat(result.getValue())
.extracting(HttpRequest::getUri)
.containsExactly("https://test.domain.dm/uri?source=placement+id&account=account+id");
.containsExactly(
String.format("https://%s/uri?source=%s&account=%s",
DEFAULT_HOST,
DEFAULT_SOURCE_ID,
DEFAULT_ACCOUNT_ID));
assertThat(result.getErrors()).isEmpty();
}

@Test
public void makeHttpRequestsShouldCreateSingleRequestWithExpectedAlternativeUri() {
// given
final String expectedDefaultHost = "us-e-node1";
final BidRequest bidRequest = givenBidRequest(
givenImp(expectedDefaultHost, DEFAULT_ACCOUNT_ID, DEFAULT_PLACEMENT_ID, null)
);

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

// then
assertThat(result.getValue())
.extracting(HttpRequest::getUri)
.containsExactly(
String.format("https://%s/uri?source=%s&account=%s",
expectedDefaultHost,
DEFAULT_PLACEMENT_ID,
DEFAULT_ACCOUNT_ID));
assertThat(result.getErrors()).isEmpty();
}

@Test
public void makeHttpRequestsShouldCreateSingleRequest() {
// given
final BidRequest bidRequest = givenBidRequest(
givenImp("accountId", "placementId"),
givenImp(),
givenImp(identity()));

// when
Expand Down Expand Up @@ -417,8 +447,17 @@ private Imp givenImp(UnaryOperator<Imp.ImpBuilder> impCustomizer) {
return impCustomizer.apply(Imp.builder()).build();
}

private Imp givenImp(String accountId, String placementId) {
final ExtPrebid<?, ?> ext = ExtPrebid.of(null, ExtImpBizzclick.of(accountId, placementId));
private Imp givenImp() {
final ExtPrebid<?, ?> ext = ExtPrebid.of(null, ExtImpBizzclick.of(
DEFAULT_HOST, DEFAULT_ACCOUNT_ID, DEFAULT_PLACEMENT_ID, DEFAULT_SOURCE_ID
));
return givenImp(imp -> imp.ext(mapper.valueToTree(ext)));
}

private Imp givenImp(String host, String accountId, String placementId, String sourceId) {
final ExtPrebid<?, ?> ext = ExtPrebid.of(
null, ExtImpBizzclick.of(host, accountId, placementId, sourceId)
);
return givenImp(imp -> imp.ext(mapper.valueToTree(ext)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"ext": {
"bizzclick": {
"host": "host",
"accountId": "accountId",
"placementId": "placementId"
AntoxaAntoxic marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Loading