@@ -5253,6 +5253,51 @@ void asyncBatchRequestEnabledLogsCorrectMessage(Vertx vertx, VertxTestContext te
52535253 testContext .completeNow ();
52545254 }
52555255
5256+ @ Test
5257+ void rawEmailDotMetricRecorded (Vertx vertx , VertxTestContext testContext ) {
5258+ fakeAuth (201 , Role .GENERATOR , Role .MAPPER );
5259+ setupSalts ();
5260+ setupKeys ();
5261+
5262+ // /v2/token/generate
5263+ String emailHash = TokenUtils .getIdentityHashString ("hash@example.com" );
5264+ sendTokenGenerate (vertx , new JsonObject ().put ("email" , "john.doe@example.com" ), 200 , json -> {}); // dot, non-gmail
5265+ sendTokenGenerate (vertx , new JsonObject ().put ("email" , "johndoe@example.com" ), 200 , json -> {}); // no dot, non-gmail
5266+ sendTokenGenerate (vertx , new JsonObject ().put ("email" , "john.doe@gmail.com" ), 200 , json -> {}); // dot, gmail
5267+ sendTokenGenerate (vertx , new JsonObject ().put ("email_hash" , emailHash ), 200 , json -> { // hash - should not record
5268+
5269+ assertEquals (1 , Metrics .globalRegistry
5270+ .get ("uid2_operator_raw_email_dot_total" )
5271+ .tag ("path" , "/v2/token/generate" ).tag ("has_dot" , "true" ).tag ("is_gmail" , "false" )
5272+ .counter ().count ());
5273+ assertEquals (1 , Metrics .globalRegistry
5274+ .get ("uid2_operator_raw_email_dot_total" )
5275+ .tag ("path" , "/v2/token/generate" ).tag ("has_dot" , "false" ).tag ("is_gmail" , "false" )
5276+ .counter ().count ());
5277+ assertEquals (1 , Metrics .globalRegistry
5278+ .get ("uid2_operator_raw_email_dot_total" )
5279+ .tag ("path" , "/v2/token/generate" ).tag ("has_dot" , "true" ).tag ("is_gmail" , "true" )
5280+ .counter ().count ());
5281+ // has_dot=false, is_gmail=false count is still 1 — hash request did not increment it
5282+ assertEquals (1 , Metrics .globalRegistry
5283+ .get ("uid2_operator_raw_email_dot_total" )
5284+ .tag ("path" , "/v2/token/generate" ).tag ("has_dot" , "false" ).tag ("is_gmail" , "false" )
5285+ .counter ().count ());
5286+
5287+ // /v2/identity/map — batch with two dot emails to verify counter reaches 2
5288+ JsonObject mapReq = new JsonObject ().put ("email" , new JsonArray ()
5289+ .add ("a.b@example.com" )
5290+ .add ("c.d@example.com" ));
5291+ send (vertx , "v2/identity/map" , mapReq , 200 , mapJson -> {
5292+ assertEquals (2 , Metrics .globalRegistry
5293+ .get ("uid2_operator_raw_email_dot_total" )
5294+ .tag ("path" , "/v2/identity/map" ).tag ("has_dot" , "true" ).tag ("is_gmail" , "false" )
5295+ .counter ().count ());
5296+ testContext .completeNow ();
5297+ });
5298+ });
5299+ }
5300+
52565301 @ Test
52575302 void asyncBatchRequestDisabledLogsCorrectMessage (Vertx vertx , VertxTestContext testContext ) {
52585303 // Verify that when enable_async_batch_request is false, the correct log message is emitted
0 commit comments