Skip to content

Commit

Permalink
Improvedigital: Consent processor issue fix (#2954)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohammad Nurul Islam Shihan <islam.shihan@ext.azerion.dev>
  • Loading branch information
ishihanvcs and Mohammad Nurul Islam Shihan authored Feb 14, 2024
1 parent 2322dfc commit bb09799
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ private ExtUser getAdditionalConsentProvidersUserExt(ExtUser extUser) {
return extUser;
}

final String consentedProvidersPart = StringUtils.substringAfter(consentedProviders, "~");
if (StringUtils.isEmpty(consentedProvidersPart)) {
final String[] consentedProvidersParts = StringUtils.split(consentedProviders, "~");
final String consentedProvidersPart = consentedProvidersParts.length > 1 ? consentedProvidersParts[1] : null;
if (StringUtils.isBlank(consentedProvidersPart)) {
return extUser;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,35 @@ public void makeHttpRequestsShouldProperProcessConsentedProvidersSetting() {
.containsExactly(expectedExtUser);
}

@Test
public void makeHttpRequestsShouldProperProcessConsentedProvidersSettingWithMultipleTilda() {
// given
final ExtUser extUser = ExtUser.builder()
.consentedProvidersSettings(ConsentedProvidersSettings.of("1~10.20.90~anything"))
.build();

final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> bidRequestBuilder
.id("123")
.user(User.builder().ext(extUser).build())
.id("request_id"), identity());

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

// then
final ExtUser expectedExtUser = jacksonMapper.fillExtension(extUser,
mapper.createObjectNode().set("consented_providers_settings",
mapper.createObjectNode()
.set("consented_providers", mapper.createArrayNode().add(10).add(20).add(90))));

assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.extracting(BidRequest::getUser)
.extracting(User::getExt)
.containsExactly(expectedExtUser);
}

@Test
public void makeHttpRequestsShouldReturnUserExtIfConsentedProvidersIsNotProvided() {
// given
Expand Down

0 comments on commit bb09799

Please sign in to comment.