Skip to content

Commit 47d48ae

Browse files
committed
Remove old participant
1 parent addd000 commit 47d48ae

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

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

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ private record V2Envelope(String envelope, byte[] nonce) {
9595
@Getter
9696
private final Type type;
9797
private final PublisherUid2Client publisherClient;
98-
private final PublisherUid2Client oldPublisherClient;
9998
private final UID2Client dspClient;
10099

101100
public Operator(String host, Integer port, String name, Type type) {
@@ -125,7 +124,7 @@ public Operator(String host, String name, Type type) {
125124
this(host, null, name, type);
126125
}
127126

128-
public TokenGenerateResponse v2TokenGenerate(String type, String identity, boolean asOldParticipant) {
127+
public TokenGenerateResponse v2TokenGenerate(String type, String identity) {
129128
TokenGenerateInput token;
130129

131130
if ("email".equals(type)) {
@@ -140,18 +139,8 @@ public TokenGenerateResponse v2TokenGenerate(String type, String identity, boole
140139
token = token.withTransparencyAndConsentString(TC_STRING);
141140
}
142141

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

157146
public JsonNode v2ClientSideTokenGenerate(String requestBody, boolean useValidOrigin) throws Exception {
@@ -277,7 +266,7 @@ public DecryptionResponse v2TokenDecrypt(String token) throws UID2ClientExceptio
277266
return dspClient.decrypt(token);
278267
}
279268

280-
public JsonNode v2IdentityMap(String payload, boolean asOldParticipant) throws Exception {
269+
public JsonNode v2IdentityMap(String payload) throws Exception {
281270
V2Envelope envelope = v2CreateEnvelope(payload, getClientApiSecret(asOldParticipant));
282271
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v2/identity/map", envelope.envelope(), getClientApiKey(asOldParticipant));
283272
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), getClientApiSecret(asOldParticipant));
@@ -301,12 +290,12 @@ public JsonNode v2KeySharing() throws Exception {
301290
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), CLIENT_API_SECRET);
302291
}
303292

304-
private String getClientApiKey(boolean asOldParticipant) {
305-
return asOldParticipant ? CLIENT_API_KEY_BEFORE_OPTOUT_CUTOFF : CLIENT_API_KEY;
293+
private String getClientApiKey() {
294+
return CLIENT_API_KEY;
306295
}
307296

308-
private String getClientApiSecret(boolean asOldParticipant) {
309-
return asOldParticipant ? CLIENT_API_SECRET_BEFORE_OPTOUT_CUTOFF : CLIENT_API_SECRET;
297+
private String getClientApiSecret() {
298+
return CLIENT_API_SECRET;
310299
}
311300

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

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public void testV2SpecialRefreshOptoutOldParticipant(String label, Operator oper
4141
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
4242
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
4343
})
44-
public void testV2IdentityMapSpecialOptoutParamTrue(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) throws Exception {
44+
public void testV2IdentityMapSpecialOptoutParamTrue(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
4545
if (isPrivateOperator(operator)) {
4646
return;
4747
}
4848

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

5252
assertThat(response.get("body").get("unmapped").get(0).get("reason").asText()).isEqualTo("optout");
5353
}
@@ -57,13 +57,13 @@ public void testV2IdentityMapSpecialOptoutParamTrue(String label, Operator opera
5757
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
5858
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
5959
})
60-
public void testV2IdentityMapSpecialOptoutParamFalse(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) throws Exception {
60+
public void testV2IdentityMapSpecialOptoutParamFalse(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
6161
if (isPrivateOperator(operator)) {
6262
return;
6363
}
6464

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

6868
assertThat(response.get("body").get("unmapped").get(0).get("reason").asText()).isEqualTo("optout");
6969
}
@@ -73,13 +73,13 @@ public void testV2IdentityMapSpecialOptoutParamFalse(String label, Operator oper
7373
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
7474
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
7575
})
76-
public void testV2IdentityMapSpecialOptoutNoParam(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) throws Exception {
76+
public void testV2IdentityMapSpecialOptoutNoParam(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
7777
if (isPrivateOperator(operator)) {
7878
return;
7979
}
8080

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

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

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

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

@@ -45,8 +45,8 @@ public void testV2TokenGenerate(String label, Operator operator, String operator
4545
"suite.operator.TestData#tokenEmailArgsSpecialOptout",
4646
"suite.operator.TestData#tokenPhoneArgsSpecialOptout"
4747
})
48-
public void testV2TokenGenerateSpecialOptout(String label, Operator operator, String operatorName, String type, String identity, boolean asOldParticipant) {
49-
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity, false);
48+
public void testV2TokenGenerateSpecialOptout(String label, Operator operator, String operatorName, String type, String identity) {
49+
TokenGenerateResponse tokenGenerateResponse = operator.v2TokenGenerate(type, identity);
5050

5151
assertTrue(tokenGenerateResponse.isOptout());
5252
}
@@ -57,7 +57,7 @@ public void testV2TokenGenerateSpecialOptout(String label, Operator operator, St
5757
"suite.operator.TestData#tokenPhoneArgs"
5858
})
5959
public void testV2TokenRefresh(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
60-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, false).getIdentity();
60+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
6161
TokenRefreshResponse refreshed = operator.v2TokenRefresh(currentIdentity);
6262
DecryptionResponse decrypted = operator.v2TokenDecrypt(refreshed.getIdentity().getAdvertisingToken());
6363

@@ -70,7 +70,7 @@ public void testV2TokenRefresh(String label, Operator operator, String operatorN
7070
"suite.operator.TestData#tokenPhoneArgsSpecialRefreshOptout"
7171
})
7272
public void testV2SpecialRefreshOptout(String label, Operator operator, String operatorName, String type, String identity) {
73-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, false).getIdentity();
73+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
7474
TokenRefreshResponse refreshed = operator.v2TokenRefresh(currentIdentity);
7575

7676
assertTrue(refreshed.isOptout());
@@ -82,7 +82,7 @@ public void testV2SpecialRefreshOptout(String label, Operator operator, String o
8282
"suite.operator.TestData#tokenValidatePhoneArgs"
8383
})
8484
public void testV2TokenValidate(String label, Operator operator, String operatorName, String type, String identity) throws Exception {
85-
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity, false).getIdentity();
85+
IdentityTokens currentIdentity = operator.v2TokenGenerate(type, identity).getIdentity();
8686
String advertisingToken = currentIdentity.getAdvertisingToken();
8787
JsonNode response = operator.v2TokenValidate(type, identity, advertisingToken);
8888

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

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

115115
assertThat(response.get("body").get("mapped").get(0).get("advertising_id").asText()).isNotNull();
116116
}

0 commit comments

Comments
 (0)