Skip to content

Commit

Permalink
Protect against random failures due to document count
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Oct 26, 2022
1 parent c937165 commit df79cef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void testDlsWithMinDocCountZeroAggregations() throws Exception {

// Significant Text Aggregation is not impacted.
// Non-admin user with setting "min_doc_count=0". Expected to only have access to buckets for dept_manager".
String query3 = "{\"aggregations\":{\"significant_termX\":{\"significant_terms\":{\"field\":\"termX.keyword\",\"min_doc_count\":0}}}}";
String query3 = "{\"size\":100,\"aggregations\":{\"significant_termX\":{\"significant_terms\":{\"field\":\"termX.keyword\",\"min_doc_count\":0}}}}";
HttpResponse response5 = rh.executePostRequest("logs*/_search", query3, encodeBasicHeader("dept_manager", "password"));

Assert.assertEquals(HttpStatus.SC_OK, response5.getStatusCode());
Expand All @@ -377,7 +377,7 @@ public void testDlsWithMinDocCountZeroAggregations() throws Exception {
Assert.assertFalse(response5.getBody(), response5.getBody().contains("\"termX\":\"E\""));

// Non-admin user without setting "min_doc_count". Expected to only have access to buckets for dept_manager".
String query4 = "{\"aggregations\":{\"significant_termX\":{\"significant_terms\":{\"field\":\"termX.keyword\"}}}}";
String query4 = "{\"size\":100,\"aggregations\":{\"significant_termX\":{\"significant_terms\":{\"field\":\"termX.keyword\"}}}}";

HttpResponse response6 = rh.executePostRequest("logs*/_search", query4, encodeBasicHeader("dept_manager", "password"));

Expand Down Expand Up @@ -410,7 +410,7 @@ public void testDlsWithMinDocCountZeroAggregations() throws Exception {

// Histogram Aggregation is not impacted.
// Non-admin user with setting "min_doc_count=0". Expected to only have access to buckets for dept_manager".
String query5 = "{\"aggs\":{\"amount\":{\"histogram\":{\"field\":\"amount\",\"interval\":1,\"min_doc_count\":0}}}}";
String query5 = "{\"size\":100,\"aggs\":{\"amount\":{\"histogram\":{\"field\":\"amount\",\"interval\":1,\"min_doc_count\":0}}}}";

HttpResponse response9 = rh.executePostRequest("logs*/_search", query5, encodeBasicHeader("dept_manager", "password"));

Expand All @@ -422,7 +422,7 @@ public void testDlsWithMinDocCountZeroAggregations() throws Exception {
Assert.assertFalse(response9.getBody(), response9.getBody().contains("\"termX\":\"E\""));

// Non-admin user without setting "min_doc_count". Expected to only have access to buckets for dept_manager".
String query6 = "{\"aggs\":{\"amount\":{\"histogram\":{\"field\":\"amount\",\"interval\":1}}}}";
String query6 = "{\"size\":100,\"aggs\":{\"amount\":{\"histogram\":{\"field\":\"amount\",\"interval\":1}}}}";

HttpResponse response10 = rh.executePostRequest("logs*/_search", query6, encodeBasicHeader("dept_manager", "password"));

Expand Down Expand Up @@ -456,7 +456,7 @@ public void testDlsWithMinDocCountZeroAggregations() throws Exception {

// Date Histogram Aggregation is not impacted.
// Non-admin user with setting "min_doc_count=0". Expected to only have access to buckets for dept_manager".
String query7 = "{\"aggs\":{\"timestamp\":{\"date_histogram\":{\"field\":\"timestamp\",\"calendar_interval\":\"month\",\"min_doc_count\":0}}}}";
String query7 = "{\"size\":100,\"aggs\":{\"timestamp\":{\"date_histogram\":{\"field\":\"timestamp\",\"calendar_interval\":\"month\",\"min_doc_count\":0}}}}";

HttpResponse response13 = rh.executePostRequest("logs*/_search", query7, encodeBasicHeader("dept_manager", "password"));

Expand All @@ -468,7 +468,7 @@ public void testDlsWithMinDocCountZeroAggregations() throws Exception {
Assert.assertFalse(response13.getBody(), response13.getBody().contains("\"termX\":\"E\""));

// Non-admin user without setting "min_doc_count". Expected to only have access to buckets for dept_manager".
String query8 = "{\"aggs\":{\"timestamp\":{\"date_histogram\":{\"field\":\"timestamp\",\"calendar_interval\":\"month\"}}}}";
String query8 = "{\"size\":100,\"aggs\":{\"timestamp\":{\"date_histogram\":{\"field\":\"timestamp\",\"calendar_interval\":\"month\"}}}}";

HttpResponse response14 = rh.executePostRequest("logs*/_search", query8, encodeBasicHeader("dept_manager", "password"));

Expand Down

0 comments on commit df79cef

Please sign in to comment.