Skip to content

Commit

Permalink
Adding new fields added to the GVL vendors. (#128)
Browse files Browse the repository at this point in the history
Co-authored-by: srini81 <[email protected]>
  • Loading branch information
srinivas81 and srini81 authored Sep 27, 2021
1 parent 12e6d61 commit 66e8951
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ target
.classpath
.project
.settings
iabtcf-decoder/iabtcf-decoder.iml
iabtcf-encoder/iabtcf-encoder.iml
iabtcf-extras/iabtcf-extras.iml
iabtcf-extras-jackson/iabtcf-extras-jackson.iml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iabtcf.extras.gvl.Overflow;

public class Vendor implements com.iabtcf.extras.gvl.Vendor {
Expand All @@ -39,6 +40,11 @@ public class Vendor implements com.iabtcf.extras.gvl.Vendor {
private String policyUrl;
private Instant deletedDate;
private com.iabtcf.extras.gvl.Overflow overflow;
private Integer cookieMaxAgeSeconds;
private boolean usesCookies;
private boolean cookieRefresh;
private boolean usesNonCookieAccess;
private String deviceStorageDisclosureUrl;

/**
* A vendor id: a numeric ID which is incrementally assigned and never re-used – deleted Vendors
Expand Down Expand Up @@ -169,4 +175,58 @@ public boolean isDeleted() {
.map(deletedDate -> !deletedDate.isAfter(Instant.now()))
.orElse(false);
}

/**
* The number of seconds representing the longest potential duration for cookie storage on a device.
*
* @return The number, in seconds, of the longest potential duration for storage on a device, as set when using the
* cookie method of storage.
*/
@Override
public Optional<Integer> getCookieMaxAgeSeconds() {
return Optional.ofNullable(cookieMaxAgeSeconds);
}

/**
* This boolean field indicates whether the vendor uses cookie storage (session or otherwise).
*
* @return True indicates cookie storage is used
*/
@Override
public boolean getUsesCookies() {
return usesCookies;
}

/**
* This boolean field indicates whether any cookies in scope for cookieMaxAgeSeconds are refreshed after being
* initially set.
*
* @return True indicates the vendor refreshes this cookie
*/
@Override
public boolean getHasCookieRefresh() {
return cookieRefresh;
}

/**
* This true or false field indicates whether the vendor uses other, non-cookie methods of storage or accessing
* information already stored on a user’s device. Examples of non-cookie storage and access may be localStorage,
* indexDB, mobile ad IDs, etc.
*
* @return True indicates non-cookie access is used
*/
@Override
public boolean getUsesNonCookieAccess() {
return usesNonCookieAccess;
}

/**
* Link to a recommended, vendor-hosted, secure URL for disclosing additional storage information
*
* @return Location of vendor-hosted deviceStorage.json file
*/
@Override
public Optional<String> getDeviceStorageDisclosureUrl() {
return Optional.ofNullable(deviceStorageDisclosureUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,23 @@
import org.junit.BeforeClass;
import org.junit.Test;

import com.iabtcf.extras.gvl.Gvl;
import com.iabtcf.extras.gvl.Vendor;
import com.iabtcf.extras.jackson.Loader;
import com.iabtcf.extras.jackson.TestUtil;

public class VendorTest {

private static Vendor vendorEight;
private static Vendor vendorTwo;
private static final int VENDOR_ID_SELECTED_FOR_TEST = 8;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
Loader loader = new Loader();
vendorEight = loader.globalVendorList(TestUtil.getGlobalVendorList()).getVendor(VENDOR_ID_SELECTED_FOR_TEST);
Gvl gvl = loader.globalVendorList(TestUtil.getGlobalVendorList());
vendorEight = gvl.getVendor(VENDOR_ID_SELECTED_FOR_TEST);
vendorTwo = gvl.getVendor(2);
}

@Test
Expand Down Expand Up @@ -114,4 +118,44 @@ public void testGetOverflow() {
public void testIsDeleted() {
Assert.assertTrue(vendorEight.isDeleted());
}

@Test
public void testCookieMaxAgeSeconds() {
int expectedCookieMaxAgeSeconds = 2678400;
Assert.assertTrue(vendorEight.getCookieMaxAgeSeconds().isPresent());
Assert.assertEquals(expectedCookieMaxAgeSeconds, vendorEight.getCookieMaxAgeSeconds().get().intValue());
}

@Test
public void testUsesCookies() {
Assert.assertTrue(vendorEight.getUsesCookies());
}

@Test
public void testCookieRefresh() {
Assert.assertFalse(vendorEight.getHasCookieRefresh());
}

@Test
public void testUsesNonCookieAccess() {
Assert.assertTrue(vendorEight.getUsesNonCookieAccess());
}

@Test
public void testNullDeviceStorageDisclosureUrl() {
Assert.assertFalse(vendorEight.getDeviceStorageDisclosureUrl().isPresent());
}

@Test
public void testNullCookieMaxAgeSeconds() {
Assert.assertFalse(vendorTwo.getUsesCookies());
Assert.assertFalse(vendorTwo.getCookieMaxAgeSeconds().isPresent());
}

@Test
public void testDeviceStorageDisclosureUrl() {
String expectedDeviceStorageDisclosureUrl = "https://privacy.blismedia.com/.well-known/deviceStorage.json";
Assert.assertTrue(vendorTwo.getDeviceStorageDisclosureUrl().isPresent());
Assert.assertEquals(expectedDeviceStorageDisclosureUrl, vendorTwo.getDeviceStorageDisclosureUrl().get());
}
}
20 changes: 17 additions & 3 deletions iabtcf-extras-jackson/src/test/resources/gvl.json
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@
2,
3,
4,
4,
7,
8,
10
Expand All @@ -587,7 +588,11 @@
2
],
"policyUrl": "https://pubnative.net/privacy-notice/",
"deletedDate": "2019-02-28T00:00:00Z"
"deletedDate": "2019-02-28T00:00:00Z",
"cookieMaxAgeSeconds": null,
"usesCookies": false,
"cookieRefresh": false,
"usesNonCookieAccess": false
},
"8": {
"id": 8,
Expand Down Expand Up @@ -620,7 +625,11 @@
"deletedDate": "2020-06-28T00:00:00Z",
"overflow": {
"httpGetLimit": 32
}
},
"cookieMaxAgeSeconds": 2678400,
"usesCookies": true,
"cookieRefresh": false,
"usesNonCookieAccess": true
},
"2": {
"id": 2,
Expand All @@ -644,7 +653,12 @@
2
],
"specialFeatures": [ ],
"policyUrl": "http://www.captify.co.uk/privacy-policy/"
"policyUrl": "http://www.captify.co.uk/privacy-policy/",
"cookieMaxAgeSeconds": null,
"usesCookies": false,
"cookieRefresh": true,
"usesNonCookieAccess": true,
"deviceStorageDisclosureUrl": "https://privacy.blismedia.com/.well-known/deviceStorage.json"
}
}
}
41 changes: 41 additions & 0 deletions iabtcf-extras/src/main/java/com/iabtcf/extras/gvl/Vendor.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,45 @@ public interface Vendor {
* @return true, if the vendor is deleted
*/
boolean isDeleted();

/**
* The number of seconds representing the longest potential duration for cookie storage on a device.
* If a Vendor uses multiple cookies with differing durations, cookieMaxAgeSeconds represents the cookie with
* the longest duration. Note: cookies are the only method of storage or device access that permit a predictable
* duration to be set.
* This is required only if usesCookies is set to true, else optional
* @return The number, in seconds, of the longest potential duration for storage on a device, as set when using
* the cookie method of storage. A negative number or a 0 indicate session storage similar to the Set-Cookie spec.
* A "-100" value no longer indicates no cookie usage.
* Note: this only includes what is declared when the storage is set and does not consider duration extensions
* should storage be refreshed
*/
Optional<Integer> getCookieMaxAgeSeconds();

/**
* This boolean field indicates whether the vendor uses cookie storage (session or otherwise).
* @return True indicates cookie storage is used
*/
boolean getUsesCookies();

/**
* This true or false field indicates whether any cookies in scope for cookieMaxAgeSeconds are refreshed after
* being initially set.
* @return True indicates the vendor refreshes this cookie
*/
boolean getHasCookieRefresh();

/**
* This boolean field indicates whether the vendor uses other, non-cookie methods of storage or accessing
* information already stored on a user’s device. Examples of non-cookie storage and access may be localStorage,
* indexDB, mobile ad IDs, etc.
* @return True indicates non-cookie access is used
*/
boolean getUsesNonCookieAccess();

/**
* Link to a recommended, vendor-hosted, secure URL for disclosing additional storage information
* @return Location of vendor-hosted deviceStorage.json file
*/
Optional<String> getDeviceStorageDisclosureUrl();
}

0 comments on commit 66e8951

Please sign in to comment.