Skip to content

Commit 2310bca

Browse files
markjhoyelasticsearchmachine
andauthored
Remove Enterprise Search Service Account (#124655)
* remove Enterprise Search service account + tests * [CI] Auto commit changes from spotless * remove all tests referencing ent-search * [CI] Auto commit changes from spotless * ensure yaml tests have correct length * set proper length expected * use index for slow log test that works * skip account REST tests with invalid length * skip Test service account tokens test too * remove added space * add changelog for PR * update --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent c822a57 commit 2310bca

File tree

9 files changed

+11
-183
lines changed

9 files changed

+11
-183
lines changed

x-pack/plugin/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->
116116
task.skipTest("esql/40_tsdb/from index pattern unsupported counter", "TODO: support for subset of metric fields")
117117
task.skipTest("esql/40_unsupported_types/unsupported", "TODO: support for subset of metric fields")
118118
task.skipTest("esql/40_unsupported_types/unsupported with sort", "TODO: support for subset of metric fields")
119+
task.skipTest("service_accounts/10_basic/Test get service accounts", "Enterprise Search service account removed, invalidating the current tests")
120+
task.skipTest("service_accounts/10_basic/Test service account tokens", "Enterprise Search service account removed, invalidating the current tests")
119121
task.skipTest("ml/3rd_party_deployment/Test clear deployment cache", "Deprecated route removed")
120122
task.skipTest("ml/3rd_party_deployment/Test start and stop deployment with cache", "Deprecated route removed")
121123
task.skipTest("ml/3rd_party_deployment/Test start and stop multiple deployments", "Deprecated route removed")

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/xcontent/XContentUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void testAddAuthorizationInfoWithApiKey() throws IOException {
6363
}
6464

6565
public void testAddAuthorizationInfoWithServiceAccount() throws IOException {
66-
String account = "elastic/" + randomFrom("kibana", "fleet-server", "enterprise-search-server");
66+
String account = "elastic/" + randomFrom("kibana", "fleet-server");
6767
User user = new User(account);
6868
AuthenticationTestBuilder builder = AuthenticationTestHelper.builder().serviceAccount(user);
6969
Authentication authentication = builder.build();

x-pack/plugin/security/qa/security-basic/src/javaRestTest/java/org/elasticsearch/xpack/security/SecuritySlowLogIT.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public void testSlowLogWithServiceAccount() throws Exception {
224224

225225
Map<String, Object> expectedUser = Map.of(
226226
"user.name",
227-
"elastic/enterprise-search-server",
227+
"elastic/fleet-server",
228228
"user.realm",
229229
"_service_account",
230230
"auth.type",
@@ -311,7 +311,7 @@ private static List<TestIndexData> randomTestIndexData() throws IOException {
311311
List<TestIndexData> testData = new ArrayList<>();
312312
for (int i = 0; i < randomIntBetween(1, 10); i++) {
313313
TestIndexData randomTestData = new TestIndexData(
314-
"search-" + randomAlphaOfLengthBetween(5, 10).toLowerCase() + "-" + i,
314+
"agentless-" + randomAlphaOfLengthBetween(5, 10).toLowerCase() + "-" + i,
315315
randomBoolean(),
316316
randomBoolean(),
317317
randomBoolean(),
@@ -380,10 +380,7 @@ private static Map<String, Object> createApiKey(String name, String authHeader)
380380
}
381381

382382
private static Map<String, Object> createServiceAccountToken() throws IOException {
383-
final Request createServiceTokenRequest = new Request(
384-
"POST",
385-
"/_security/service/elastic/enterprise-search-server/credential/token"
386-
);
383+
final Request createServiceTokenRequest = new Request("POST", "/_security/service/elastic/fleet-server/credential/token");
387384
final Response createServiceTokenResponse = adminClient().performRequest(createServiceTokenRequest);
388385
assertOK(createServiceTokenResponse);
389386

x-pack/plugin/security/qa/service-account/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/service/ServiceAccountIT.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -490,19 +490,6 @@ public void testGetServiceAccount() throws IOException {
490490
)
491491
);
492492

493-
final Request getServiceAccountRequestEnterpriseSearchService = new Request(
494-
"GET",
495-
"_security/service/elastic/enterprise-search-server"
496-
);
497-
final Response getServiceAccountResponseEnterpriseSearchService = client().performRequest(
498-
getServiceAccountRequestEnterpriseSearchService
499-
);
500-
assertServiceAccountRoleDescriptor(
501-
getServiceAccountResponseEnterpriseSearchService,
502-
"elastic/enterprise-search-server",
503-
ELASTIC_ENTERPRISE_SEARCH_SERVER_ROLE_DESCRIPTOR
504-
);
505-
506493
final String requestPath = "_security/service/" + randomFrom("foo", "elastic/foo", "foo/bar");
507494
final Request getServiceAccountRequest4 = new Request("GET", requestPath);
508495
final Response getServiceAccountResponse4 = client().performRequest(getServiceAccountRequest4);

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccounts.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,42 +42,6 @@ final class ElasticServiceAccounts {
4242
)
4343
);
4444

45-
private static final ServiceAccount ENTERPRISE_SEARCH_ACCOUNT = new ElasticServiceAccount(
46-
"enterprise-search-server",
47-
new RoleDescriptor(
48-
NAMESPACE + "/enterprise-search-server",
49-
new String[] { "manage", "manage_security", "read_connector_secrets", "write_connector_secrets" },
50-
new RoleDescriptor.IndicesPrivileges[] {
51-
RoleDescriptor.IndicesPrivileges.builder()
52-
.indices(
53-
"search-*",
54-
".search-acl-filter-*",
55-
".elastic-analytics-collections",
56-
".ent-search-*",
57-
".monitoring-ent-search-*",
58-
"metricbeat-ent-search-*",
59-
"enterprise-search-*",
60-
"logs-app_search.analytics-default",
61-
"logs-elastic_analytics.events-*",
62-
"logs-enterprise_search.api-default",
63-
"logs-enterprise_search.audit-default",
64-
"logs-app_search.search_relevance_suggestions-default",
65-
"logs-crawler-default",
66-
"logs-elastic_crawler-default",
67-
"logs-workplace_search.analytics-default",
68-
"logs-workplace_search.content_events-default",
69-
".elastic-connectors*"
70-
)
71-
.privileges("manage", "read", "write")
72-
.build() },
73-
null,
74-
null,
75-
null,
76-
null,
77-
null
78-
)
79-
);
80-
8145
private static final ServiceAccount FLEET_ACCOUNT = new ElasticServiceAccount(
8246
"fleet-server",
8347
new RoleDescriptor(
@@ -210,7 +174,6 @@ final class ElasticServiceAccounts {
210174

211175
static final Map<String, ServiceAccount> ACCOUNTS = Stream.of(
212176
AUTO_OPS_ACCOUNT,
213-
ENTERPRISE_SEARCH_ACCOUNT,
214177
FLEET_ACCOUNT,
215178
FLEET_REMOTE_ACCOUNT,
216179
KIBANA_SYSTEM_ACCOUNT

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/service/TransportGetServiceAccountActionTests.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,10 @@ public void testDoExecute() {
4646
final PlainActionFuture<GetServiceAccountResponse> future1 = new PlainActionFuture<>();
4747
transportGetServiceAccountAction.doExecute(mock(Task.class), request1, future1);
4848
final GetServiceAccountResponse getServiceAccountResponse1 = future1.actionGet();
49-
assertThat(getServiceAccountResponse1.getServiceAccountInfos().length, equalTo(5));
49+
assertThat(getServiceAccountResponse1.getServiceAccountInfos().length, equalTo(4));
5050
assertThat(
5151
Arrays.stream(getServiceAccountResponse1.getServiceAccountInfos()).map(ServiceAccountInfo::getPrincipal).toList(),
52-
containsInAnyOrder(
53-
"elastic/auto-ops",
54-
"elastic/enterprise-search-server",
55-
"elastic/fleet-server",
56-
"elastic/fleet-server-remote",
57-
"elastic/kibana"
58-
)
52+
containsInAnyOrder("elastic/auto-ops", "elastic/fleet-server", "elastic/fleet-server-remote", "elastic/kibana")
5953
);
6054

6155
final GetServiceAccountRequest request2 = new GetServiceAccountRequest("elastic", "fleet-server");

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,12 @@
4545
import org.elasticsearch.transport.TransportRequest;
4646
import org.elasticsearch.xpack.core.ilm.action.GetLifecycleAction;
4747
import org.elasticsearch.xpack.core.ilm.action.ILMActions;
48-
import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkAction;
4948
import org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyAction;
5049
import org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyRequest;
5150
import org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyAction;
5251
import org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyRequest;
5352
import org.elasticsearch.xpack.core.security.action.apikey.InvalidateApiKeyAction;
5453
import org.elasticsearch.xpack.core.security.action.apikey.InvalidateApiKeyRequest;
55-
import org.elasticsearch.xpack.core.security.action.role.PutRoleAction;
56-
import org.elasticsearch.xpack.core.security.action.user.PutUserAction;
5754
import org.elasticsearch.xpack.core.security.authc.Authentication;
5855
import org.elasticsearch.xpack.core.security.authc.AuthenticationTestHelper;
5956
import org.elasticsearch.xpack.core.security.authc.service.ServiceAccount;
@@ -394,93 +391,6 @@ public void testElasticServiceAccount() {
394391
);
395392
}
396393

397-
public void testElasticEnterpriseSearchServerAccount() {
398-
final Role role = Role.buildFromRoleDescriptor(
399-
ElasticServiceAccounts.ACCOUNTS.get("elastic/enterprise-search-server").roleDescriptor(),
400-
new FieldPermissionsCache(Settings.EMPTY),
401-
RESTRICTED_INDICES
402-
);
403-
404-
final Authentication authentication = AuthenticationTestHelper.builder().serviceAccount().build();
405-
final TransportRequest request = mock(TransportRequest.class);
406-
407-
// manage
408-
assertThat(role.cluster().check(ClusterUpdateSettingsAction.NAME, request, authentication), is(true));
409-
410-
// manage_security
411-
assertThat(
412-
role.cluster()
413-
.check(CreateApiKeyAction.NAME, new CreateApiKeyRequest(randomAlphaOfLengthBetween(3, 8), null, null), authentication),
414-
is(true)
415-
);
416-
assertThat(
417-
role.cluster().check(GetApiKeyAction.NAME, GetApiKeyRequest.builder().ownedByAuthenticatedUser().build(), authentication),
418-
is(true)
419-
);
420-
assertThat(role.cluster().check(InvalidateApiKeyAction.NAME, InvalidateApiKeyRequest.forOwnedApiKeys(), authentication), is(true));
421-
422-
assertThat(role.cluster().check(PutUserAction.NAME, request, authentication), is(true));
423-
assertThat(role.cluster().check(PutRoleAction.NAME, request, authentication), is(true));
424-
425-
// manage_index_templates
426-
assertThat(role.cluster().check(TransportPutIndexTemplateAction.TYPE.name(), request, authentication), is(true));
427-
assertThat(role.cluster().check(GetIndexTemplatesAction.NAME, request, authentication), is(true));
428-
assertThat(role.cluster().check(TransportDeleteIndexTemplateAction.TYPE.name(), request, authentication), is(true));
429-
430-
// monitoring
431-
assertThat(role.cluster().check(MonitoringBulkAction.NAME, request, authentication), is(true));
432-
assertThat(role.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(true));
433-
434-
// manage_ilm
435-
assertThat(role.cluster().check(GetLifecycleAction.NAME, request, authentication), is(true));
436-
assertThat(role.cluster().check(ILMActions.PUT.name(), request, authentication), is(true));
437-
438-
// Connector secrets. Enterprise Search has read and write access.
439-
assertThat(role.cluster().check("cluster:admin/xpack/connector/secret/delete", request, authentication), is(true));
440-
assertThat(role.cluster().check("cluster:admin/xpack/connector/secret/get", request, authentication), is(true));
441-
assertThat(role.cluster().check("cluster:admin/xpack/connector/secret/post", request, authentication), is(true));
442-
assertThat(role.cluster().check("cluster:admin/xpack/connector/secret/put", request, authentication), is(true));
443-
444-
List.of(
445-
"search-" + randomAlphaOfLengthBetween(1, 20),
446-
".search-acl-filter-" + randomAlphaOfLengthBetween(1, 20),
447-
".elastic-analytics-collections",
448-
".ent-search-" + randomAlphaOfLengthBetween(1, 20),
449-
".monitoring-ent-search-" + randomAlphaOfLengthBetween(1, 20),
450-
"metricbeat-ent-search-" + randomAlphaOfLengthBetween(1, 20),
451-
"enterprise-search-" + randomAlphaOfLengthBetween(1, 20),
452-
"logs-app_search.analytics-default",
453-
"logs-elastic_analytics.events-" + randomAlphaOfLengthBetween(1, 20),
454-
"logs-enterprise_search.api-default",
455-
"logs-enterprise_search.audit-default",
456-
"logs-app_search.search_relevance_suggestions-default",
457-
"logs-crawler-default",
458-
"logs-workplace_search.analytics-default",
459-
"logs-workplace_search.content_events-default",
460-
".elastic-connectors*",
461-
"logs-elastic_crawler-default"
462-
).forEach(index -> {
463-
final IndexAbstraction enterpriseSearchIndex = mockIndexAbstraction(index);
464-
assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(enterpriseSearchIndex), is(true));
465-
assertThat(role.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(enterpriseSearchIndex), is(true));
466-
assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(enterpriseSearchIndex), is(true));
467-
assertThat(role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(enterpriseSearchIndex), is(true));
468-
assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(enterpriseSearchIndex), is(true));
469-
assertThat(role.indices().allowedIndicesMatcher(TransportBulkAction.NAME).test(enterpriseSearchIndex), is(true));
470-
assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(enterpriseSearchIndex), is(true));
471-
assertThat(role.indices().allowedIndicesMatcher(TransportMultiGetAction.NAME).test(enterpriseSearchIndex), is(true));
472-
assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(enterpriseSearchIndex), is(true));
473-
assertThat(role.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(enterpriseSearchIndex), is(true));
474-
assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(enterpriseSearchIndex), is(true));
475-
assertThat(
476-
role.indices().allowedIndicesMatcher(TransportUpdateSettingsAction.TYPE.name()).test(enterpriseSearchIndex),
477-
is(true)
478-
);
479-
assertThat(role.indices().allowedIndicesMatcher(RefreshAction.NAME).test(enterpriseSearchIndex), is(true));
480-
assertThat(role.indices().allowedIndicesMatcher("indices:foo").test(enterpriseSearchIndex), is(false));
481-
});
482-
}
483-
484394
private IndexAbstraction mockIndexAbstraction(String name) {
485395
IndexAbstraction mock = mock(IndexAbstraction.class);
486396
when(mock.getName()).thenReturn(name);

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ServiceAccountServiceTests.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,7 @@ public void stopThreadPool() {
103103
public void testGetServiceAccountPrincipals() {
104104
assertThat(
105105
ServiceAccountService.getServiceAccountPrincipals(),
106-
containsInAnyOrder(
107-
"elastic/auto-ops",
108-
"elastic/enterprise-search-server",
109-
"elastic/fleet-server",
110-
"elastic/fleet-server-remote",
111-
"elastic/kibana"
112-
)
106+
containsInAnyOrder("elastic/auto-ops", "elastic/fleet-server", "elastic/fleet-server-remote", "elastic/kibana")
113107
);
114108
}
115109

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/service_accounts/10_basic.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,21 @@ teardown:
2020
name: api-token-kibana
2121
ignore: 404
2222

23-
- do:
24-
security.delete_service_token:
25-
namespace: elastic
26-
service: enterprise-search-server
27-
name: api-token-enterprise-search-server
28-
ignore: 404
29-
3023
---
3124
"Test get service accounts":
3225
- do:
3326
security.get_service_accounts: {}
34-
- length: { '': 5 }
27+
- length: { '': 4 }
3528
- is_true: "elastic/auto-ops"
36-
- is_true: "elastic/enterprise-search-server"
3729
- is_true: "elastic/fleet-server"
3830
- is_true: "elastic/fleet-server-remote"
3931
- is_true: "elastic/kibana"
4032

4133
- do:
4234
security.get_service_accounts:
4335
namespace: elastic
44-
- length: { '': 5 }
36+
- length: { '': 4 }
4537
- is_true: "elastic/auto-ops"
46-
- is_true: "elastic/enterprise-search-server"
4738
- is_true: "elastic/fleet-server"
4839
- is_true: "elastic/fleet-server-remote"
4940
- is_true: "elastic/kibana"
@@ -79,16 +70,6 @@ teardown:
7970
- match: { "token.name": "api-token-kibana" }
8071
- set: { "token.value": service_token_kibana }
8172

82-
- do:
83-
security.create_service_token:
84-
namespace: elastic
85-
service: enterprise-search-server
86-
name: api-token-enterprise-search-server
87-
88-
- is_true: created
89-
- match: { "token.name": "api-token-enterprise-search-server" }
90-
- set: { "token.value": service_token_enterprise_search_server }
91-
9273
- do:
9374
headers:
9475
Authorization: Bearer ${service_token_fleet}

0 commit comments

Comments
 (0)