Skip to content

Commit

Permalink
Fix Rubicon eids striping (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanchyk authored Sep 24, 2020
1 parent 7748869 commit 46fc6b0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ private User makeUser(User user, ExtImpRubicon rubiconImpExt) {
final User.UserBuilder userBuilder = user != null ? user.toBuilder() : User.builder();

return userBuilder
.id(resolvedId)
.id(ObjectUtils.defaultIfNull(resolvedId, userId))
.gender(null)
.yob(null)
.geo(null)
Expand Down Expand Up @@ -783,10 +783,10 @@ private static ExtUserEid prepareExtUserEid(ExtUserEid extUserEid) {

private static ExtUserEidUid cleanExtUserEidUidStype(ExtUserEidUid extUserEidUid) {
final ExtUserEidUidExt extUserEidUidExt = extUserEidUid.getExt();
return STYPE_TO_REMOVE.contains(extUserEidUidExt.getStype())
? ExtUserEidUid.of(extUserEidUid.getId(), extUserEidUid.getAtype(),
ExtUserEidUidExt.of(extUserEidUidExt.getRtiPartner(), null))
: extUserEidUid;
return extUserEidUidExt == null || !STYPE_TO_REMOVE.contains(extUserEidUidExt.getStype())
? extUserEidUid
: ExtUserEidUid.of(extUserEidUid.getId(), extUserEidUid.getAtype(),
ExtUserEidUidExt.of(extUserEidUidExt.getRtiPartner(), null));
}

private static Map<String, List<ExtUserEid>> specialExtUserEids(List<ExtUserEid> eids) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,31 @@ public void makeHttpRequestsShouldCreateUserExtTpIdWithAdServerEidSource() {
.build()));
}

@Test
public void makeHttpRequestsShouldUseGivenUserIdIfOtherExtUserFieldsPassed() {
// given
final ExtUser extUser = ExtUser.builder()
.eids(singletonList(ExtUserEid.of("liveramp.com", null,
singletonList(ExtUserEidUid.of("firstId", null, null)), null)))
.build();
final BidRequest bidRequest = givenBidRequest(builder -> builder.user(User.builder()
.id("userId")
.ext(extUser)
.build()),
builder -> builder.video(Video.builder().build()), identity());

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

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1).doesNotContainNull()
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.extracting(BidRequest::getUser)
.extracting(User::getId)
.containsOnly("userId");
}

@Test
public void makeHttpRequestsShouldCreateUserIdIfMissingFromFirstUidStypePpuid() {
// given
Expand Down Expand Up @@ -809,7 +834,7 @@ public void makeHttpRequestsShouldCreateUserIdIfMissingFromFirstUidStypePpuid()
}

@Test
public void makeHttpRequestsShouldNotCreateUseIdIfMissingWhenNoUidWithPpuidType() {
public void makeHttpRequestsShouldNotCreateUserIdIfMissingWhenNoUidWithPpuidType() {
// given
final BidRequest bidRequest = givenBidRequest(builder -> builder.user(User.builder()
.ext(ExtUser.builder()
Expand Down Expand Up @@ -857,14 +882,14 @@ public void makeHttpRequestsShouldRemoveStypesPpuidSha256emailDmp() {
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.extracting(request -> request.getUser().getExt()).hasSize(1).element(0)
.isEqualTo(ExtUser.builder()
.eids(singletonList(ExtUserEid.of("source", "id",
asList(
ExtUserEidUid.of("id1", null, ExtUserEidUidExt.of(null, "other")),
ExtUserEidUid.of("id2", null, ExtUserEidUidExt.of(null, null)),
ExtUserEidUid.of("id3", null, ExtUserEidUidExt.of(null, null)),
ExtUserEidUid.of("id4", null, ExtUserEidUidExt.of(null, null))),
null)))
.build());
.eids(singletonList(ExtUserEid.of("source", "id",
asList(
ExtUserEidUid.of("id1", null, ExtUserEidUidExt.of(null, "other")),
ExtUserEidUid.of("id2", null, ExtUserEidUidExt.of(null, null)),
ExtUserEidUid.of("id3", null, ExtUserEidUidExt.of(null, null)),
ExtUserEidUid.of("id4", null, ExtUserEidUidExt.of(null, null))),
null)))
.build());
}

@Test
Expand Down

0 comments on commit 46fc6b0

Please sign in to comment.