|
27 | 27 | import org.junit.runner.RunWith; |
28 | 28 |
|
29 | 29 | import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; |
30 | | -import org.opensearch.action.admin.indices.create.CreateIndexRequest; |
31 | 30 | import org.opensearch.action.fieldcaps.FieldCapabilitiesRequest; |
32 | 31 | import org.opensearch.action.fieldcaps.FieldCapabilitiesResponse; |
33 | 32 | import org.opensearch.action.get.GetRequest; |
|
44 | 43 | import org.opensearch.action.search.SearchScrollRequest; |
45 | 44 | import org.opensearch.client.Client; |
46 | 45 | import org.opensearch.client.RestHighLevelClient; |
47 | | -import org.opensearch.index.mapper.SourceFieldMapper; |
48 | | -import org.opensearch.index.mapper.size.SizeFieldMapper; |
49 | | -import org.opensearch.index.query.MatchAllQueryBuilder; |
50 | 46 | import org.opensearch.index.query.QueryBuilder; |
51 | 47 | import org.opensearch.index.query.QueryBuilders; |
52 | | -import org.opensearch.plugin.mapper.MapperSizePlugin; |
53 | 48 | import org.opensearch.search.aggregations.Aggregation; |
54 | 49 | import org.opensearch.search.aggregations.metrics.ParsedAvg; |
55 | | -import org.opensearch.search.builder.SearchSourceBuilder; |
56 | 50 | import org.opensearch.search.sort.SortOrder; |
57 | 51 | import org.opensearch.test.framework.TestSecurityConfig; |
58 | 52 | import org.opensearch.test.framework.cluster.ClusterManager; |
|
61 | 55 |
|
62 | 56 | import static org.hamcrest.MatcherAssert.assertThat; |
63 | 57 | import static org.hamcrest.Matchers.allOf; |
64 | | -import static org.hamcrest.Matchers.containsString; |
65 | 58 | import static org.hamcrest.Matchers.everyItem; |
66 | 59 | import static org.hamcrest.Matchers.greaterThan; |
67 | 60 | import static org.hamcrest.Matchers.instanceOf; |
|
101 | 94 | import static org.opensearch.test.framework.matcher.SearchResponseMatchers.isSuccessfulSearchResponse; |
102 | 95 | import static org.opensearch.test.framework.matcher.SearchResponseMatchers.numberOfTotalHitsIsEqualTo; |
103 | 96 | import static org.opensearch.test.framework.matcher.SearchResponseMatchers.searchHitContainsFieldWithValue; |
104 | | -import static org.opensearch.test.framework.matcher.SearchResponseMatchers.searchHitDoesContainField; |
105 | 97 | import static org.opensearch.test.framework.matcher.SearchResponseMatchers.searchHitDoesNotContainField; |
106 | 98 | import static org.opensearch.test.framework.matcher.SearchResponseMatchers.searchHitsContainDocumentWithId; |
107 | 99 |
|
@@ -220,7 +212,6 @@ public class FlsAndFieldMaskingTests { |
220 | 212 | .nodeSettings( |
221 | 213 | Map.of("plugins.security.restapi.roles_enabled", List.of("user_" + ADMIN_USER.getName() + "__" + ALL_ACCESS.getName())) |
222 | 214 | ) |
223 | | - .plugin(MapperSizePlugin.class) |
224 | 215 | .authc(AUTHC_HTTPBASIC_INTERNAL) |
225 | 216 | .users( |
226 | 217 | ADMIN_USER, |
@@ -435,10 +426,6 @@ public void flsEnabledFieldsAreHiddenForNormalUsers() throws IOException { |
435 | 426 |
|
436 | 427 | private static List<String> createIndexWithDocs(String indexName, Song... songs) { |
437 | 428 | try (Client client = cluster.getInternalNodeClient()) { |
438 | | - client.admin() |
439 | | - .indices() |
440 | | - .create(new CreateIndexRequest(indexName).mapping(Map.of("_size", Map.of("enabled", true)))) |
441 | | - .actionGet(); |
442 | 429 | return Stream.of(songs).map(song -> { |
443 | 430 | IndexResponse response = client.index(new IndexRequest(indexName).setRefreshPolicy(IMMEDIATE).source(song.asMap())) |
444 | 431 | .actionGet(); |
@@ -482,14 +469,6 @@ private static void assertSearchHitsDoNotContainField(SearchResponse response, S |
482 | 469 | .forEach(index -> assertThat(response, searchHitDoesNotContainField(index, excludedField))); |
483 | 470 | } |
484 | 471 |
|
485 | | - private static void assertSearchHitsDoContainField(SearchResponse response, String includedField) { |
486 | | - assertThat(response, isSuccessfulSearchResponse()); |
487 | | - assertThat(response.getHits().getHits().length, greaterThan(0)); |
488 | | - IntStream.range(0, response.getHits().getHits().length) |
489 | | - .boxed() |
490 | | - .forEach(index -> assertThat(response, searchHitDoesContainField(index, includedField))); |
491 | | - } |
492 | | - |
493 | 472 | @Test |
494 | 473 | public void searchForDocuments() throws IOException { |
495 | 474 | // FIELD MASKING |
@@ -832,28 +811,4 @@ public void getFieldCapabilities() throws IOException { |
832 | 811 | } |
833 | 812 | } |
834 | 813 |
|
835 | | - @Test |
836 | | - public void flsWithIncludesRulesIncludesFieldMappersFromPlugins() throws IOException { |
837 | | - String indexName = "fls_includes_index"; |
838 | | - TestSecurityConfig.Role userRole = new TestSecurityConfig.Role("fls_include_stars_reader").clusterPermissions( |
839 | | - "cluster_composite_ops_ro" |
840 | | - ).indexPermissions("read").fls(FIELD_STARS).on("*"); |
841 | | - TestSecurityConfig.User user = createUserWithRole("fls_includes_user", userRole); |
842 | | - List<String> docIds = createIndexWithDocs(indexName, SONGS[0], SONGS[1]); |
843 | | - |
844 | | - try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(user)) { |
845 | | - SearchRequest searchRequest = new SearchRequest(indexName); |
846 | | - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); |
847 | | - MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery(); |
848 | | - searchSourceBuilder.storedFields(List.of(SizeFieldMapper.NAME, SourceFieldMapper.NAME)); |
849 | | - searchSourceBuilder.query(matchAllQueryBuilder); |
850 | | - searchRequest.source(searchSourceBuilder); |
851 | | - SearchResponse searchResponse = restHighLevelClient.search(searchRequest, DEFAULT); |
852 | | - |
853 | | - assertSearchHitsDoContainField(searchResponse, FIELD_STARS); |
854 | | - assertThat(searchResponse.toString(), containsString(SizeFieldMapper.NAME)); |
855 | | - assertSearchHitsDoNotContainField(searchResponse, FIELD_ARTIST); |
856 | | - } |
857 | | - } |
858 | | - |
859 | 814 | } |
0 commit comments