Skip to content

Commit 79a9669

Browse files
committed
Fix failing test
1 parent ec7f125 commit 79a9669

File tree

1 file changed

+10
-6
lines changed
  • x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql

1 file changed

+10
-6
lines changed

x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -781,19 +781,23 @@ public void testListQueryForbidden() throws Exception {
781781

782782
public void testGetQueryAllowed() throws Exception {
783783
// This is a bit tricky, since there is no such running query. We just make sure it didn't fail on forbidden privileges.
784-
Request request = new Request("GET", "_query/queries/foo:1234");
785-
var resp = expectThrows(ResponseException.class, () -> client().performRequest(request));
786-
assertThat(resp.getResponse().getStatusLine().getStatusCode(), not(equalTo(404)));
784+
setUser(GET_QUERY_REQUEST, "user_with_monitor_privileges");
785+
var resp = expectThrows(ResponseException.class, () -> client().performRequest(GET_QUERY_REQUEST));
786+
assertThat(resp.getResponse().getStatusLine().getStatusCode(), not(equalTo(403)));
787787
}
788788

789789
public void testGetQueryForbidden() throws Exception {
790-
Request request = new Request("GET", "_query/queries/foo:1234");
791-
setUser(request, "user_without_monitor_privileges");
792-
var resp = expectThrows(ResponseException.class, () -> client().performRequest(request));
790+
setUser(GET_QUERY_REQUEST, "user_without_monitor_privileges");
791+
var resp = expectThrows(ResponseException.class, () -> client().performRequest(GET_QUERY_REQUEST));
793792
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(403));
794793
assertThat(resp.getMessage(), containsString("this action is granted by the cluster privileges [monitor_esql,monitor,manage,all]"));
795794
}
796795

796+
private static final Request GET_QUERY_REQUEST = new Request(
797+
"GET",
798+
"_query/queries/FmJKWHpFRi1OU0l5SU1YcnpuWWhoUWcZWDFuYUJBeW1TY0dKM3otWUs2bDJudzo1Mg=="
799+
);
800+
797801
private void createEnrichPolicy() throws Exception {
798802
createIndex("songs", Settings.EMPTY, """
799803
"properties":{"song_id": {"type": "keyword"}, "title": {"type": "keyword"}, "artist": {"type": "keyword"} }

0 commit comments

Comments
 (0)