Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Caitlin Harper <caitlin.harper@defence.gov.au>
  • Loading branch information
ch-govau committed Feb 22, 2022
1 parent eb43a0d commit 132369f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ protected void populateData(TransportClient tc) {
.source("{\"role\": \"prole2\", \"amount\": 4040}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("prop2").type("_doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.source("{\"role\": \"prole3\", \"amount\": 5050}", XContentType.JSON)).actionGet();

tc.index(new IndexRequest("prop-mapped").type("_doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.source("{\"securityRole\": \"opendistro_security_mapped\", \"amount\": 6060}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("prop-mapped").type("_doc").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.source("{\"securityRole\": \"not_assigned\", \"amount\": 7070}", XContentType.JSON)).actionGet();
}


Expand All @@ -58,5 +61,9 @@ public void testDlsProps() throws Exception {
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/prop1,prop2/_search?pretty&size=100", encodeBasicHeader("prop_replace", "password"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 3,\n \"relation"));

Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/prop-mapped/_search?pretty&size=100", encodeBasicHeader("prop_replace", "password"))).getStatusCode());
System.out.println(res.getBody());
Assert.assertTrue(res.getBody().contains("\"value\" : 1,\n \"relation"));
}
}
1 change: 1 addition & 0 deletions src/test/resources/dlsfls/internal_users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ prop_replace:
backend_roles:
- "prole1"
- "prole2"
- "prolemapped"
attributes: {}
description: "Migrated from v6"
user_masked_custom:
Expand Down
7 changes: 7 additions & 0 deletions src/test/resources/dlsfls/roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,13 @@ opendistro_security_prop_replace:
masked_fields: null
allowed_actions:
- "OPENDISTRO_SECURITY_READ"
- index_patterns:
- "prop-mapped"
dls: "{\"terms\" : { \"securityRole\" : [${user.securityRoles}]}}"
fls: null
masked_fields: null
allowed_actions:
- "OPENDISTRO_SECURITY_READ"
tenant_permissions: []
opendistro_security_logstash:
reserved: false
Expand Down
9 changes: 9 additions & 0 deletions src/test/resources/dlsfls/roles_mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,12 @@ opendistro_security_date_math:
opendistro_security_fls_exists:
users:
- fls_exists
opendistro_security_mapped:
reserved: false
hidden: false
backend_roles:
- prolemapped
hosts: []
users: []
and_backend_roles: []
description: "Security role mapping to backend role prolemapped"

0 comments on commit 132369f

Please sign in to comment.