Skip to content

Commit 08d3c20

Browse files
committed
fix security IT
Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent d289025 commit 08d3c20

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/security/CalciteCrossClusterSearchIT.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.io.IOException;
1717
import java.util.Locale;
1818
import org.apache.commons.text.StringEscapeUtils;
19+
import org.json.JSONArray;
1920
import org.json.JSONObject;
2021
import org.junit.Assert;
2122
import org.junit.Test;
@@ -485,10 +486,18 @@ public void testCrossClusterHighlightWildcard() throws IOException {
485486
String.format(
486487
"search source=%s \\\"Hattie\\\" | fields firstname", TEST_INDEX_BANK_REMOTE),
487488
"[\"*\"]");
488-
verifySchema(result, schema("firstname", "string"));
489-
verifyDataRows(result, rows("Hattie"));
490-
var highlights = result.getJSONArray("highlights");
491-
var highlight = highlights.getJSONObject(0);
489+
JSONArray schemaArray = result.getJSONArray("schema");
490+
int hlIndex = -1;
491+
for (int i = 0; i < schemaArray.length(); i++) {
492+
if ("_highlight".equals(schemaArray.getJSONObject(i).getString("name"))) {
493+
hlIndex = i;
494+
break;
495+
}
496+
}
497+
Assert.assertTrue("Schema should contain _highlight column", hlIndex >= 0);
498+
JSONArray dataRows = result.getJSONArray("datarows");
499+
Assert.assertTrue("Should have at least one row", dataRows.length() > 0);
500+
var highlight = dataRows.getJSONArray(0).getJSONObject(hlIndex);
492501
Assert.assertTrue(
493502
"Highlight should contain <em>Hattie</em>",
494503
highlight.getJSONArray("firstname").getString(0).contains("<em>Hattie</em>"));

0 commit comments

Comments
 (0)