Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,4 @@ public boolean hasConsent(int vendorId, TransparentConsentPurpose ... purposes)
.reduce(0, (f, x) -> (f | (1 << x)))
& requiredBits) == requiredBits;
}

public boolean hasSpecialFeature(TransparentConsentSpecialFeature feature) {
return this.tcString.getSpecialFeatureOptIns().contains(feature.value);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.uid2.operator.privacy.tcf.TransparentConsent;
import com.uid2.operator.privacy.tcf.TransparentConsentParseResult;
import com.uid2.operator.privacy.tcf.TransparentConsentPurpose;
import com.uid2.operator.privacy.tcf.TransparentConsentSpecialFeature;
import com.uid2.operator.service.*;
import com.uid2.operator.store.*;
import com.uid2.operator.store.IConfigStore;
Expand Down Expand Up @@ -1632,9 +1631,7 @@ private UserConsentStatus validateUserConsent(JsonObject req, String apiContact)
TransparentConsentPurpose.MEASURE_AD_PERFORMANCE, // 7
TransparentConsentPurpose.DEVELOP_AND_IMPROVE_PRODUCTS // 10
);
final boolean allowPreciseGeo = tcResult.getTCString().hasSpecialFeature(TransparentConsentSpecialFeature.PreciseGeolocationData);

if (!userConsent || !allowPreciseGeo) {
if (!userConsent) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like TransparentConsentSpecialFeature is no longer used, should we remove it or remove the values it has currently?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok removed

return UserConsentStatus.INSUFFICIENT;
}
}
Expand Down
53 changes: 53 additions & 0 deletions src/test/java/com/uid2/operator/EUIDOperatorVerticleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import org.junit.jupiter.api.Test;

import com.iabtcf.encoder.TCStringEncoder;
import com.iabtcf.utils.BitSetIntIterable;
import com.uid2.operator.model.IdentityScope;
import com.uid2.shared.auth.Role;

import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.junit5.VertxTestContext;

import java.time.Instant;

import static org.junit.jupiter.api.Assertions.*;

class EUIDOperatorVerticleTest extends UIDOperatorVerticleTest {
Expand Down Expand Up @@ -75,5 +79,54 @@ void noContentOnInsufficientTcfConsent(Vertx vertx, VertxTestContext testContext
testContext.completeNow();
});
}

@Test
void consentPassesWhenPreciseGeolocationSpecialFeatureIsMissing(Vertx vertx, VertxTestContext testContext) {
final int clientSiteId = 201;
fakeAuth(clientSiteId, Role.GENERATOR);
setupSalts();
setupKeys();

final String emailAddress = "test@uid2.com";
final JsonObject v2Payload = new JsonObject();
v2Payload.put("email", emailAddress);
// TCF string with all required purposes but WITHOUT PreciseGeolocation special feature (feature 1)
String tcfStringWithoutPreciseGeolocation = createTcfConsentString(
new int[] { 21 }, // vendor consent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: Is it possible to rewrite this without needing createTcfConsentString?
e.g. TCStringEncoder.newBuilder().addVendorConsent(..)..addVendorLegitimateInterest(...)...

Only worthwhile if we don't have to include unrelated fields such as version().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i'll leave it for now

new int[] { 21 }, // vendor LI
new int[] { 1, 3, 4 }, // purpose consents (1, 3, 4)
new int[] { 2, 7, 10 }, // purpose LI (2, 7, 10)
new int[] {} // NO special features - PreciseGeolocation (1) is missing
);
v2Payload.put("tcf_consent_string", tcfStringWithoutPreciseGeolocation);
sendTokenGenerate(vertx, v2Payload, 200, json -> {
assertTrue(json.containsKey("body"));
assertEquals("success", json.getString("status"));
testContext.completeNow();
});
}

private String createTcfConsentString(int[] vendorConsent, int[] vendorLI, int[] purposesConsent, int[] purposesLI, int[] specialFeatureOptIns) {
return TCStringEncoder.newBuilder()
.version(2)
.created(Instant.now())
.lastUpdated(Instant.now())
.cmpId(1)
.cmpVersion(12)
.consentScreen(1)
.consentLanguage("FR")
.vendorListVersion(2)
.tcfPolicyVersion(1)
.isServiceSpecific(true)
.useNonStandardStacks(false)
.addSpecialFeatureOptIns(BitSetIntIterable.from(specialFeatureOptIns))
.publisherCC("DE")
.addVendorConsent(BitSetIntIterable.from(vendorConsent))
.addVendorLegitimateInterest(BitSetIntIterable.from(vendorLI))
.purposeOneTreatment(true)
.addPurposesConsent(BitSetIntIterable.from(purposesConsent))
.addPurposesLITransparency(BitSetIntIterable.from(purposesLI))
.encode();
}
}

Loading