Skip to content

Commit

Permalink
Merge pull request #233 from IABTechLab/cbc-UID2-1403-tcf-optional
Browse files Browse the repository at this point in the history
Made tcf string optional
  • Loading branch information
cody-constine-ttd authored Sep 28, 2023
2 parents 5ed0d1b + 5cdb236 commit 273967d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,8 @@ private InputUtil.InputVal[] createInputListV1(JsonArray a, IdentityType identit
}

private UserConsentStatus validateUserConsent(JsonObject req) {
if (identityScope.equals(IdentityScope.EUID)) {
// TCF string is an optional parameter and we should only check tcf if in EUID and the string is present
if (identityScope.equals(IdentityScope.EUID) && req.containsKey("tcf_consent_string")) {
TransparentConsentParseResult tcResult = this.getUserConsentV2(req);
if (!tcResult.isSuccess()) {
return UserConsentStatus.INVALID;
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/com/uid2/operator/EUIDOperatorVerticleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ void badRequestOnInvalidTcfConsent(Vertx vertx, VertxTestContext testContext) {
sendTokenGenerate("v2", vertx, "", v2Payload, 400, json -> testContext.completeNow());
}

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

final String emailAddress = "[email protected]";
final JsonObject v2Payload = new JsonObject();
v2Payload.put("email", emailAddress);
sendTokenGenerate("v2", vertx, "", v2Payload, 200, json -> testContext.completeNow(), false);

}

@Test
void noContentOnInsufficientTcfConsent(Vertx vertx, VertxTestContext testContext) {
final int clientSiteId = 201;
Expand Down
15 changes: 11 additions & 4 deletions src/test/java/com/uid2/operator/UIDOperatorVerticleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,23 @@ private void send(String apiVersion, Vertx vertx, String endpoint, boolean isV1G

protected void sendTokenGenerate(String apiVersion, Vertx vertx, String v1GetParam, JsonObject v2PostPayload, int expectedHttpCode,
Handler<JsonObject> handler) {
sendTokenGenerate(apiVersion, vertx, v1GetParam, v2PostPayload, expectedHttpCode, null, handler);
sendTokenGenerate(apiVersion, vertx, v1GetParam, v2PostPayload, expectedHttpCode, null, handler, true);
}

private void sendTokenGenerate(String apiVersion, Vertx vertx, String v1GetParam, JsonObject v2PostPayload, int expectedHttpCode, String referer, Handler<JsonObject> handler) {
protected void sendTokenGenerate(String apiVersion, Vertx vertx, String v1GetParam, JsonObject v2PostPayload, int expectedHttpCode,
Handler<JsonObject> handler, boolean additionalParams) {
sendTokenGenerate(apiVersion, vertx, v1GetParam, v2PostPayload, expectedHttpCode, null, handler, additionalParams);
}

private void sendTokenGenerate(String apiVersion, Vertx vertx, String v1GetParam, JsonObject v2PostPayload, int expectedHttpCode, String referer, Handler<JsonObject> handler, boolean additionalParams) {
if (apiVersion.equals("v2")) {
ClientKey ck = (ClientKey) clientKeyProvider.get("");

long nonce = new BigInteger(Random.getBytes(8)).longValue();

addAdditionalTokenGenerateParams(v2PostPayload);
if(additionalParams) {
addAdditionalTokenGenerateParams(v2PostPayload);
}

postV2(ck, vertx, apiVersion + "/token/generate", v2PostPayload, nonce, referer, ar -> {
assertTrue(ar.succeeded());
Expand Down Expand Up @@ -2556,7 +2563,7 @@ void requestWithReferer(Vertx vertx, VertxTestContext testContext) {
assertStatsCollector("/v2/token/generate", "test-referer", null, null);

testContext.completeNow();
});
}, true);
}

private void postCstg(Vertx vertx, String endpoint, String httpOriginHeader, JsonObject body, Handler<AsyncResult<HttpResponse<Buffer>>> handler) {
Expand Down

0 comments on commit 273967d

Please sign in to comment.