diff --git a/shield/src/main/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolver.java b/shield/src/main/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolver.java index d44f36b8c7f..02dbc88324f 100644 --- a/shield/src/main/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolver.java +++ b/shield/src/main/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolver.java @@ -18,7 +18,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.IndexMissingException; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.shield.User; import org.elasticsearch.shield.authz.AuthorizationService; import org.elasticsearch.transport.TransportRequest; @@ -138,7 +138,7 @@ public class DefaultIndicesResolver implements IndicesResolver //If we can't replace because we got an empty set, we can only throw exception. if (finalAliases.isEmpty()) { Index index = matchAllAliases ? new Index(MetaData.ALL) : new Index(Arrays.toString(aliases)); - throw new IndexMissingException(index); + throw new IndexNotFoundException(index.getName()); } return finalAliases; } @@ -204,9 +204,9 @@ public class DefaultIndicesResolver implements IndicesResolver } } } else { - //MetaData#convertFromWildcards checks if the index exists here and throws IndexMissingException if not (based on ignore_unavailable). + //MetaData#convertFromWildcards checks if the index exists here and throws IndexNotFoundException if not (based on ignore_unavailable). //Do nothing as if the index is missing but the user is not authorized to it an AuthorizationException will be thrown. - //If the index is missing and the user is authorized to it, core will throw IndexMissingException later on. + //If the index is missing and the user is authorized to it, core will throw IndexNotFoundException later on. //There is no problem with deferring this as we are dealing with an explicit name, not with wildcards. if (minus) { finalIndices.remove(aliasOrIndex); @@ -227,7 +227,7 @@ public class DefaultIndicesResolver implements IndicesResolver //Downside of this is that a single item exception is going to make fail the composite request that holds it as a whole. if (resolvedIndices == null || resolvedIndices.isEmpty()) { Index index = IndexNameExpressionResolver.isAllIndices(indicesList(originalIndices)) ? new Index(MetaData.ALL) : new Index(Arrays.toString(originalIndices)); - throw new IndexMissingException(index); + throw new IndexNotFoundException(index.getName()); } return resolvedIndices; } diff --git a/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java b/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java index 810cd6972a2..11e977925d2 100644 --- a/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java @@ -19,7 +19,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.LocalTransportAddress; import org.elasticsearch.env.Environment; -import org.elasticsearch.indices.IndexMissingException; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.node.Node; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.search.SearchHit; @@ -190,7 +190,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { } } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAnonymousAccessDenied_Transport_Muted() throws Exception { initialize("anonymous_access_denied"); TransportMessage message = randomFrom(new RemoteHostMockMessage(), new LocalHostMockMessage(), new MockIndicesTransportMessage()); @@ -215,7 +215,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { assertThat(hit.field("request_body").getValue(), notNullValue()); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAnonymousAccessDenied_Rest_Muted() throws Exception { initialize("anonymous_access_denied"); RestRequest request = mockRestRequest(); @@ -272,7 +272,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { } } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAuthenticationFailed_Transport_Muted() throws Exception { initialize("authentication_failed"); TransportMessage message = randomFrom(new RemoteHostMockMessage(), new LocalHostMockMessage(), new MockIndicesTransportMessage()); @@ -280,7 +280,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { getClient().prepareExists(resolveIndexName()).execute().actionGet(); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAuthenticationFailed_Transport_NoToken_Muted() throws Exception { initialize("authentication_failed"); TransportMessage message = randomFrom(new RemoteHostMockMessage(), new LocalHostMockMessage(), new MockIndicesTransportMessage()); @@ -323,7 +323,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { assertThat(hit.field("request_body").getValue(), notNullValue()); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAuthenticationFailed_Rest_Muted() throws Exception { initialize("authentication_failed"); RestRequest request = mockRestRequest(); @@ -331,7 +331,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { getClient().prepareExists(resolveIndexName()).execute().actionGet(); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAuthenticationFailed_Rest_NoToken_Muted() throws Exception { initialize("authentication_failed"); RestRequest request = mockRestRequest(); @@ -367,7 +367,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { } } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAuthenticationFailed_Transport_Realm_Muted() throws Exception { initialize("authentication_failed"); TransportMessage message = randomFrom(new RemoteHostMockMessage(), new LocalHostMockMessage(), new MockIndicesTransportMessage()); @@ -393,7 +393,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { assertThat(hit.field("request_body").getValue(), notNullValue()); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAuthenticationFailed_Rest_Realm_Muted() throws Exception { initialize("authentication_failed"); RestRequest request = mockRestRequest(); @@ -420,7 +420,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { } } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAccessGranted_Muted() throws Exception { initialize("access_granted"); TransportMessage message = randomFrom(new RemoteHostMockMessage(), new LocalHostMockMessage(), new MockIndicesTransportMessage()); @@ -442,7 +442,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { assertEquals("internal:_action", hit.field("action").getValue()); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testSystemAccessGranted_Muted() throws Exception { initialize(); TransportMessage message = randomBoolean() ? new RemoteHostMockMessage() : new LocalHostMockMessage(); @@ -470,7 +470,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { } } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testAccessDenied_Muted() throws Exception { initialize("access_denied"); TransportMessage message = randomFrom(new RemoteHostMockMessage(), new LocalHostMockMessage(), new MockIndicesTransportMessage()); @@ -494,7 +494,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { assertEquals("_action", hit.field("action").getValue()); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testTamperedRequest_Muted() throws Exception { initialize("tampered_request"); TransportRequest message = new RemoteHostMockTransportRequest(); @@ -518,7 +518,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { assertEquals("default", hit.field("transport_profile").getValue()); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testConnectionGranted_Muted() throws Exception { initialize("connection_granted"); InetAddress inetAddress = InetAddress.getLocalHost(); @@ -543,7 +543,7 @@ public class IndexAuditTrailTests extends ShieldIntegrationTest { assertEquals("default", hit.field("transport_profile").getValue()); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testConnectionDenied_Muted() throws Exception { initialize("connection_denied"); InetAddress inetAddress = InetAddress.getLocalHost(); diff --git a/shield/src/test/java/org/elasticsearch/shield/authz/IndexAliasesTests.java b/shield/src/test/java/org/elasticsearch/shield/authz/IndexAliasesTests.java index 242804f4334..7ff3ba0e981 100644 --- a/shield/src/test/java/org/elasticsearch/shield/authz/IndexAliasesTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/authz/IndexAliasesTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequestBuilder; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.indices.IndexMissingException; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.shield.authc.support.Hasher; import org.elasticsearch.shield.authc.support.SecuredString; import org.elasticsearch.test.ShieldIntegrationTest; @@ -102,7 +102,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().addAlias("test_*", "test_alias") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_only", new SecuredString("test123".toCharArray()))).get(); fail("add alias should have failed due to missing manage_aliases privileges"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[test_*]")); } } @@ -134,7 +134,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().removeAlias("test_1", "alias_*") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_only", new SecuredString("test123".toCharArray()))).get(); fail("remove alias should have failed due to missing manage_aliases privileges"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[alias_*")); } @@ -142,7 +142,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().removeAlias("test_1", "_all") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_only", new SecuredString("test123".toCharArray()))).get(); fail("remove alias should have failed due to missing manage_aliases privileges"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } } @@ -162,7 +162,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases("_all").setIndices("test_1").setIndicesOptions(IndicesOptions.lenientExpandOpen()) .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_only", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } @@ -170,7 +170,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases().setIndices("test_1").setIndicesOptions(IndicesOptions.lenientExpandOpen()) .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_only", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } @@ -178,7 +178,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases("test_alias").setIndices("test_*").setIndicesOptions(IndicesOptions.lenientExpandOpen()) .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_only", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[test_*]")); } @@ -186,7 +186,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases() .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_only", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } } @@ -254,7 +254,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().removeAlias("test_1", "test_alias_*") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_test", new SecuredString("test123".toCharArray()))).get(); fail("remove alias should have failed due to no existing matching aliases to expand test_alias_* to"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[test_alias_*]")); } @@ -263,7 +263,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().removeAlias("test_1", "_all") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_test", new SecuredString("test123".toCharArray()))).get(); fail("remove alias should have failed due to no existing matching aliases to expand _all to"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } @@ -381,7 +381,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().addAlias("test_*", "alias_1") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("add alias should have failed due to missing manage_aliases privileges on test_1"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[test_*]")); } } @@ -434,7 +434,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().removeAlias("test_*", "alias_1") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("remove alias should have failed due to missing manage_aliases privileges on test_*"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[test_*]")); } } @@ -459,7 +459,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases().setIndices("test_*").setAliases("test_alias") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges on test_*"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[test_*]")); } @@ -468,7 +468,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases().setAliases("test_alias") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges on any index"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } @@ -477,7 +477,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases().setIndices("test_1").setAliases("test_*") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges on test_1"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[test_*]")); } @@ -486,7 +486,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases().setIndices("test_1").setAliases("_all") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges on test_1"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } @@ -495,7 +495,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases().setIndices("test_1") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges on test_1"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } @@ -504,7 +504,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareGetAliases() .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_alias", new SecuredString("test123".toCharArray()))).get(); fail("get alias should have failed due to missing manage_aliases privileges on test_1"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } } @@ -563,7 +563,7 @@ public class IndexAliasesTests extends ShieldIntegrationTest { client().admin().indices().prepareAliases().removeAlias("test_1", "_all") .putHeader(BASIC_AUTH_HEADER, basicAuthHeaderValue("create_test_aliases_test_alias", new SecuredString("test123".toCharArray()))).get(); fail("remove alias should have failed due to no existing aliases matching _all"); - } catch(IndexMissingException e) { + } catch(IndexNotFoundException e) { assertThat(e.toString(), containsString("[_all]")); } } diff --git a/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolverTests.java b/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolverTests.java index df6d6c885ec..857b7667733 100644 --- a/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolverTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/DefaultIndicesResolverTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.indices.IndexMissingException; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.shield.User; import org.elasticsearch.shield.authz.AuthorizationService; import org.elasticsearch.test.ElasticsearchTestCase; @@ -195,13 +195,13 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.indices(), arrayContaining(replacedIndices)); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveNonMatchingIndices() { SearchRequest request = new SearchRequest("missing*"); defaultIndicesResolver.resolve(user, SearchAction.NAME, request, metaData); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveNoAuthorizedIndices() { SearchRequest request = new SearchRequest(); defaultIndicesResolver.resolve(userNoIndices, SearchAction.NAME, request, metaData); @@ -301,7 +301,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.getAliasActions().get(1).aliases(), arrayContaining("alias2")); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveWildcardsIndicesAliasesRequestNoMatchingIndices() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAlias("alias1", "foo*"); @@ -329,7 +329,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.getAliasActions().get(1).aliases(), arrayContaining("alias2")); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveAllIndicesAliasesRequestNoAuthorizedIndices() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAlias("alias1", "_all"); @@ -337,7 +337,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { defaultIndicesResolver.resolve(userNoIndices, IndicesAliasesAction.NAME, request, metaData); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveWildcardsIndicesAliasesRequestNoAuthorizedIndices() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAlias("alias1", "foo*"); @@ -432,7 +432,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.getAliasActions().get(1).aliases(), arrayContaining("foofoobar", "explicit")); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveAliasesWildcardsIndicesAliasesRequestDeleteActionsNoAuthorizedIndices() { IndicesAliasesRequest request = new IndicesAliasesRequest(); request.addAliasAction(AliasAction.newRemoveAliasAction("foo*", "foo*")); @@ -499,7 +499,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.aliases(), arrayContaining("alias1")); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveWildcardsGetAliasesRequestNoMatchingIndices() { GetAliasesRequest request = new GetAliasesRequest(); request.aliases("alias3"); @@ -548,7 +548,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.aliases(), arrayContaining("alias1")); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveAllGetAliasesRequestNoAuthorizedIndices() { GetAliasesRequest request = new GetAliasesRequest(); request.aliases("alias1"); @@ -557,7 +557,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { defaultIndicesResolver.resolve(userNoIndices, GetAliasesAction.NAME, request, metaData); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveWildcardsGetAliasesRequestNoAuthorizedIndices() { GetAliasesRequest request = new GetAliasesRequest(); request.aliases("alias1"); @@ -634,7 +634,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.aliases(), arrayContaining("foofoobar")); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveAliasesWildcardsGetAliasesRequestNoAuthorizedIndices() { GetAliasesRequest request = new GetAliasesRequest(); //no authorized aliases match bar*, hence the request fails @@ -643,7 +643,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { defaultIndicesResolver.resolve(user, GetAliasesAction.NAME, request, metaData); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveAliasesAllGetAliasesRequestNoAuthorizedIndices() { GetAliasesRequest request = new GetAliasesRequest(); if (randomBoolean()) { @@ -722,7 +722,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { assertThat(request.subRequests().get(1).indices(), equalTo(new String[]{"missing"})); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveMultiSearchWildcardsNoMatchingIndices() { MultiSearchRequest request = new MultiSearchRequest(); request.add(Requests.searchRequest("missing*")); @@ -730,7 +730,7 @@ public class DefaultIndicesResolverTests extends ElasticsearchTestCase { defaultIndicesResolver.resolve(user, MultiSearchAction.NAME, request, metaData); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testResolveMultiSearchWildcardsNoAuthorizedIndices() { MultiSearchRequest request = new MultiSearchRequest(); request.add(Requests.searchRequest("foofoo*")); diff --git a/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/IndicesResolverIntegrationTests.java b/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/IndicesResolverIntegrationTests.java index ece2767f5ca..3dc32790c91 100644 --- a/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/IndicesResolverIntegrationTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/authz/indicesresolver/IndicesResolverIntegrationTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.search.MultiSearchResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.Requests; -import org.elasticsearch.indices.IndexMissingException; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.search.SearchHit; import org.elasticsearch.test.ShieldIntegrationTest; import org.elasticsearch.test.ShieldSettingsSource; @@ -55,30 +55,30 @@ public class IndicesResolverIntegrationTests extends ShieldIntegrationTest { assertReturnedIndices(searchResponse, "test1", "test2", "test3"); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testSearchNonAuthorizedWildcard() { //wildcard doesn't match any authorized index createIndices("test1", "test2", "index1", "index2"); client().prepareSearch("index*").get(); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testEmptyClusterSearchForAll() { client().prepareSearch().get(); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testEmptyClusterSearchForWildcard() { client().prepareSearch("*").get(); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testEmptyAuthorizedIndicesSearchForAll() { createIndices("index1", "index2"); client().prepareSearch().get(); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testEmptyAuthorizedIndicesSearchForWildcard() { createIndices("index1", "index2"); client().prepareSearch("*").get(); @@ -91,13 +91,13 @@ public class IndicesResolverIntegrationTests extends ShieldIntegrationTest { } @Test - public void testIndexMissing() { + public void testIndexNotFound() { createIndices("test1", "test2", "index1"); assertThrowsAuthorizationException(client().prepareSearch("missing")); } @Test - public void testIndexMissingIgnoreUnavailable() { + public void testIndexNotFoundIgnoreUnavailable() { createIndices("test1", "test2", "index1"); assertThrowsAuthorizationException(client().prepareSearch("missing").setIndicesOptions(IndicesOptions.lenientExpandOpen())); } @@ -176,7 +176,7 @@ public class IndicesResolverIntegrationTests extends ShieldIntegrationTest { assertThat(multiSearchResponse.getResponses()[1].getFailure().toString(), equalTo("[test4] no such index")); } - @Test(expected = IndexMissingException.class) + @Test(expected = IndexNotFoundException.class) public void testMultiSearchWildcard() { //test4 is missing but authorized, only that specific item fails createIndices("test1", "test2", "test3", "index1");