Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
Signed-off-by: cliu123 <lc12251109@gmail.com>
  • Loading branch information
cliu123 committed Mar 28, 2022
1 parent 024ae17 commit d3966e7
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ public void testCcs() throws Exception {
//Assert.assertTrue(ccs.getBody().contains("Can not filter indices; index cross_cluster_two:xx exists but there is also a remote cluster named: cross_cluster_two"));

System.out.println("###################### query 5");
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:abcnonext/xx/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:abcnonext/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_NOT_FOUND, ccs.getStatusCode());
Assert.assertTrue(ccs.getBody().contains("index_not_found_exception"));

System.out.println("###################### query 6");
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twutter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter,twutter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("nagilum","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode());
Assert.assertFalse(ccs.getBody().contains("security_exception"));
Expand Down Expand Up @@ -282,7 +282,7 @@ public void testCcsNonadmin() throws Exception {
Assert.assertTrue(ccs.getBody().contains("crl2_"));

System.out.println("###################### query 5");
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode());

Expand All @@ -291,7 +291,7 @@ public void testCcsNonadmin() throws Exception {
"{}"+System.lineSeparator()+
"{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator();

ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter,twitter/tweet/_msearch?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, msearchBody, encodeBasicHeader("twitter","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter,twitter/_msearch?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, msearchBody, encodeBasicHeader("twitter","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode());

Expand All @@ -300,7 +300,7 @@ public void testCcsNonadmin() throws Exception {
"{}"+System.lineSeparator()+
"{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator();

ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter/tweet/_msearch?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, msearchBody, encodeBasicHeader("twitter","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter/_msearch?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, msearchBody, encodeBasicHeader("twitter","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode());

Expand Down Expand Up @@ -452,7 +452,7 @@ public void testCcsNonadminDnfof() throws Exception {
Assert.assertTrue(ccs.getBody().contains("crl2_"));

System.out.println("###################### query 5");
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twutter,twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, ccs.getStatusCode());

Expand All @@ -461,7 +461,7 @@ public void testCcsNonadminDnfof() throws Exception {
"{}"+System.lineSeparator()+
"{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator();

ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter,twitter/tweet/_msearch?pretty", msearchBody, encodeBasicHeader("twitter","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter,twitter/_msearch?pretty", msearchBody, encodeBasicHeader("twitter","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode());

Expand All @@ -470,7 +470,7 @@ public void testCcsNonadminDnfof() throws Exception {
"{}"+System.lineSeparator()+
"{\"size\":10, \"query\":{\"bool\":{\"must\":{\"match_all\":{}}}}}"+System.lineSeparator();

ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter/tweet/_msearch?pretty", msearchBody, encodeBasicHeader("twitter","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executePostRequest("cross_cluster_two:twitter/_msearch?pretty", msearchBody, encodeBasicHeader("twitter","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode());

Expand Down Expand Up @@ -591,7 +591,7 @@ public void testCcsEmptyCoord() throws Exception {
HttpResponse ccs = null;

System.out.println("###################### query 1");
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/tweet/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum"));
ccs = new RestHelper(cl1Info, false, false, getResourceFolder()).executeGetRequest("cross_cluster_two:twitter/_search?pretty&ccs_minimize_roundtrips="+ccsMinimizeRoundtrips, encodeBasicHeader("twitter","nagilum"));
System.out.println(ccs.getBody());
Assert.assertEquals(HttpStatus.SC_OK, ccs.getStatusCode());
Assert.assertFalse(ccs.getBody().contains("security_exception"));
Expand Down Expand Up @@ -941,7 +941,7 @@ public void testCcsWithDiffCertsWithNoNodesDnUpdate() throws Exception {
setupCcs(new DynamicSecurityConfig(), cluster1, cluster2);
populateBaseData(cluster1, cluster2);

String uri = "cross_cluster_two:twitter/tweet/_search?pretty";
String uri = "cross_cluster_two:twitter/_search?pretty";
HttpResponse ccs = rh1.executeGetRequest(uri, encodeBasicHeader("twitter", "nagilum"));
System.out.println(ccs.getBody());
assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_INTERNAL_SERVER_ERROR));
Expand All @@ -963,7 +963,7 @@ public void testCcsWithDiffCertsWithNodesDnStaticallyAdded() throws Exception {
setupCcs(new DynamicSecurityConfig(), cluster1, cluster2);
populateBaseData(cluster1, cluster2);

String uri = "cross_cluster_two:twitter/tweet/_search?pretty";
String uri = "cross_cluster_two:twitter/_search?pretty";
HttpResponse ccs = rh1.executeGetRequest(uri, encodeBasicHeader("twitter", "nagilum"));
System.out.println(ccs.getBody());
assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_OK));
Expand All @@ -988,7 +988,7 @@ public void testCcsWithDiffCertsWithNodesDnDynamicallyAdded() throws Exception {

populateBaseData(cluster1, cluster2);

String uri = "cross_cluster_two:twitter/tweet/_search?pretty";
String uri = "cross_cluster_two:twitter/_search?pretty";
HttpResponse ccs = rh1.executeGetRequest(uri, encodeBasicHeader("twitter", "nagilum"));
System.out.println(ccs.getBody());
assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_OK));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void testCustomMaskedGet() throws Exception {

HttpResponse res;

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/deals/0?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_doc/0?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Assert.assertTrue(res.getBody().contains("\"found\" : true"));
Assert.assertTrue(res.getBody().contains("cust1"));
Assert.assertFalse(res.getBody().contains("cust2"));
Expand All @@ -220,7 +220,7 @@ public void testCustomMaskedGet() throws Exception {
Assert.assertFalse(res.getBody().contains("XXX"));


Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/deals/0?pretty", encodeBasicHeader("user_masked_custom", "password"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_doc/0?pretty", encodeBasicHeader("user_masked_custom", "password"))).getStatusCode());
Assert.assertTrue(res.getBody().contains("\"found\" : true"));
Assert.assertFalse(res.getBody().contains("cust1"));
Assert.assertFalse(res.getBody().contains("cust2"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testSearch() throws Exception {

HttpResponse res;

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));
Expand All @@ -68,7 +68,7 @@ public void testSearch() throws Exception {
Assert.assertTrue(res.getBody().contains("mymsg"));
Assert.assertTrue(res.getBody().contains("msgid"));

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/logs/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("%3Clogstash-%7Bnow%2Fd%7D%3E/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));
Expand Down Expand Up @@ -105,7 +105,7 @@ public void testSearchWc() throws Exception {

HttpResponse res;

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-*/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-*/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));
Expand All @@ -114,7 +114,7 @@ public void testSearchWc() throws Exception {
Assert.assertTrue(res.getBody().contains("mymsg"));
Assert.assertTrue(res.getBody().contains("msgid"));

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-*/logs/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-*/_search?pretty", encodeBasicHeader("opendistro_security_logstash", "password"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));
Expand All @@ -131,7 +131,7 @@ public void testSearchWc2() throws Exception {

HttpResponse res;

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-1-*,logstash-20*/logs/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-1-*,logstash-20*/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 4,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));
Expand All @@ -140,7 +140,7 @@ public void testSearchWc2() throws Exception {
Assert.assertTrue(res.getBody().contains("mymsg"));
Assert.assertTrue(res.getBody().contains("msgid"));

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-1-*,logstash-20*/logs/_search?pretty", encodeBasicHeader("regex", "password"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("logstash-1-*,logstash-20*/_search?pretty", encodeBasicHeader("regex", "password"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public void testNestedQuery() throws Exception {


HttpResponse res;
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/deals/mytype/_search?pretty", query, encodeBasicHeader("dept_manager", "password"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/deals/_search?pretty", query, encodeBasicHeader("dept_manager", "password"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"my_nested_object\" : {"));
Assert.assertTrue(res.getBody().contains("\"field\" : \"my_nested_object\","));
Assert.assertTrue(res.getBody().contains("\"offset\" : 0"));

//Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/deals/mytype/_search?pretty", query, encodeBasicHeader("admin", "admin"))).getStatusCode());
//Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("/deals/_search?pretty", query, encodeBasicHeader("admin", "admin"))).getStatusCode());
//System.out.println(res.getBody());
//Assert.assertTrue(res.getBody().contains("\"value\" : 2,\n \"relation"));
//Assert.assertTrue(res.getBody().contains("\"value\" : 1510.0"));
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/opensearch/security/dlic/dlsfls/DlsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public void testDlsTermVectors() throws Exception {
setup();

HttpResponse res;
res = rh.executeGetRequest("/deals/deals/0/_termvectors?pretty=true", encodeBasicHeader("dept_manager", "password"));
res = rh.executeGetRequest("/deals/_doc/0/_termvectors?pretty=true", encodeBasicHeader("dept_manager", "password"));
Assert.assertTrue(res.getBody().contains("\"found\" : false"));

res = rh.executeGetRequest("/deals/deals/0/_termvectors?pretty=true", encodeBasicHeader("admin", "admin"));
res = rh.executeGetRequest("/deals/_doc/0/_termvectors?pretty=true", encodeBasicHeader("admin", "admin"));
Assert.assertTrue(res.getBody().contains("\"found\" : true"));
}

Expand Down Expand Up @@ -160,13 +160,13 @@ public void testDls() throws Exception {
Assert.assertTrue(res.getBody().contains("\"value\" : 0,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));

res = rh.executeGetRequest("/deals/deals/0?pretty", encodeBasicHeader("dept_manager", "password"));
res = rh.executeGetRequest("/deals/_doc/0?pretty", encodeBasicHeader("dept_manager", "password"));
Assert.assertTrue(res.getBody().contains("\"found\" : false"));

res = rh.executeGetRequest("/deals/deals/0?realtime=true&pretty", encodeBasicHeader("dept_manager", "password"));
res = rh.executeGetRequest("/deals/_doc/0?realtime=true&pretty", encodeBasicHeader("dept_manager", "password"));
Assert.assertTrue(res.getBody().contains("\"found\" : false"));

res = rh.executeGetRequest("/deals/deals/1?pretty", encodeBasicHeader("dept_manager", "password"));
res = rh.executeGetRequest("/deals/_doc/1?pretty", encodeBasicHeader("dept_manager", "password"));
Assert.assertTrue(res.getBody().contains("\"found\" : true"));

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_count?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Expand Down Expand Up @@ -261,10 +261,10 @@ public void testDlsCache() throws Exception {
Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation"));
Assert.assertTrue(res.getBody().contains("\"failed\" : 0"));

res = rh.executeGetRequest("/deals/deals/0?pretty", encodeBasicHeader("admin", "admin"));
res = rh.executeGetRequest("/deals/_doc/0?pretty", encodeBasicHeader("admin", "admin"));
Assert.assertTrue(res.getBody().contains("\"found\" : true"));

res = rh.executeGetRequest("/deals/deals/0?pretty", encodeBasicHeader("dept_manager", "password"));
res = rh.executeGetRequest("/deals/_doc/0?pretty", encodeBasicHeader("dept_manager", "password"));
Assert.assertTrue(res.getBody().contains("\"found\" : false"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void testMaskedGet() throws Exception {

HttpResponse res;

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/deals/0?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_doc/0?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
Assert.assertTrue(res.getBody().contains("\"found\" : true"));
Assert.assertTrue(res.getBody().contains("cust1"));
Assert.assertFalse(res.getBody().contains("cust2"));
Expand All @@ -196,7 +196,7 @@ public void testMaskedGet() throws Exception {
Assert.assertFalse(res.getBody().contains("87873bdb698e5f0f60e0b02b76dad1ec11b2787c628edbc95b7ff0e82274b140"));


Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/deals/0?pretty", encodeBasicHeader("user_masked", "password"))).getStatusCode());
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_doc/0?pretty", encodeBasicHeader("user_masked", "password"))).getStatusCode());
Assert.assertTrue(res.getBody().contains("\"found\" : true"));
Assert.assertTrue(res.getBody().contains("cust1"));
Assert.assertFalse(res.getBody().contains("cust2"));
Expand Down
Loading

0 comments on commit d3966e7

Please sign in to comment.