Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
hsiang9431-amzn committed Jul 13, 2021
1 parent e813426 commit 6567bc3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/test/java/org/opensearch/security/AggregationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,44 @@ public void testBasicAggregations() throws Exception {
assertContains(res, "*\"failed\" : 0*");

Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePostRequest("_search?pretty", "{\"size\":0,\"aggs\":{\"myindices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("worf", "worf"))).getStatusCode());


// _resolve api is for replacing same filtering functionality
// reuse previous tests for checking if it works properly
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_resolve/index/*?pretty", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
System.out.println(res.getBody());
assertNotContains(res, "*xception*");
assertNotContains(res, "*erial*");
assertNotContains(res, "*mpty*");
assertNotContains(res, "*pendistro_security*");
assertContains(res, "*vulcangov*");
assertContains(res, "*starfleet*");
assertContains(res, "*klingonempire*");
assertContains(res, "*xyz*");
assertContains(res, "*role01_role02*");

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_resolve/index/*?pretty",encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
System.out.println(res.getBody());
assertNotContains(res, "*xception*");
assertNotContains(res, "*erial*");
assertNotContains(res, "*mpty*");
assertNotContains(res, "*pendistro_security*");
assertContains(res, "*vulcangov*");
assertContains(res, "*starfleet*");
assertContains(res, "*klingonempire*");
assertContains(res, "*xyz*");
assertContains(res, "*role01_role02*");

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("_resolve/index/*?pretty",encodeBasicHeader("worf", "worf"))).getStatusCode());
System.out.println(res.getBody());
assertNotContains(res, "*xception*");
assertNotContains(res, "*erial*");
assertNotContains(res, "*mpty*");
assertNotContains(res, "*pendistro_security*");
assertNotContains(res, "*vulcangov*");
assertNotContains(res, "*kirk*");
assertContains(res, "*starfleet*");
assertContains(res, "*public*");
assertContains(res, "*xyz*");
}

}
2 changes: 2 additions & 0 deletions src/test/resources/action_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ OPENDISTRO_SECURITY_READ:
hidden: false
allowed_actions:
- "indices:data/read*"
- "indices:admin/resolve/index"
type: "index"
description: "Migrated from v6"
OPENDISTRO_SECURITY_DELETE:
Expand Down Expand Up @@ -113,6 +114,7 @@ OPENDISTRO_SECURITY_GET:
allowed_actions:
- "indices:data/read/get*"
- "indices:data/read/mget*"
- "indices:admin/resolve/index"
type: "index"
description: "Migrated from v6"
OPENDISTRO_SECURITY_MANAGE:
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/action_groups_packaged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ OPENDISTRO_SECURITY_READ:
allowed_actions:
- "indices:data/read*"
- "indices:admin/mappings/fields/get*"
- "indices:admin/resolve/index"
type: "index"
description: "Migrated from v6"
OPENDISTRO_SECURITY_INDICES_ALL:
Expand Down

0 comments on commit 6567bc3

Please sign in to comment.