Skip to content

Commit 79530fa

Browse files
committed
Test that vendor IDs outside range [1, MaxVendorID] are not allowed
1 parent 7bf67de commit 79530fa

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/test/java/com/iab/gdpr/consent/implementation/v1/ByteBufferBackedVendorConsentTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ public void testBitFieldEncoding() {
237237
assertFalse(vendorConsent.isVendorAllowed(3));
238238
assertFalse(vendorConsent.isVendorAllowed(31));
239239
assertFalse(vendorConsent.isVendorAllowed(32));
240+
241+
// Vendors outside range [1, MaxVendorId] are not allowed
242+
assertFalse(vendorConsent.isVendorAllowed(-99));
243+
assertFalse(vendorConsent.isVendorAllowed(-1));
244+
assertFalse(vendorConsent.isVendorAllowed(0));
245+
assertFalse(vendorConsent.isVendorAllowed(33));
246+
assertFalse(vendorConsent.isVendorAllowed(34));
247+
assertFalse(vendorConsent.isVendorAllowed(99));
240248
}
241249

242250
@Test
@@ -275,6 +283,14 @@ public void testRangeEncodingDefaultFalse() {
275283
assertFalse(vendorConsent.isVendorAllowed(28));
276284
assertFalse(vendorConsent.isVendorAllowed(31));
277285
assertFalse(vendorConsent.isVendorAllowed(32));
286+
287+
// Vendors outside range [1, MaxVendorId] are not allowed
288+
assertFalse(vendorConsent.isVendorAllowed(-99));
289+
assertFalse(vendorConsent.isVendorAllowed(-1));
290+
assertFalse(vendorConsent.isVendorAllowed(0));
291+
assertFalse(vendorConsent.isVendorAllowed(33));
292+
assertFalse(vendorConsent.isVendorAllowed(34));
293+
assertFalse(vendorConsent.isVendorAllowed(99));
278294
}
279295

280296
@Test
@@ -313,6 +329,14 @@ public void testRangeEncodingDefaultTrue() {
313329
assertTrue(vendorConsent.isVendorAllowed(15));
314330
assertTrue(vendorConsent.isVendorAllowed(31));
315331
assertTrue(vendorConsent.isVendorAllowed(32));
332+
333+
// Vendors outside range [1, MaxVendorId] are not allowed
334+
assertFalse(vendorConsent.isVendorAllowed(-99));
335+
assertFalse(vendorConsent.isVendorAllowed(-1));
336+
assertFalse(vendorConsent.isVendorAllowed(0));
337+
assertFalse(vendorConsent.isVendorAllowed(33));
338+
assertFalse(vendorConsent.isVendorAllowed(34));
339+
assertFalse(vendorConsent.isVendorAllowed(99));
316340
}
317341

318342
@Test(expected = VendorConsentParseException.class)
@@ -548,4 +572,4 @@ public void testRealString6() {
548572
assertTrue(vendorConsent.isVendorAllowed(1000));
549573
}
550574

551-
}
575+
}

0 commit comments

Comments
 (0)