Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix IllegalArgumentException when resolved indices are empty in PrivilegesEvaluator ([#5770](https://github.com/opensearch-project/security/pull/5797))
- Fixes an issue where recursive LDAP role search would fail with a NullPointerException ([#5861](https://github.com/opensearch-project/security/pull/5861))
- Skip hasExplicitIndexPrivilege check for plugin users accessing their own system indices ([#5858](https://github.com/opensearch-project/security/pull/5858))
- Fix test failure related to change in core to add content-encoding to response headers ([#5897](https://github.com/opensearch-project/security/pull/5897))

### Refactoring

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,57 +91,41 @@ public void testCcs() throws Exception {
tc.index(
new IndexRequest("twitter").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source("{\"cluster\": \"" + cl1Info.clustername + "\"}", XContentType.JSON)
.source("{\"cluster\": \"%s\"}".formatted(cl1Info.clustername), XContentType.JSON)
).actionGet();
}

try (Client tc = cl2.nodeClient()) {
tc.index(
new IndexRequest("twutter").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source("{\"cluster\": \"" + cl2Info.clustername + "\"}", XContentType.JSON)
).actionGet();
tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source(
"{\"cluster\": \""
+ cl2Info.clustername
+ "\","
+ "\"Designation\": \"CEO\","
+ "\"FirstName\": \"__fn__"
+ cl2Info.clustername
+ "\","
+ "\"LastName\": \"lastname0\","
+ "\"Salary\": \"salary0\","
+ "\"SecretFiled\": \"secret0\","
+ "\"AnotherSecredField\": \"anothersecret0\","
+ "\"XXX\": \"xxx0\""
+ "}",
XContentType.JSON
)
).actionGet();

tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("1")
.source(
"{\"cluster\": \""
+ cl2Info.clustername
+ "\","
+ "\"Designation\": \"someoneelse\","
+ "\"FirstName\": \"__fn__"
+ cl2Info.clustername
+ "\","
+ "\"LastName\": \"lastname1\","
+ "\"Salary\": \"salary1\","
+ "\"SecretFiled\": \"secret1\","
+ "\"AnotherSecredField\": \"anothersecret1\","
+ "\"XXX\": \"xxx1\""
+ "}",
XContentType.JSON
)
.source("{\"cluster\": \"%s\"}".formatted(cl2Info.clustername), XContentType.JSON)
).actionGet();
tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("0").source("""
{
"cluster": "%s",
"Designation": "CEO",
"FirstName": "__fn__%s",
"LastName": "lastname0",
"Salary": "salary0",
"SecretFiled": "secret0",
"AnotherSecredField": "anothersecret0",
"XXX": "xxx0"
}
""".formatted(cl2Info.clustername, cl2Info.clustername), XContentType.JSON)).actionGet();

tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("1").source("""
{
"cluster": "%s",
"Designation": "someoneelse",
"FirstName": "__fn__%s",
"LastName": "lastname1",
"Salary": "salary1",
"SecretFiled": "secret1",
"AnotherSecredField": "anothersecret1",
"XXX": "xxx1"
}
""".formatted(cl2Info.clustername, cl2Info.clustername), XContentType.JSON)).actionGet();

}

Expand All @@ -167,7 +151,7 @@ public void testCcs() throws Exception {
Assert.assertFalse(body.contains("secret1"));
Assert.assertFalse(body.contains("AnotherSecredField"));
Assert.assertFalse(body.contains("xxx1"));
assertThat(ccs.getHeaders().toString(), ccs.getHeaders().size(), is(3));
assertThat(ccs.getHeaders().toString(), ccs.getHeaders().size(), is(4));
}

@Test
Expand All @@ -178,57 +162,41 @@ public void testCcsDifferentConfig() throws Exception {
tc.index(
new IndexRequest("twitter").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source("{\"cluster\": \"" + cl1Info.clustername + "\"}", XContentType.JSON)
.source("{\"cluster\": \"%s\"}".formatted(cl1Info.clustername), XContentType.JSON)
).actionGet();
}

try (Client tc = cl2.nodeClient()) {
tc.index(
new IndexRequest("twutter").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source("{\"cluster\": \"" + cl2Info.clustername + "\"}", XContentType.JSON)
).actionGet();
tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source(
"{\"cluster\": \""
+ cl2Info.clustername
+ "\","
+ "\"Designation\": \"CEO\","
+ "\"FirstName\": \"__fn__"
+ cl2Info.clustername
+ "\","
+ "\"LastName\": \"lastname0\","
+ "\"Salary\": \"salary0\","
+ "\"SecretFiled\": \"secret0\","
+ "\"AnotherSecredField\": \"anothersecret0\","
+ "\"XXX\": \"xxx0\""
+ "}",
XContentType.JSON
)
).actionGet();

tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("1")
.source(
"{\"cluster\": \""
+ cl2Info.clustername
+ "\","
+ "\"Designation\": \"someoneelse\","
+ "\"FirstName\": \"__fn__"
+ cl2Info.clustername
+ "\","
+ "\"LastName\": \"lastname1\","
+ "\"Salary\": \"salary1\","
+ "\"SecretFiled\": \"secret1\","
+ "\"AnotherSecredField\": \"anothersecret1\","
+ "\"XXX\": \"xxx1\""
+ "}",
XContentType.JSON
)
.source("{\"cluster\": \"%s\"}".formatted(cl2Info.clustername), XContentType.JSON)
).actionGet();
tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("0").source("""
{
"cluster": "%s",
"Designation": "CEO",
"FirstName": "__fn__%s",
"LastName": "lastname0",
"Salary": "salary0",
"SecretFiled": "secret0",
"AnotherSecredField": "anothersecret0",
"XXX": "xxx0"
}
""".formatted(cl2Info.clustername, cl2Info.clustername), XContentType.JSON)).actionGet();

tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("1").source("""
{
"cluster": "%s",
"Designation": "someoneelse",
"FirstName": "__fn__%s",
"LastName": "lastname1",
"Salary": "salary1",
"SecretFiled": "secret1",
"AnotherSecredField": "anothersecret1",
"XXX": "xxx1"
}
""".formatted(cl2Info.clustername, cl2Info.clustername), XContentType.JSON)).actionGet();

}

Expand All @@ -253,7 +221,7 @@ public void testCcsDifferentConfig() throws Exception {
Assert.assertTrue(ccs.getBody().contains("__fn__crl2"));
Assert.assertFalse(ccs.getBody().contains("secret1"));
Assert.assertFalse(ccs.getBody().contains("AnotherSecredField"));
assertThat(ccs.getHeaders().toString(), ccs.getHeaders().size(), is(3));
assertThat(ccs.getHeaders().toString(), ccs.getHeaders().size(), is(4));
}

@Test
Expand All @@ -264,99 +232,67 @@ public void testCcsDifferentConfigBoth() throws Exception {
tc.index(
new IndexRequest("twitter").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source("{\"cluster\": \"" + cl1Info.clustername + "\"}", XContentType.JSON)
.source("{\"cluster\": \"%s\"}".formatted(cl1Info.clustername), XContentType.JSON)
).actionGet();

tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source(
"{\"cluster\": \""
+ cl1Info.clustername
+ "\","
+ "\"Designation\": \"CEO\","
+ "\"FirstName\": \"__fn__"
+ cl1Info.clustername
+ "\","
+ "\"LastName\": \"lastname0\","
+ "\"Salary\": \"salary0\","
+ "\"SecretFiled\": \"secret3\","
+ "\"AnotherSecredField\": \"anothersecret3\","
+ "\"XXX\": \"xxx0\""
+ "}",
XContentType.JSON
)
).actionGet();

tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("1")
.source(
"{\"cluster\": \""
+ cl1Info.clustername
+ "\","
+ "\"Designation\": \"someoneelse\","
+ "\"FirstName\": \"__fn__"
+ cl1Info.clustername
+ "\","
+ "\"LastName\": \"lastname1\","
+ "\"Salary\": \"salary1\","
+ "\"SecretFiled\": \"secret4\","
+ "\"AnotherSecredField\": \"anothersecret4\","
+ "\"XXX\": \"xxx1\""
+ "}",
XContentType.JSON
)
).actionGet();
tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("0").source("""
{
"cluster": "%s",
"Designation": "CEO",
"FirstName": "__fn__%s",
"LastName": "lastname0",
"Salary": "salary0",
"SecretFiled": "secret3",
"AnotherSecredField": "anothersecret3",
"XXX": "xxx0"
}
""".formatted(cl1Info.clustername, cl1Info.clustername), XContentType.JSON)).actionGet();

tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("1").source("""
{
"cluster": "%s",
"Designation": "someoneelse",
"FirstName": "__fn__%s",
"LastName": "lastname1",
"Salary": "salary1",
"SecretFiled": "secret4",
"AnotherSecredField": "anothersecret4",
"XXX": "xxx1"
}
""".formatted(cl1Info.clustername, cl1Info.clustername), XContentType.JSON)).actionGet();
}

try (Client tc = cl2.nodeClient()) {
tc.index(
new IndexRequest("twutter").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source("{\"cluster\": \"" + cl2Info.clustername + "\"}", XContentType.JSON)
).actionGet();
tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("0")
.source(
"{\"cluster\": \""
+ cl2Info.clustername
+ "\","
+ "\"Designation\": \"CEO\","
+ "\"FirstName\": \"__fn__"
+ cl2Info.clustername
+ "\","
+ "\"LastName\": \"lastname0\","
+ "\"Salary\": \"salary0\","
+ "\"SecretFiled\": \"secret0\","
+ "\"AnotherSecredField\": \"anothersecret0\","
+ "\"XXX\": \"xxx0\""
+ "}",
XContentType.JSON
)
).actionGet();

tc.index(
new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE)
.id("1")
.source(
"{\"cluster\": \""
+ cl2Info.clustername
+ "\","
+ "\"Designation\": \"someoneelse\","
+ "\"FirstName\": \"__fn__"
+ cl2Info.clustername
+ "\","
+ "\"LastName\": \"lastname1\","
+ "\"Salary\": \"salary1\","
+ "\"SecretFiled\": \"secret1\","
+ "\"AnotherSecredField\": \"anothersecret1\","
+ "\"XXX\": \"xxx1\""
+ "}",
XContentType.JSON
)
.source("{\"cluster\": \"%s\"}".formatted(cl2Info.clustername), XContentType.JSON)
).actionGet();
tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("0").source("""
{
"cluster": "%s",
"Designation": "CEO",
"FirstName": "__fn__%s",
"LastName": "lastname0",
"Salary": "salary0",
"SecretFiled": "secret0",
"AnotherSecredField": "anothersecret0",
"XXX": "xxx0"
}
""".formatted(cl2Info.clustername, cl2Info.clustername), XContentType.JSON)).actionGet();

tc.index(new IndexRequest("humanresources").setRefreshPolicy(RefreshPolicy.IMMEDIATE).id("1").source("""
{
"cluster": "%s",
"Designation": "someoneelse",
"FirstName": "__fn__%s",
"LastName": "lastname1",
"Salary": "salary1",
"SecretFiled": "secret1",
"AnotherSecredField": "anothersecret1",
"XXX": "xxx1"
}
""".formatted(cl2Info.clustername, cl2Info.clustername), XContentType.JSON)).actionGet();

}

Expand All @@ -383,6 +319,6 @@ public void testCcsDifferentConfigBoth() throws Exception {
Assert.assertFalse(ccs.getBody().contains("secret1"));
Assert.assertFalse(ccs.getBody().contains("AnotherSecredField"));
Assert.assertTrue(ccs.getBody().contains("someoneelse"));
assertThat(ccs.getHeaders().toString(), ccs.getHeaders().size(), is(3));
assertThat(ccs.getHeaders().toString(), ccs.getHeaders().size(), is(4));
}
}
Loading
Loading