Skip to content

Commit 8c93a11

Browse files
Fix security tests
1 parent c63d906 commit 8c93a11

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
103103
import static org.hamcrest.Matchers.hasKey;
104104
import static org.hamcrest.Matchers.hasSize;
105+
import static org.hamcrest.Matchers.is;
105106
import static org.hamcrest.Matchers.not;
106107
import static org.hamcrest.Matchers.nullValue;
107108

@@ -913,6 +914,13 @@ public void testIndexMode() throws Exception {
913914
assertThat(actualIndexModes, equalTo(indexModes));
914915
}
915916

917+
public void testNoneExpressionIndices() {
918+
// The auth code injects the pattern ["*", "-*"] which effectively means a request that requests no indices
919+
FieldCapabilitiesResponse response = client().prepareFieldCaps("*", "-*").setFields("*").get();
920+
921+
assertThat(response.getIndices().length, is(0));
922+
}
923+
916924
private void assertIndices(FieldCapabilitiesResponse response, String... indices) {
917925
assertNotNull(response.getIndices());
918926
Arrays.sort(indices);

server/src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private void doExecuteForked(Task task, FieldCapabilitiesRequest request, Action
165165
if (localIndexNames.length == 0) {
166166
String[] concreteIndexNames = indexNameExpressionResolver.concreteIndexNames(projectMetadata, indicesOptions);
167167
resolvedLocallyList.add(createResolvedIndexExpression(Metadata.ALL, concreteIndexNames));
168-
} else {
168+
} else if (IndexNameExpressionResolver.isNoneExpression(localIndexNames) == false) {
169169
for (String localIndexName : localIndexNames) {
170170
String[] concreteIndexNames = indexNameExpressionResolver.concreteIndexNames(
171171
projectMetadata,

0 commit comments

Comments
 (0)