From f158be89b89238046dd110f5c5bcb70ab2538bd2 Mon Sep 17 00:00:00 2001 From: Ali Beyad Date: Mon, 22 May 2017 13:16:53 -0400 Subject: [PATCH] [TEST] fixes tests that attempt to delete documents from missing indices, as that is now prohibited by elastic/elasticsearch#24518 relates elastic/x-pack-elasticsearch#1511 Original commit: elastic/x-pack-elasticsearch@026a516196654b89f48094513c95cbef8a3558fd --- .../security/authc/esnative/NativeRealmIntegTests.java | 5 +++-- .../xpack/security/authz/WriteActionsTests.java | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java index 44fdff501b9..97f3f162061 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java @@ -101,10 +101,11 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/x-pack-elasticsearch/pull/1507") public void testDeletingNonexistingUserAndRole() throws Exception { SecurityClient c = securityClient(); - DeleteUserResponse resp = c.prepareDeleteUser("joe").get(); + // first create the index so it exists + c.preparePutUser("joe", "s3kirt".toCharArray(), "role1", "user").get(); + DeleteUserResponse resp = c.prepareDeleteUser("missing").get(); assertFalse("user shouldn't be found", resp.found()); DeleteRoleResponse resp2 = c.prepareDeleteRole("role").get(); assertFalse("role shouldn't be found", resp2.found()); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java index dd28702f6dc..6afaa3e1d2c 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/authz/WriteActionsTests.java @@ -14,6 +14,7 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.update.UpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.Requests; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.engine.DocumentMissingException; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.SecurityIntegTestCase; @@ -54,7 +55,6 @@ public class WriteActionsTests extends SecurityIntegTestCase { BulkAction.NAME + "[s]"); } - @AwaitsFix(bugUrl = "https://github.com/elastic/x-pack-elasticsearch/issues/1511") public void testDelete() { createIndex("test1", "index1"); client().prepareIndex("test1", "type", "id").setSource("field", "value").get(); @@ -62,9 +62,7 @@ public class WriteActionsTests extends SecurityIntegTestCase { assertThrowsAuthorizationExceptionDefaultUsers(client().prepareDelete("index1", "type", "id")::get, BulkAction.NAME + "[s]"); - assertEquals(RestStatus.NOT_FOUND, client().prepareDelete("test4", "type", "id").get().status()); - - assertThrowsAuthorizationExceptionDefaultUsers(client().prepareDelete("missing", "type", "id")::get, BulkAction.NAME + "[s]"); + expectThrows(IndexNotFoundException.class, () -> client().prepareDelete("test4", "type", "id").get()); } public void testUpdate() {