2626import java .util .concurrent .TimeUnit ;
2727import java .util .concurrent .atomic .AtomicReference ;
2828
29- import static org .hamcrest .MatcherAssert .assertThat ;
3029import static org .hamcrest .Matchers .empty ;
3130import static org .hamcrest .Matchers .equalTo ;
3231import static org .hamcrest .Matchers .hasKey ;
@@ -180,20 +179,19 @@ public void testCrossClusterSlowLogAuthenticationContext() throws Exception {
180179 assertOK (searchResponse );
181180
182181 // Verify slow log contains correct authentication context from the original user
183- // The key test: slow logs should show the original user from querying cluster
184182 Map <String , Object > expectedAuthContext = Map .of (
185183 "user.name" ,
186- "slow_log_test_user" , // Original user from querying cluster
184+ "slow_log_test_user" ,
187185 "user.realm" ,
188- "_es_api_key" , // User's realm on querying cluster
186+ "_es_api_key" ,
189187 "user.full_name" ,
190188 "Slow Log Test User" ,
191189 "auth.type" ,
192- "API_KEY" , // Authentication type
190+ "API_KEY" ,
193191 "apikey.id" ,
194- apiKeyId , // API key from querying cluster
192+ apiKeyId ,
195193 "apikey.name" ,
196- "slow_log_test_api_key" // API key name
194+ "slow_log_test_api_key"
197195 );
198196
199197 verifySlowLogAuthenticationContext (expectedAuthContext );
@@ -205,7 +203,6 @@ public void testRunAsUserInCrossClusterSlowLog() throws Exception {
205203
206204 // Fulfilling cluster setup
207205 {
208- // Create an index for run-as testing with slow log enabled
209206 final Request createIndexRequest = new Request ("PUT" , "/run_as_test" );
210207 createIndexRequest .setJsonEntity ("""
211208 {
@@ -283,16 +280,15 @@ public void testRunAsUserInCrossClusterSlowLog() throws Exception {
283280 final Response runAsResponse = client ().performRequest (runAsSearchRequest );
284281 assertOK (runAsResponse );
285282
286- // Verify slow log shows both authenticating and effective users from querying cluster
287283 Map <String , Object > expectedRunAsAuthContext = Map .of (
288284 "user.name" ,
289- "run_as_user" , // Authenticating user from querying cluster
285+ "run_as_user" ,
290286 "user.realm" ,
291287 "default_native" ,
292288 "user.full_name" ,
293289 "Run As User" ,
294290 "user.effective.name" ,
295- "target_user" , // Effective user from querying cluster
291+ "target_user" ,
296292 "user.effective.realm" ,
297293 "default_native" ,
298294 "user.effective.full_name" ,
@@ -315,7 +311,6 @@ private void verifySlowLogAuthenticationContext(Map<String, Object> expectedAuth
315311 String lastLogLine = lines .get (lines .size () - 1 );
316312 Map <String , Object > logEntry = XContentHelper .convertToMap (XContentType .JSON .xContent (), lastLogLine , true );
317313
318- // Verify that the log entry contains the expected authentication context
319314 for (Map .Entry <String , Object > expectedEntry : expectedAuthContext .entrySet ()) {
320315 assertThat (
321316 "Slow log should contain " + expectedEntry .getKey () + " with value " + expectedEntry .getValue (),
0 commit comments