From 6d535043f860687b08e2d13f3a2fb9b0dee02cbf Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Wed, 29 Jun 2016 17:09:48 +0200 Subject: [PATCH] [SECURITY] Added a `teardown` section to the integration test for roles Currently, the REST tests for security (and possibly others) don't clean up the environment after they have run, eg. they don't delete the users and roles they create. This leads to test failures, because in a subsequent run, a user or role already exists, so eg. a test like `match: { role: { created: true } }` fails. This patch adds a `teardown` section to the test, with `do` actions which are to be executed _after_ the test runs. This patch assumes that REST tests runners for all languages support the `teardown` directive in a xUnimt nomenclature -- similarly to the `setup` directive, which they already support. Original commit: elastic/x-pack-elasticsearch@70d0ff4ee98cdd1e7e17fe6bf832f8b51a802e96 --- .../test/roles/11_idx_arrays.yaml | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/elasticsearch/x-pack/security/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yaml b/elasticsearch/x-pack/security/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yaml index aeda2d10749..10909bfb3ab 100644 --- a/elasticsearch/x-pack/security/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yaml +++ b/elasticsearch/x-pack/security/src/test/resources/rest-api-spec/test/roles/11_idx_arrays.yaml @@ -3,9 +3,28 @@ - skip: features: headers - - do: - cluster.health: - wait_for_status: yellow + - setup: + - do: + cluster.health: + wait_for_status: yellow + + - teardown: + - do: + xpack.security.delete_role: + name: "admin_role2" + ignore: 404 + + - do: + xpack.security.delete_user: + username: "joe" + ignore: 404 + + - do: + delete: + index: foo + type: doc + id: 1 + ignore: 404 - do: xpack.security.put_role: @@ -50,7 +69,6 @@ - match: { _index: foo } - match: { _type: doc } - match: { _id: "1"} - - match: { _version: 1} - match: { _source: { foo: bar }} # test that the role works on the cluster level