Skip to content

Commit 9260a35

Browse files
CTMBNaraosulzhenko
authored andcommitted
Revert "Core: Pad GPP consent string sections" (#3963)
1 parent 950672f commit 9260a35

5 files changed

Lines changed: 9 additions & 102 deletions

File tree

src/main/java/org/prebid/server/auction/gpp/model/GppModelWrapper.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,7 @@ public class GppModelWrapper extends GppModel {
1717
private IntObjectMap<String> sectionIdToEncodedString;
1818

1919
public GppModelWrapper(String encodedString) throws DecodingException {
20-
super(padSections(encodedString));
21-
}
22-
23-
private static String padSections(String gpp) {
24-
final StringBuilder gppBuilder = new StringBuilder(gpp);
25-
26-
int subsectionStart = 0;
27-
int offset = 0;
28-
for (int i = 1; i < gpp.length(); i++) {
29-
final char currentChar = gpp.charAt(i);
30-
31-
if (currentChar == '~' || currentChar == '.') {
32-
if ((i - subsectionStart) % 4 != 0 && gpp.charAt(i - 1) != '=') {
33-
gppBuilder.insert(i + offset, "A");
34-
offset++;
35-
}
36-
37-
subsectionStart = i + 1;
38-
}
39-
}
40-
41-
final int lastSubsectionLength = gpp.length() - subsectionStart;
42-
if (lastSubsectionLength > 0 && lastSubsectionLength % 4 != 0 && !gpp.endsWith("=")) {
43-
gppBuilder.append("A");
44-
}
45-
46-
return gppBuilder.toString();
20+
super(encodedString);
4721
}
4822

4923
private void init() {

src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitEidsActivitiesSpec.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ import static org.prebid.server.functional.model.request.auction.PrivacyModule.I
7676
import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC
7777
import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL
7878
import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE
79-
import static org.prebid.server.functional.model.response.auction.ErrorType.PREBID
8079
import static org.prebid.server.functional.util.privacy.model.State.ALABAMA
8180
import static org.prebid.server.functional.util.privacy.model.State.ONTARIO
8281

src/test/groovy/org/prebid/server/functional/tests/privacy/GppTransmitUfpdActivitiesSpec.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ import org.prebid.server.functional.model.request.amp.AmpRequest
1515
import org.prebid.server.functional.model.request.auction.Activity
1616
import org.prebid.server.functional.model.request.auction.ActivityRule
1717
import org.prebid.server.functional.model.request.auction.AllowActivities
18+
import org.prebid.server.functional.model.request.auction.BidRequest
1819
import org.prebid.server.functional.model.request.auction.Condition
20+
import org.prebid.server.functional.model.request.auction.Data
1921
import org.prebid.server.functional.model.request.auction.Device
22+
import org.prebid.server.functional.model.request.auction.Eid
2023
import org.prebid.server.functional.model.request.auction.Geo
2124
import org.prebid.server.functional.model.request.auction.RegsExt
25+
import org.prebid.server.functional.model.request.auction.User
26+
import org.prebid.server.functional.model.request.auction.UserExt
27+
import org.prebid.server.functional.model.request.auction.UserExtData
2228
import org.prebid.server.functional.service.PrebidServerException
2329
import org.prebid.server.functional.util.PBSUtils
2430
import org.prebid.server.functional.util.privacy.gpp.UsCaV1Consent
@@ -80,7 +86,6 @@ import static org.prebid.server.functional.model.request.auction.PrivacyModule.I
8086
import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_CUSTOM_LOGIC
8187
import static org.prebid.server.functional.model.request.auction.PrivacyModule.IAB_US_GENERAL
8288
import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE
83-
import static org.prebid.server.functional.model.response.auction.ErrorType.PREBID
8489
import static org.prebid.server.functional.util.privacy.model.State.ALABAMA
8590
import static org.prebid.server.functional.util.privacy.model.State.ONTARIO
8691

src/test/java/org/prebid/server/auction/gpp/model/GppContextCreatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void fromShouldReturnGppContextWrapperWithErrorOnInvalidGpp() {
3737
assertThat(gppContext.regions()).isEqualTo(GppContext.Regions.builder().build());
3838
});
3939
assertThat(gppContextWrapper.getErrors())
40-
.containsExactly("GPP string invalid: Unable to decode 'invalidA'");
40+
.containsExactly("GPP string invalid: Unable to decode 'invalid'");
4141
}
4242

4343
@Test

src/test/java/org/prebid/server/auction/gpp/model/GppModelWrapperTest.java

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
import com.iab.gpp.encoder.error.EncodingException;
66
import com.iab.gpp.encoder.section.HeaderV1;
77
import com.iab.gpp.encoder.section.TcfEuV2;
8-
import com.iab.gpp.encoder.section.UsNat;
98
import com.iab.gpp.encoder.section.UspV1;
109
import org.junit.jupiter.api.Test;
1110

1211
import java.util.Comparator;
13-
import java.util.List;
1412

1513
import static org.assertj.core.api.Assertions.assertThat;
16-
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
17-
import static org.assertj.core.api.Assertions.assertThatNoException;
1814

1915
public class GppModelWrapperTest {
2016

@@ -39,7 +35,7 @@ public class GppModelWrapperTest {
3935
+ "1YN-";
4036

4137
@Test
42-
public void wrapperShouldStoreSomeOfOriginalSections() throws DecodingException, EncodingException {
38+
public void test() throws DecodingException, EncodingException {
4339
// given and when
4440
final GppModel originalGpp = new GppModel(GPP_STRING);
4541
final GppModel wrappedGpp = new GppModelWrapper(GPP_STRING);
@@ -52,73 +48,6 @@ public void wrapperShouldStoreSomeOfOriginalSections() throws DecodingException,
5248
assertThat(wrappedGpp.encodeSection(UspV1.ID)).isEqualTo(originalGpp.encodeSection(UspV1.ID));
5349
}
5450

55-
@Test
56-
public void wrapperShouldPadSectionsIfNeeded() {
57-
// given
58-
final List<String> samples = List.of(
59-
"DBABLA~BVQqAAAAAg",
60-
"DBABLA~BVVqCAAACg",
61-
"DBABLA~BVVVBAAABg",
62-
"DBABLA~BVVqCACACg",
63-
"DBABLA~BVQVAAAAAg",
64-
"DBABLA~BVVVBABABg");
65-
66-
for (String sample : samples) {
67-
// when
68-
final GppModel originalGpp = new GppModel(sample);
69-
final GppModel wrappedGpp = new GppModelWrapper(sample);
70-
71-
// then
72-
assertThatExceptionOfType(DecodingException.class)
73-
.isThrownBy(() -> originalGpp.getUsNatSection().getMspaCoveredTransaction());
74-
assertThatNoException()
75-
.isThrownBy(() -> wrappedGpp.getUsNatSection().getMspaCoveredTransaction());
76-
}
77-
}
78-
79-
@Test
80-
public void wrapperShouldNotModifyValidBase64SubsectionsWithPadChars() {
81-
// given
82-
final String gpp = "DBABLA~BVVVQAAARlA=.QA==";
83-
84-
// when
85-
final GppModel wrappedGpp = new GppModelWrapper(gpp);
86-
87-
// then
88-
assertThat(wrappedGpp.encodeSection(UsNat.ID)).isEqualTo("BVVVQAAARlA=.QA==");
89-
}
90-
91-
@Test
92-
public void wrapperShouldNotModifyValidBase64SubsectionsWithoutPadChars() {
93-
// given
94-
final String gpp = "DBABLA~CqqqgAAAAIJo.YA==";
95-
96-
// when
97-
final GppModel wrappedGpp = new GppModelWrapper(gpp);
98-
99-
// then
100-
assertThat(wrappedGpp.encodeSection(UsNat.ID)).isEqualTo("CqqqgAAAAIJo.YA==");
101-
assertThatNoException()
102-
.isThrownBy(() -> wrappedGpp.getUsNatSection().getMspaCoveredTransaction());
103-
}
104-
105-
@Test
106-
public void wrapperShouldPadSubsections() {
107-
// given
108-
final String gpp = "DBABLA~BVVVQAAARl.Q";
109-
110-
// when
111-
final GppModel originalGpp = new GppModel(gpp);
112-
final GppModel wrappedGpp = new GppModelWrapper(gpp);
113-
114-
// then
115-
assertThat(wrappedGpp.encodeSection(UsNat.ID)).isEqualTo("BVVVQAAARlA.QA");
116-
assertThatExceptionOfType(DecodingException.class)
117-
.isThrownBy(() -> originalGpp.getUsNatSection().getMspaCoveredTransaction());
118-
assertThatNoException()
119-
.isThrownBy(() -> wrappedGpp.getUsNatSection().getMspaCoveredTransaction());
120-
}
121-
12251
public static String normalizeEncodedTcfEuV2Section(String encodedSection) {
12352
try {
12453
final GppModel normalizer = new GppModel();

0 commit comments

Comments
 (0)