@@ -129,6 +129,11 @@ public void deployVerticle(Vertx vertx, VertxTestContext testContext, TestInfo t
129129 when (this .secureLinkValidatorService .validateRequest (any (RoutingContext .class ), any (JsonObject .class ), any (Role .class ))).thenReturn (true );
130130
131131 setupConfig (config );
132+ // TODO: Remove this when we remove tokenGenerateOptOutTokenWithDisableOptoutTokenFF test
133+ if (testInfo .getTestMethod ().isPresent () &&
134+ testInfo .getTestMethod ().get ().getName ().equals ("tokenGenerateOptOutTokenWithDisableOptoutTokenFF" )) {
135+ config .put (Const .Config .DisableOptoutTokenProp , true );
136+ }
132137 if (testInfo .getDisplayName ().equals ("cstgNoPhoneSupport(Vertx, VertxTestContext)" )) {
133138 config .put ("enable_phone_support" , false );
134139 }
@@ -165,6 +170,7 @@ private void setupConfig(JsonObject config) {
165170 config .put (Const .Config .AllowClockSkewSecondsProp , 3600 );
166171 config .put (Const .Config .OptOutStatusApiEnabled , true );
167172 config .put (Const .Config .OptOutStatusMaxRequestSize , optOutStatusMaxRequestSize );
173+ config .put (Const .Config .DisableOptoutTokenProp , false );
168174 }
169175
170176 private static byte [] makeAesKey (String prefix ) {
@@ -1207,6 +1213,51 @@ void tokenGenerateOptOutToken(String policyParameterKey, String identity, Identi
12071213 });
12081214 }
12091215
1216+ @ ParameterizedTest // TODO: remove test after optout check phase 3
1217+ @ CsvSource ({
"policy,[email protected] ,Email" ,
1218+ "policy,+01234567890,Phone" ,
1219+ "optout_check,[email protected] ,Email" ,
1220+ "optout_check,+01234567890,Phone" })
1221+ void tokenGenerateOptOutTokenWithDisableOptoutTokenFF (String policyParameterKey , String identity , IdentityType identityType ,
1222+ Vertx vertx , VertxTestContext testContext ) {
1223+ ClientKey oldClientKey = new ClientKey (
1224+ null ,
1225+ null ,
1226+ Utils .toBase64String (clientSecret ),
1227+ "test-contact" ,
1228+ newClientCreationDateTime .minusSeconds (5 ),
1229+ Set .of (Role .GENERATOR ),
1230+ 201 ,
1231+ null
1232+ );
1233+ when (clientKeyProvider .get (any ())).thenReturn (oldClientKey );
1234+ when (clientKeyProvider .getClientKey (any ())).thenReturn (oldClientKey );
1235+ when (clientKeyProvider .getOldestClientKey (201 )).thenReturn (oldClientKey );
1236+ when (this .optOutStore .getLatestEntry (any ())).thenReturn (Instant .now ());
1237+ setupSalts ();
1238+ setupKeys ();
1239+
1240+ JsonObject v2Payload = new JsonObject ();
1241+ v2Payload .put (identityType .name ().toLowerCase (), identity );
1242+ v2Payload .put (policyParameterKey , OptoutCheckPolicy .DoNotRespect .policy );
1243+
1244+ sendTokenGenerate ("v2" , vertx ,
1245+ "" , v2Payload , 200 ,
1246+ json -> {
1247+ assertEquals ("optout" , json .getString ("status" ));
1248+
1249+ decodeV2RefreshToken (json );
1250+
1251+ assertTokenStatusMetrics (
1252+ 201 ,
1253+ TokenResponseStatsCollector .Endpoint .GenerateV2 ,
1254+ TokenResponseStatsCollector .ResponseStatus .OptOut ,
1255+ TokenResponseStatsCollector .PlatformType .Other );
1256+
1257+ testContext .completeNow ();
1258+ });
1259+ }
1260+
12101261 @ ParameterizedTest
12111262 @ ValueSource (strings = {"v1" , "v2" })
12121263 void tokenGenerateForEmail (String apiVersion , Vertx vertx , VertxTestContext testContext ) {
0 commit comments