Skip to content

Commit b8f2d20

Browse files
committed
Clean up comments
1 parent 6755ccb commit b8f2d20

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecuritySlowLogRestIT.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.concurrent.TimeUnit;
2727
import java.util.concurrent.atomic.AtomicReference;
2828

29-
import static org.hamcrest.MatcherAssert.assertThat;
3029
import static org.hamcrest.Matchers.empty;
3130
import static org.hamcrest.Matchers.equalTo;
3231
import 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(),

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,13 +2416,6 @@ public Map<String, String> getAuthContextForSlowLog() {
24162416
return Map.of();
24172417
}
24182418

2419-
/**
2420-
* Helper method to populate authentication context fields for slow logs.
2421-
* This logic is common for both direct authentications and the nested
2422-
* original authentication in cross-cluster access scenarios.
2423-
*
2424-
* @param auth The Authentication object to extract details from.
2425-
*/
24262419
private Map<String, String> createAuthContextMap(Authentication auth) {
24272420
Map<String, String> authContext = new HashMap<>();
24282421

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,10 +1267,6 @@ public void testAuthContextForSlowLog_LocalAccess_OriginalRealmUser() throws Exc
12671267
assertFalse(authContext.containsKey("apikey.name"));
12681268
}
12691269

1270-
/**
1271-
* Tests getAuthContextForSlowLog for an API Key authentication scenario.
1272-
* Covers a part of the 'else' branch where authentication is NOT cross-cluster.
1273-
*/
12741270
public void testAuthContextForSlowLog_LocalAccess_ApiKeyAuthentication() throws Exception {
12751271
createComponents(Settings.EMPTY);
12761272
AuthenticationContextSerializer serializer = new AuthenticationContextSerializer();

0 commit comments

Comments
 (0)