Skip to content

Commit c0b6854

Browse files
committed
Addressing feedback
1 parent 6a4d365 commit c0b6854

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

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

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.time.Clock;
2626
import java.time.Instant;
2727
import java.util.Base64;
28-
import java.util.List;
2928

3029
public class Operator extends App {
3130
public enum Type {
@@ -263,9 +262,9 @@ public DecryptionResponse v2TokenDecrypt(String token) throws UID2ClientExceptio
263262

264263
// Need to use the manual mapping for error cases - SDK won't allow creating input with bad emails or disable optout check
265264
public JsonNode v2IdentityMap(String payload) throws Exception {
266-
V2Envelope envelope = v2CreateEnvelope(payload, getClientApiSecret());
267-
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v2/identity/map", envelope.envelope(), getClientApiKey());
268-
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), getClientApiSecret());
265+
V2Envelope envelope = v2CreateEnvelope(payload, CLIENT_API_SECRET);
266+
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v2/identity/map", envelope.envelope(), CLIENT_API_KEY);
267+
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), CLIENT_API_SECRET);
269268
}
270269

271270
public IdentityMapResponse v2IdentityMap(IdentityMapInput input) {
@@ -275,9 +274,9 @@ public IdentityMapResponse v2IdentityMap(IdentityMapInput input) {
275274

276275
// Need to use the manual mapping for error cases - SDK won't allow creating input with bad emails
277276
public JsonNode v3IdentityMap(String payload) throws Exception {
278-
V2Envelope envelope = v2CreateEnvelope(payload, getClientApiSecret());
279-
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v3/identity/map", envelope.envelope(), getClientApiKey());
280-
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), getClientApiSecret());
277+
V2Envelope envelope = v2CreateEnvelope(payload, CLIENT_API_SECRET);
278+
String encryptedResponse = HttpClient.post(getBaseUrl() + "/v3/identity/map", envelope.envelope(), CLIENT_API_KEY);
279+
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), CLIENT_API_SECRET);
281280
}
282281

283282
public IdentityMapV3Response v3IdentityMap(IdentityMapV3Input input) {
@@ -303,14 +302,6 @@ public JsonNode v2KeySharing() throws Exception {
303302
return v2DecryptEncryptedResponse(encryptedResponse, envelope.nonce(), CLIENT_API_SECRET);
304303
}
305304

306-
private String getClientApiKey() {
307-
return CLIENT_API_KEY;
308-
}
309-
310-
private String getClientApiSecret() {
311-
return CLIENT_API_SECRET;
312-
}
313-
314305
private V2Envelope v2CreateEnvelope(String payload, String secret) throws Exception {
315306
// Unencrypted envelope payload = timestamp + nonce + raw payload
316307
Instant timestamp = Instant.now();

src/test/java/suite/operator/OperatorPublicOnlyTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ public void testV3IdentityMapSpecialOptout(String label, Operator operator, Stri
9393
return;
9494
}
9595

96-
// We need all properties to be there for Identity Map V3, so default all to empty
97-
// In JSON if a property appears multiple times, the last value wins
98-
String payload = "{\"email\":[], \"email_hash\":[], \"phone\":[], \"phone_hash\":[], \"" + type + "\": [\"" + identity + "\"]}";
96+
String payload = "{\"" + type + "\": [\"" + identity + "\"]}";
9997
JsonNode response = operator.v3IdentityMap(payload);
10098

10199
assertThat(response.get("body").get(type).get(0).get("e").asText()).isEqualTo("optout");

src/test/java/suite/operator/OperatorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void testV3IdentityMapLargeBatch(
183183

184184
// Sanity check that refresh from is a date not too far in the past.
185185
// If it is, either there is an Operator issue or salt rotation hasn't been running for a long time.
186-
assertThat(mappedDii.getRefreshFrom()).isAfter(Instant.now().minus(Duration.ofDays(10)));
186+
assertThat(mappedDii.getRefreshFrom()).isAfter(Instant.now().minus(Duration.ofHours(1)));
187187
}
188188
});
189189
}
@@ -193,11 +193,11 @@ public void testV3IdentityMapLargeBatch(
193193
"suite.operator.TestData#identityMapV3BatchBadEmailArgs",
194194
"suite.operator.TestData#identityMapV3BatchBadPhoneArgs"
195195
})
196-
public void testV3IdentityMapUnmapped(String label, Operator operator, String operatorName, String payload, String section) throws Exception {
196+
public void testV3IdentityMapUnmapped(String label, Operator operator, String operatorName, String payload, String identityType) throws Exception {
197197
JsonNode response = operator.v3IdentityMap(payload);
198198

199199
assertThat(response.at("/status").asText()).isEqualTo("success");
200-
assertThat(response.at("/body/" + section + "/0/e").asText()).isEqualTo("invalid identifier");
200+
assertThat(response.at("/body/" + identityType + "/0/e").asText()).isEqualTo("invalid identifier");
201201
}
202202

203203

0 commit comments

Comments
 (0)