1111import org .junit .jupiter .params .provider .MethodSource ;
1212
1313import java .time .Duration ;
14+ import java .time .Instant ;
1415import java .util .List ;
16+ import java .util .Objects ;
1517
1618import static org .assertj .core .api .Assertions .assertThat ;
1719import static org .junit .jupiter .api .Assertions .*;
1820
1921@ SuppressWarnings ("unused" )
20- public class V2ApiOperatorTest {
22+ public class OperatorTest {
2123 /*
2224 TODO:
2325 /v2/token/generate - Add failure case
@@ -31,6 +33,7 @@ public class V2ApiOperatorTest {
3133
3234 private static final ObjectMapper OBJECT_MAPPER = Mapper .getInstance ();
3335 private static final String CLIENT_SITE_ID = EnvUtil .getEnv (Const .Config .Operator .CLIENT_SITE_ID );
36+ private static final int RAW_UID_SIZE = 44 ;
3437
3538 @ ParameterizedTest (name = "/v2/token/generate - {0} - {2}" )
3639 @ MethodSource ({
@@ -113,7 +116,7 @@ public void testV2IdentityMap(String label, Operator operator, String operatorNa
113116 "suite.operator.TestData#identityMapBigBatchArgs"
114117 })
115118 public void testV2IdentityMapLargeBatch (String label , Operator operator , String operatorName , String payload , List <String > diis ) {
116- assertTimeoutPreemptively (Duration .ofSeconds (5 ), () -> { // Validate we didn't make mapping too slow.
119+ assertTimeoutPreemptively (Duration .ofSeconds (5 ), () -> { // Validate we didn't make mapping too slow.
117120 JsonNode response = operator .v2IdentityMap (payload );
118121
119122 assertThat (response .at ("/status" ).asText ()).isEqualTo ("success" );
@@ -129,6 +132,50 @@ public void testV2IdentityMapLargeBatch(String label, Operator operator, String
129132 });
130133 }
131134
135+ @ ParameterizedTest (name = "/v3/identity/map - {0} - {2}" )
136+ @ MethodSource ({
137+ "suite.operator.TestData#identityMapV3BigBatchArgs"
138+ })
139+ public void testV3IdentityMapLargeBatch (
140+ String label ,
141+ Operator operator ,
142+ String operatorName ,
143+ List <String > emails ,
144+ List <String > phones ,
145+ List <String > emailHashes ,
146+ List <String > phoneHashes ,
147+ List <String > diis
148+ ) {
149+ assertTimeoutPreemptively (Duration .ofSeconds (5 ), () -> { // Validate we didn't make mapping too slow.
150+ var response = operator .v3IdentityMap (emails , phones , emailHashes , phoneHashes );
151+
152+ assertThat (response .isSuccess ()).isTrue ();
153+
154+ var allMappedDiis = response .getMappedIdentities ();
155+ assertThat (allMappedDiis .size ()).isEqualTo (10_000 );
156+
157+
158+ for (var dii : diis ) {
159+ var mappedDii = allMappedDiis .get (dii );
160+ assertThat (mappedDii ).isNotNull ();
161+
162+ // Current UID should always be there and should have correct length
163+ assertThat (mappedDii .getCurrentRawUid ().length ()).isEqualTo (RAW_UID_SIZE );
164+
165+ // Previous UID is there for 90 days after rotation only, then it's null.
166+ // If it's there, it should have the correct size
167+ assertThat (mappedDii .getPreviousRawUid ()).satisfiesAnyOf (
168+ uid -> assertThat (uid ).isNull (),
169+ uid -> assertThat (uid ).hasSize (RAW_UID_SIZE )
170+ );
171+
172+ // Sanity check that refresh from is a date not too far in the past.
173+ // If it is, either there is an Operator issue or salt rotation hasn't been running for a long time.
174+ assertThat (mappedDii .getRefreshFrom ()).isAfter (Instant .now ().minus (Duration .ofDays (10 )));
175+ }
176+ });
177+ }
178+
132179
133180 @ ParameterizedTest (name = "/v2/identity/map - VALIDATE EMAIL - {0} - {2}" )
134181 @ MethodSource ({
0 commit comments