|
45 | 45 | import org.elasticsearch.transport.TransportRequest; |
46 | 46 | import org.elasticsearch.xpack.core.ilm.action.GetLifecycleAction; |
47 | 47 | import org.elasticsearch.xpack.core.ilm.action.ILMActions; |
48 | | -import org.elasticsearch.xpack.core.monitoring.action.MonitoringBulkAction; |
49 | 48 | import org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyAction; |
50 | 49 | import org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyRequest; |
51 | 50 | import org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyAction; |
52 | 51 | import org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyRequest; |
53 | 52 | import org.elasticsearch.xpack.core.security.action.apikey.InvalidateApiKeyAction; |
54 | 53 | 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; |
57 | 54 | import org.elasticsearch.xpack.core.security.authc.Authentication; |
58 | 55 | import org.elasticsearch.xpack.core.security.authc.AuthenticationTestHelper; |
59 | 56 | import org.elasticsearch.xpack.core.security.authc.service.ServiceAccount; |
@@ -394,93 +391,6 @@ public void testElasticServiceAccount() { |
394 | 391 | ); |
395 | 392 | } |
396 | 393 |
|
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 | | - |
484 | 394 | private IndexAbstraction mockIndexAbstraction(String name) { |
485 | 395 | IndexAbstraction mock = mock(IndexAbstraction.class); |
486 | 396 | when(mock.getName()).thenReturn(name); |
|
0 commit comments