Skip to content

Commit eb2006e

Browse files
author
elasticsearchmachine
committed
[CI] Auto commit changes from spotless
1 parent feead9d commit eb2006e

File tree

1 file changed

+19
-71
lines changed

1 file changed

+19
-71
lines changed

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

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,6 @@ public <T> List<T> loadExtensions(Class<T> extensionPointType) {
12391239
assertThat(operatorPrivilegesService, is(NOOP_OPERATOR_PRIVILEGES_SERVICE));
12401240
}
12411241

1242-
12431242
public void testAuthContextForSlowLog_LocalAccess_OriginalRealmUser() throws Exception {
12441243
createComponents(Settings.EMPTY);
12451244
AuthenticationContextSerializer serializer = new AuthenticationContextSerializer();
@@ -1252,11 +1251,7 @@ public void testAuthContextForSlowLog_LocalAccess_OriginalRealmUser() throws Exc
12521251
Collections.emptyMap(),
12531252
true
12541253
);
1255-
Authentication.RealmRef userRealm = new Authentication.RealmRef(
1256-
"default_native",
1257-
"native",
1258-
"nodeName"
1259-
);
1254+
Authentication.RealmRef userRealm = new Authentication.RealmRef("default_native", "native", "nodeName");
12601255

12611256
Authentication realmAuth = Authentication.newRealmAuthentication(searchUser, userRealm);
12621257
serializer.writeToContext(realmAuth, threadContext);
@@ -1284,14 +1279,7 @@ public void testAuthContextForSlowLog_LocalAccess_ApiKeyAuthentication() throws
12841279
apiKeyMetadata.put(AuthenticationField.API_KEY_ID_KEY, "test_local_api_key_id_123");
12851280
apiKeyMetadata.put(AuthenticationField.API_KEY_NAME_KEY, "MyLocalTestApiKey");
12861281

1287-
User apiKeyUser = new User(
1288-
"local_api_key_principal",
1289-
new String[0],
1290-
null,
1291-
null,
1292-
Collections.emptyMap(),
1293-
true
1294-
);
1282+
User apiKeyUser = new User("local_api_key_principal", new String[0], null, null, Collections.emptyMap(), true);
12951283

12961284
AuthenticationResult<User> apiKeyAuthResult = AuthenticationResult.success(apiKeyUser, apiKeyMetadata);
12971285

@@ -1323,36 +1311,28 @@ public void testAuthContextForSlowLog_LocalAccess_RunAsAuthentication() throws E
13231311
// Define the authenticating user
13241312
User authenticatingUser = new User(
13251313
"authenticating_user",
1326-
new String[]{"admin"},
1314+
new String[] { "admin" },
13271315
"Authenticating User",
13281316
13291317
Collections.emptyMap(),
13301318
true
13311319
);
13321320

1333-
Authentication.RealmRef authenticatingRealm = new Authentication.RealmRef(
1334-
"local_file_realm",
1335-
"file",
1336-
"local_node_authenticators"
1337-
);
1321+
Authentication.RealmRef authenticatingRealm = new Authentication.RealmRef("local_file_realm", "file", "local_node_authenticators");
13381322

13391323
Authentication baseAuth = Authentication.newRealmAuthentication(authenticatingUser, authenticatingRealm);
13401324

13411325
// Define the effective user (the one being run-as)
13421326
User effectiveUser = new User(
13431327
"run_as_user",
1344-
new String[]{"run_as"},
1328+
new String[] { "run_as" },
13451329
"Run As User",
13461330
13471331
Collections.emptyMap(),
13481332
true
13491333
);
13501334

1351-
Authentication.RealmRef effectiveRealm = new Authentication.RealmRef(
1352-
"local_ldap_realm",
1353-
"ldap",
1354-
"local_node_ldap"
1355-
);
1335+
Authentication.RealmRef effectiveRealm = new Authentication.RealmRef("local_ldap_realm", "ldap", "local_node_ldap");
13561336

13571337
Authentication runAsAuth = baseAuth.runAs(effectiveUser, effectiveRealm);
13581338
assertTrue(runAsAuth.isRunAs());
@@ -1391,11 +1371,7 @@ public void testAuthContextForSlowLog_CCA_OriginalRealmUser() throws Exception {
13911371
Collections.emptyMap(),
13921372
true
13931373
);
1394-
Authentication.RealmRef remoteSearchRealm = new Authentication.RealmRef(
1395-
"default_native",
1396-
"native",
1397-
"node_name_querying_cluster"
1398-
);
1374+
Authentication.RealmRef remoteSearchRealm = new Authentication.RealmRef("default_native", "native", "node_name_querying_cluster");
13991375
Authentication originalAuthentication = Authentication.newRealmAuthentication(remoteSearchUser, remoteSearchRealm);
14001376

14011377
CrossClusterAccessSubjectInfo crossClusterAccessSubjectInfo = new CrossClusterAccessSubjectInfo(
@@ -1404,14 +1380,7 @@ public void testAuthContextForSlowLog_CCA_OriginalRealmUser() throws Exception {
14041380
);
14051381

14061382
// Create outer Authentication object (the cross-cluster API key type)
1407-
User dummyApiKeyUser = new User(
1408-
"dummy_api_key_principal",
1409-
new String[0],
1410-
null,
1411-
null,
1412-
Collections.emptyMap(),
1413-
true
1414-
);
1383+
User dummyApiKeyUser = new User("dummy_api_key_principal", new String[0], null, null, Collections.emptyMap(), true);
14151384

14161385
Map<String, Object> authResultMetadata = new HashMap<>();
14171386
authResultMetadata.put(AuthenticationField.API_KEY_ID_KEY, "test_api_key_unique_id_from_auth_result");
@@ -1453,14 +1422,7 @@ public void testAuthContextForSlowLog_CCA_OriginalApiKeyUser() throws Exception
14531422
AuthenticationContextSerializer serializer = new AuthenticationContextSerializer();
14541423

14551424
// Original user authenticated via an API Key on the querying cluster
1456-
User originalApiKeyUser = new User(
1457-
"original_api_key_principal",
1458-
new String[0],
1459-
null,
1460-
null,
1461-
Collections.emptyMap(),
1462-
true
1463-
);
1425+
User originalApiKeyUser = new User("original_api_key_principal", new String[0], null, null, Collections.emptyMap(), true);
14641426

14651427
Map<String, Object> originalApiKeyMetadata = new HashMap<>();
14661428
originalApiKeyMetadata.put(AuthenticationField.API_KEY_ID_KEY, "original_api_key_id_xyz");
@@ -1487,10 +1449,7 @@ public void testAuthContextForSlowLog_CCA_OriginalApiKeyUser() throws Exception
14871449
);
14881450

14891451
Authentication baseApiKeyAuthApiKey = Authentication.newApiKeyAuthentication(
1490-
AuthenticationResult.success(
1491-
dummyApiKeyUserForApiKey,
1492-
Map.of(AuthenticationField.API_KEY_ID_KEY, "api_id_apikey")
1493-
),
1452+
AuthenticationResult.success(dummyApiKeyUserForApiKey, Map.of(AuthenticationField.API_KEY_ID_KEY, "api_id_apikey")),
14941453
"node_fulfilling_apikey"
14951454
);
14961455

@@ -1521,25 +1480,24 @@ public void testAuthContextForSlowLog_CCA_OriginalRunAsUser() throws Exception {
15211480
// Authenticating user on querying cluster (who performs the run-as)
15221481
User authenticatingRemoteUser = new User(
15231482
"authenticating_remote",
1524-
new String[]{"power_user"},
1483+
new String[] { "power_user" },
15251484
"Authenticating Remote User",
15261485
null,
15271486
Collections.emptyMap(),
15281487
true
15291488
);
15301489

1531-
Authentication.RealmRef authenticatingRemoteRealm = new Authentication.RealmRef(
1532-
"remote_auth_realm",
1533-
"ldap",
1534-
"node_querying_auth"
1535-
);
1490+
Authentication.RealmRef authenticatingRemoteRealm = new Authentication.RealmRef("remote_auth_realm", "ldap", "node_querying_auth");
15361491

1537-
Authentication baseAuthenticationRemote = Authentication.newRealmAuthentication(authenticatingRemoteUser, authenticatingRemoteRealm);
1492+
Authentication baseAuthenticationRemote = Authentication.newRealmAuthentication(
1493+
authenticatingRemoteUser,
1494+
authenticatingRemoteRealm
1495+
);
15381496

15391497
// Effective user (the one being run-as) on querying cluster
15401498
User effectiveRemoteUser = new User(
15411499
"effective_remote",
1542-
new String[]{"readonly"},
1500+
new String[] { "readonly" },
15431501
"Effective Remote User",
15441502
null,
15451503
Collections.emptyMap(),
@@ -1567,21 +1525,12 @@ public void testAuthContextForSlowLog_CCA_OriginalRunAsUser() throws Exception {
15671525
new String[0],
15681526
null,
15691527
null,
1570-
Map.of(
1571-
AuthenticationField.API_KEY_ID_KEY,
1572-
"api_id_runas"
1573-
),
1528+
Map.of(AuthenticationField.API_KEY_ID_KEY, "api_id_runas"),
15741529
true
15751530
);
15761531

15771532
Authentication baseApiKeyAuthRunAs = Authentication.newApiKeyAuthentication(
1578-
AuthenticationResult.success(
1579-
dummyApiKeyUserForRunAs,
1580-
Map.of(
1581-
AuthenticationField.API_KEY_ID_KEY,
1582-
"api_id_runas"
1583-
)
1584-
),
1533+
AuthenticationResult.success(dummyApiKeyUserForRunAs, Map.of(AuthenticationField.API_KEY_ID_KEY, "api_id_runas")),
15851534
"node_fulfilling_runas"
15861535
);
15871536

@@ -1606,7 +1555,6 @@ public void testAuthContextForSlowLog_CCA_OriginalRunAsUser() throws Exception {
16061555
assertFalse(authContext.containsKey("apikey.name"));
16071556
}
16081557

1609-
16101558
private void verifyHasAuthenticationHeaderValue(Exception e, String... expectedValues) {
16111559
assertThat(e, instanceOf(ElasticsearchSecurityException.class));
16121560
assertThat(((ElasticsearchSecurityException) e).getHeader("WWW-Authenticate"), notNullValue());

0 commit comments

Comments
 (0)