From bb09799f99fa9ae476cf8e79552cfcd28a7dd58e Mon Sep 17 00:00:00 2001 From: Mohammad Nurul Islam Shihan <93646635+ishihanvcs@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:18:55 +0600 Subject: [PATCH] Improvedigital: Consent processor issue fix (#2954) Co-authored-by: Mohammad Nurul Islam Shihan --- .../improvedigital/ImprovedigitalBidder.java | 5 ++-- .../ImprovedigitalBidderTest.java | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidder.java b/src/main/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidder.java index 4eba83445be..99b56d59f8a 100644 --- a/src/main/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidder.java +++ b/src/main/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidder.java @@ -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; } diff --git a/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java b/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java index f1d3e654978..439be3a40e6 100644 --- a/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java +++ b/src/test/java/org/prebid/server/bidder/improvedigital/ImprovedigitalBidderTest.java @@ -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>> 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