Skip to content

Commit 515590d

Browse files
authored
Remove old participant (#88)
* Remove old participant * Remove CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF and CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF
1 parent 4dd1848 commit 515590d

File tree

8 files changed

+32
-75
lines changed

8 files changed

+32
-75
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ ENV UID2_CORE_E2E_OPTOUT_URL ""
2626
ENV UID2_OPERATOR_E2E_CLIENT_SITE_ID ""
2727
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY ""
2828
ENV UID2_OPERATOR_E2E_CLIENT_API_SECRET ""
29-
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF ""
30-
ENV UID2_OPERATOR_E2E_CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF ""
3129
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY_SHARING_RECIPIENT ""
3230
ENV UID2_OPERATOR_E2E_CLIENT_API_SECRET_SHARING_RECIPIENT ""
3331
ENV UID2_OPERATOR_E2E_CLIENT_API_KEY_NON_SHARING_RECIPIENT ""

src/test/java/app/component/Operator.java

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ private record V2Envelope(String envelope, byte[] nonce) {
9898
@Getter
9999
private final Type type;
100100
private final PublisherUid2Client publisherClient;
101-
private final PublisherUid2Client oldPublisherClient;
102101
private final UID2Client dspClient;
103102

104103
public Operator(String host, Integer port, String name, Type type) {
@@ -111,11 +110,6 @@ public Operator(String host, Integer port, String name, Type type) {
111110
CLIENT_API_KEY,
112111
CLIENT_API_SECRET
113112
);
114-
this.oldPublisherClient = new PublisherUid2Client(
115-
getBaseUrl(),
116-
CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF,
117-
CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF
118-
);
119113
this.dspClient = new UID2Client(
120114
getBaseUrl(),
121115
CLIENT_API_KEY,
@@ -128,7 +122,7 @@ public Operator(String host, String name, Type type) {
128122
this(host, null, name, type);
129123
}
130124

131-
public TokenGenerateResponse v2TokenGenerate(String type, String identity, boolean asOldParticipant) {
125+
public TokenGenerateResponse v2TokenGenerate(String type, String identity) {
132126
TokenGenerateInput token;
133127

134128
if ("email".equals(type)) {
@@ -143,18 +137,8 @@ public TokenGenerateResponse v2TokenGenerate(String type, String identity, boole
143137
token = token.withTransparencyAndConsentString(TC_STRING);
144138
}
145139

146-
if (!asOldParticipant) {
147-
token = token.doNotGenerateTokensForOptedOut();
148-
return publisherClient.generateTokenResponse(token);
149-
} else {
150-
return oldPublisherClient.generateTokenResponse(token);
151-
}
152-
}
153-
154-
public JsonNode v2TokenGenerateUsingPayload(String payload, boolean asOldParticipant) throws Exception {
155-
V2Envelope envelope = v2CreateEnvelope(payload, getClientApiSecret(asOldParticipant));
156-
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v2/token/generate", envelope.envelope(), getClientApiKey(asOldParticipant));
157-
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), getClientApiSecret(asOldParticipant));
140+
token = token.doNotGenerateTokensForOptedOut();
141+
return publisherClient.generateTokenResponse(token);
158142
}
159143

160144
public JsonNode v2ClientSideTokenGenerate(String requestBody, boolean useValidOrigin) throws Exception {
@@ -280,10 +264,10 @@ public DecryptionResponse v2TokenDecrypt(String token) throws UID2ClientExceptio
280264
return dspClient.decrypt(token);
281265
}
282266

283-
public JsonNode v2IdentityMap(String payload, boolean asOldParticipant) throws Exception {
284-
V2Envelope envelope = v2CreateEnvelope(payload, getClientApiSecret(asOldParticipant));
285-
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v2/identity/map", envelope.envelope(), getClientApiKey(asOldParticipant));
286-
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), getClientApiSecret(asOldParticipant));
267+
public JsonNode v2IdentityMap(String payload) throws Exception {
268+
V2Envelope envelope = v2CreateEnvelope(payload, getClientApiSecret());
269+
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v2/identity/map", envelope.envelope(), getClientApiKey());
270+
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), getClientApiSecret());
287271
}
288272

289273
public JsonNode v2IdentityBuckets(String payload) throws Exception {
@@ -304,12 +288,12 @@ public JsonNode v2KeySharing() throws Exception {
304288
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), CLIENT_API_SECRET);
305289
}
306290

307-
private String getClientApiKey(boolean asOldParticipant) {
308-
return asOldParticipant ? CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF : CLIENT_API_KEY;
291+
private String getClientApiKey() {
292+
return CLIENT_API_KEY;
309293
}
310294

311-
private String getClientApiSecret(boolean asOldParticipant) {
312-
return asOldParticipant ? CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF : CLIENT_API_SECRET;
295+
private String getClientApiSecret() {
296+
return CLIENT_API_SECRET;
313297
}
314298

315299
private V2Envelope v2CreateEnvelope(String payload, String secret) throws Exception {

src/test/java/common/Const.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ public static final class Operator {
2323
public static final String CLIENT_API_KEY = "UID2_OPERATOR_E2E_CLIENT_API_KEY";
2424
public static final String CLIENT_API_SECRET = "UID2_OPERATOR_E2E_CLIENT_API_SECRET";
2525

26-
// Optout cutoff
27-
public static final String CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF = "UID2_OPERATOR_E2E_CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF";
28-
public static final String CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF = "UID2_OPERATOR_E2E_CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF";
29-
3026
// Local only - Sharing
3127
public static final String CLIENT_API_KEY_SHARING_RECIPIENT = "UID2_OPERATOR_E2E_CLIENT_API_KEY_SHARING_RECIPIENT";
3228
public static final String CLIENT_API_SECRET_SHARING_RECIPIENT = "UID2_OPERATOR_E2E_CLIENT_API_SECRET_SHARING_RECIPIENT";

src/test/java/suite/operator/V2ApiOperatorLocalOnlyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testSharing(TestData.Client sender, Operator senderOperator, TestDat
6666
"suite.operator.TestData#tokenEmailArgsLocalMockOptout"
6767
})
6868
public void testV2TokenGenerateLocalMockOptout(String label, Operator operator, String operatorName, String type, String identity) {
69-
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity, false);
69+
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity);
7070
IdentityTokens currentIdentity = tokenGenerateResponse.getIdentity();
7171

7272
assertThat(currentIdentity).isNull();

src/test/java/suite/operator/V2ApiOperatorPublicOnlyTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void testV2SpecialRefreshOptoutOldParticipant(String label, Operator oper
2727
return;
2828
}
2929

30-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, true).getIdentity();
30+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
3131
TokenRefreshResponse refreshed = operator.v2TokenRefresh(currentIdentity);
3232

3333
assertTrue(refreshed.isOptout());
@@ -38,13 +38,13 @@ public void testV2SpecialRefreshOptoutOldParticipant(String label, Operator oper
3838
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
3939
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
4040
})
41-
public void testV2IdentityMapSpecialOptoutParamTrue(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) throws Exception {
41+
public void testV2IdentityMapSpecialOptoutParamTrue(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
4242
if (isPrivateOperator(operator)) {
4343
return;
4444
}
4545

4646
String payload = "{\"" + type + "\": [\"" + identity + "\"], \"optout_check\":1}";
47-
JsonNode response = operator.v2IdentityMap(payload, asOldParticipant);
47+
JsonNode response = operator.v2IdentityMap(payload);
4848

4949
assertThat(response.get("body").get("unmapped").get(0).get("reason").asText()).isEqualTo("optout");
5050
}
@@ -54,13 +54,13 @@ public void testV2IdentityMapSpecialOptoutParamTrue(String label, Operator opera
5454
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
5555
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
5656
})
57-
public void testV2IdentityMapSpecialOptoutParamFalse(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) throws Exception {
57+
public void testV2IdentityMapSpecialOptoutParamFalse(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
5858
if (isPrivateOperator(operator)) {
5959
return;
6060
}
6161

6262
String payload = "{\"" + type + "\": [\"" + identity + "\"], \"optout_check\":0}";
63-
JsonNode response = operator.v2IdentityMap(payload, asOldParticipant);
63+
JsonNode response = operator.v2IdentityMap(payload);
6464

6565
assertThat(response.get("body").get("unmapped").get(0).get("reason").asText()).isEqualTo("optout");
6666
}
@@ -70,13 +70,13 @@ public void testV2IdentityMapSpecialOptoutParamFalse(String label, Operator oper
7070
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
7171
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
7272
})
73-
public void testV2IdentityMapSpecialOptoutNoParam(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) throws Exception {
73+
public void testV2IdentityMapSpecialOptoutNoParam(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
7474
if (isPrivateOperator(operator)) {
7575
return;
7676
}
7777

7878
String payload = "{\"" + type + "\": [\"" + identity + "\"]}";
79-
JsonNode response = operator.v2IdentityMap(payload, asOldParticipant);
79+
JsonNode response = operator.v2IdentityMap(payload);
8080

8181
assertThat(response.get("body").get("unmapped").get(0).get("reason").asText()).isEqualTo("optout");
8282
}

src/test/java/suite/operator/V2ApiOperatorTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class V2ApiOperatorTest {
3535
"suite.operator.TestData#tokenPhoneArgs"
3636
})
3737
public void testV2TokenGenerate(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
38-
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity, false);
38+
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity);
3939
IdentityTokens currentIdentity = tokenGenerateResponse.getIdentity();
4040
DecryptionResponse decrypted = operator.v2TokenDecrypt(currentIdentity.getAdvertisingToken());
4141

@@ -47,8 +47,8 @@ public void testV2TokenGenerate(String label, Operator operator, String operator
4747
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
4848
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
4949
})
50-
public void testV2TokenGenerateSpecialOptout(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) {
51-
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity, false);
50+
public void testV2TokenGenerateSpecialOptout(String label, Operator operator, String operatorName, String type, String identity) {
51+
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity);
5252

5353
assertTrue(tokenGenerateResponse.isOptout());
5454
}
@@ -59,7 +59,7 @@ public void testV2TokenGenerateSpecialOptout(String label, Operator operator, St
5959
"suite.operator.TestData#tokenPhoneArgs"
6060
})
6161
public void testV2TokenRefresh(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
62-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, false).getIdentity();
62+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
6363
TokenRefreshResponse refreshed = operator.v2TokenRefresh(currentIdentity);
6464
DecryptionResponse decrypted = operator.v2TokenDecrypt(refreshed.getIdentity().getAdvertisingToken());
6565

@@ -72,7 +72,7 @@ public void testV2TokenRefresh(String label, Operator operator, String operatorN
7272
"suite.operator.TestData#tokenPhoneArgsSpecialRefreshOptout"
7373
})
7474
public void testV2SpecialRefreshOptout(String label, Operator operator, String operatorName, String type, String identity) {
75-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, false).getIdentity();
75+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
7676
TokenRefreshResponse refreshed = operator.v2TokenRefresh(currentIdentity);
7777

7878
assertTrue(refreshed.isOptout());
@@ -84,7 +84,7 @@ public void testV2SpecialRefreshOptout(String label, Operator operator, String o
8484
"suite.operator.TestData#tokenValidatePhoneArgs"
8585
})
8686
public void testV2TokenValidate(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
87-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, false).getIdentity();
87+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
8888
String advertisingToken = currentIdentity.getAdvertisingToken();
8989
JsonNode response = operator.v2TokenValidate(type, identity, advertisingToken);
9090

@@ -99,7 +99,7 @@ public void testV2TokenValidate(String label, Operator operator, String operator
9999
"suite.operator.TestData#identityMapBatchBadPhoneArgs"
100100
})
101101
public void testV2IdentityMap(String label, Operator operator, String operatorName, String payload) throws Exception {
102-
JsonNode response = operator.v2IdentityMap(payload, false);
102+
JsonNode response = operator.v2IdentityMap(payload);
103103

104104
// TODO: Assert the value
105105
assertThat(response.at("/status").asText()).isEqualTo("success");
@@ -112,7 +112,7 @@ public void testV2IdentityMap(String label, Operator operator, String operatorNa
112112
})
113113
public void testV2IdentityMapValidateArgs(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
114114
String payload = "{\"" + type + "\": [\"" + identity + "\"], \"optout_check\":1}";
115-
JsonNode response = operator.v2IdentityMap(payload, false);
115+
JsonNode response = operator.v2IdentityMap(payload);
116116

117117
assertThat(response.get("body").get("mapped").get(0).get("advertising_id").asText()).isNotNull();
118118
}

src/test/java/suite/optout/OptoutTest.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void setupAll() {
4545
})
4646
@Order(1)
4747
public void testV2LogoutWithV2TokenGenerate(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
48-
IdentityTokens generateResponse = operator.v2TokenGenerate(type, identity, false).getIdentity();
48+
IdentityTokens generateResponse = operator.v2TokenGenerate(type, identity).getIdentity();
4949
Thread.sleep(OPTOUT_DELAY_MS);
5050
JsonNode logoutResponse = operator.v2TokenLogout(type, identity);
5151
assertThat(logoutResponse).isEqualTo(OBJECT_MAPPER.readTree("{\"body\":{\"optout\":\"OK\"},\"status\":\"success\"}"));
@@ -59,35 +59,14 @@ public void testV2LogoutWithV2TokenGenerate(String label, Operator operator, Str
5959
);
6060
}
6161

62-
@ParameterizedTest(name = "/v2/token/logout with /v2/token/generate - {0} - {2}")
63-
@MethodSource({
64-
"suite.optout.TestData#optoutTokenEmailArgs",
65-
"suite.optout.TestData#optoutTokenPhoneArgs"
66-
})
67-
@Order(2)
68-
public void testV2LogoutWithV2TokenGenerateOldParticipant(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
69-
IdentityTokens generateResponse = operator.v2TokenGenerate(type, identity, true).getIdentity();
70-
Thread.sleep(OPTOUT_DELAY_MS);
71-
JsonNode logoutResponse = operator.v2TokenLogout(type, identity);
72-
assertThat(logoutResponse).isEqualTo(OBJECT_MAPPER.readTree("{\"body\":{\"optout\":\"OK\"},\"status\":\"success\"}"));
73-
addToken(
74-
"old participant " + label,
75-
operator,
76-
"v2",
77-
"v2",
78-
generateResponse.getRefreshToken(),
79-
OBJECT_MAPPER.readTree(generateResponse.getJsonString()).at("/refresh_response_key").asText()
80-
);
81-
}
82-
8362
@ParameterizedTest(name = "/v2/token/logout with /v2/identity/map - DII {0} - toOptOut {5} - {2}")
8463
@MethodSource({
8564
"suite.optout.TestData#identityMapEmailArgs",
8665
"suite.optout.TestData#identityMapPhoneArgs"
8766
})
8867
@Order(3)
8968
public void testV2LogoutWithV2IdentityMap(String label, Operator operator, String operatorName, String type, String emailOrPhone, boolean toOptOut) throws Exception {
90-
JsonNode identityMapResponseNode = operator.v2IdentityMap("{\""+ type + "\":[\"" + emailOrPhone + "\"]}", false);
69+
JsonNode identityMapResponseNode = operator.v2IdentityMap("{\""+ type + "\":[\"" + emailOrPhone + "\"]}");
9170
assertThat(identityMapResponseNode.at("/status").asText()).isEqualTo("success");
9271
String rawUID = identityMapResponseNode.get("body").get("mapped").get(0).get(TestData.ADVERTISING_ID).asText();
9372
long beforeOptOutTimestamp = Instant.now().toEpochMilli();

src/test/java/suite/validator/V2ApiValidatorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class V2ApiValidatorTest extends ValidatorTestBase {
1818
})
1919
public void testV2TokenGenerateViaMetrics(String label, Operator operator, String operatorName, Prometheus prometheus, String prometheusName, String type, String identity) throws Exception {
2020
assertThat(compareMetricValues(prometheus, Metric.MATCH_METRIC_NAME, "/v2/token/generate", HttpClient.HttpMethod.POST, () ->
21-
operator.v2TokenGenerate(type, identity, false)
21+
operator.v2TokenGenerate(type, identity)
2222
)).isTrue();
2323
}
2424

@@ -29,7 +29,7 @@ public void testV2TokenGenerateViaMetrics(String label, Operator operator, Strin
2929
})
3030
public void testV2TokenRefreshViaMetrics(String label, Operator operator, String operatorName, Prometheus prometheus, String prometheusName, String type, String identity) throws Exception {
3131
assertThat(compareMetricValues(prometheus, Metric.MATCH_METRIC_NAME, "/v2/token/refresh", HttpClient.HttpMethod.POST, () -> {
32-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, false).getIdentity();
32+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
3333
operator.v2TokenRefresh(currentIdentity);
3434
})).isTrue();
3535
}
@@ -43,7 +43,7 @@ public void testV2TokenRefreshViaMetrics(String label, Operator operator, String
4343
})
4444
public void testV2IdentityMapViaMetrics(String label, Operator operator, String operatorName, Prometheus prometheus, String prometheusName, String payload) throws Exception {
4545
assertThat(compareMetricValues(prometheus, Metric.MATCH_METRIC_NAME, "/v2/identity/map", HttpClient.HttpMethod.POST, () ->
46-
operator.v2IdentityMap(payload, false)
46+
operator.v2IdentityMap(payload)
4747
)).isTrue();
4848
}
4949

0 commit comments

Comments
 (0)