From 740ad7b52e7f06ed4b93f235c9ecf1a496b4b996 Mon Sep 17 00:00:00 2001 From: Nikola Grcevski Date: Wed, 9 Mar 2022 13:16:43 -0500 Subject: [PATCH] Revert test workaround for #82837 --- .../xpack/restart/FullClusterRestartIT.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 25b76dda77a93..3059e788c1804 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -412,17 +412,12 @@ public void testApiKeySuperuser() throws IOException { // read is ok final Request searchRequest = new Request("GET", ".security/_search"); - // TODO: change the warning expectation to be always once #82837 is fixed - // Configure the warning to be optional due to #82837, it is ok since this test is for something else - searchRequest.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(warnings -> { - if (warnings.isEmpty()) { - return false; - } else if (warnings.size() == 1) { - return false == warnings.get(0).startsWith("this request accesses system indices: [.security-7]"); - } else { - return true; - } - }).addHeader("Authorization", apiKeyAuthHeader)); + searchRequest.setOptions( + expectWarnings( + "this request accesses system indices: [.security-7], but in a future major " + + "version, direct access to system indices will be prevented by default" + ).toBuilder().addHeader("Authorization", apiKeyAuthHeader) + ); assertOK(client().performRequest(searchRequest)); // write must not be allowed @@ -431,7 +426,12 @@ public void testApiKeySuperuser() throws IOException { { "doc_type": "foo" }"""); - indexRequest.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("Authorization", apiKeyAuthHeader)); + indexRequest.setOptions( + expectWarnings( + "this request accesses system indices: [.security-7], but in a future major " + + "version, direct access to system indices will be prevented by default" + ).toBuilder().addHeader("Authorization", apiKeyAuthHeader) + ); final ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(indexRequest)); assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(403)); assertThat(e.getMessage(), containsString("is unauthorized"));