Skip to content

Commit 94720bb

Browse files
authored
ESQL: Add more LOOKUP JOIN cases to EsqlSecurityIT (#120477)
1 parent 1b1296e commit 94720bb

File tree

1 file changed

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

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,16 @@ public void testLookupJoinIndexForbidden() throws Exception {
597597
assertThat(resp.getMessage(), containsString("Unknown index [lookup-user1]"));
598598
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
599599

600+
resp = expectThrows(
601+
ResponseException.class,
602+
() -> runESQLCommand(
603+
"metadata1_read2",
604+
"FROM lookup-user2 | EVAL value = 10.0 | LOOKUP JOIN `lookup-first-alias` ON value | KEEP x"
605+
)
606+
);
607+
assertThat(resp.getMessage(), containsString("Unknown index [lookup-first-alias]"));
608+
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
609+
600610
resp = expectThrows(
601611
ResponseException.class,
602612
() -> runESQLCommand("metadata1_read2", "ROW x = 10.0 | EVAL value = x | LOOKUP JOIN `lookup-user1` ON value | KEEP x")
@@ -612,6 +622,20 @@ public void testLookupJoinIndexForbidden() throws Exception {
612622
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
613623
}
614624

625+
public void testFromLookupIndexForbidden() throws Exception {
626+
var resp = expectThrows(ResponseException.class, () -> runESQLCommand("metadata1_read2", "FROM lookup-user1"));
627+
assertThat(resp.getMessage(), containsString("Unknown index [lookup-user1]"));
628+
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
629+
630+
resp = expectThrows(ResponseException.class, () -> runESQLCommand("metadata1_read2", "FROM lookup-first-alias"));
631+
assertThat(resp.getMessage(), containsString("Unknown index [lookup-first-alias]"));
632+
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
633+
634+
resp = expectThrows(ResponseException.class, () -> runESQLCommand("alias_user1", "FROM lookup-user1"));
635+
assertThat(resp.getMessage(), containsString("Unknown index [lookup-user1]"));
636+
assertThat(resp.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
637+
}
638+
615639
private void createEnrichPolicy() throws Exception {
616640
createIndex("songs", Settings.EMPTY, """
617641
"properties":{"song_id": {"type": "keyword"}, "title": {"type": "keyword"}, "artist": {"type": "keyword"} }

0 commit comments

Comments
 (0)