forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 2.x] Filter datasource encryption master key from cluster s…
…ettings GET API (opensearch-project#1828) (opensearch-project#1844) * Restrict master key reading from cluster settings API (opensearch-project#1825) Signed-off-by: Vamsi Manohar <reddyvam@amazon.com> (cherry picked from commit a8ecd2f) * Fxied DatasourceClusterSettingsIT for 2.x Signed-off-by: Vamsi Manohar <reddyvam@amazon.com> --------- Signed-off-by: Vamsi Manohar <reddyvam@amazon.com> Co-authored-by: Vamsi Manohar <reddyvam@amazon.com> (cherry picked from commit 98ca9f8) Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
748fc65
commit ce9d4ba
Showing
3 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
integ-test/src/test/java/org/opensearch/sql/datasource/DatasourceClusterSettingsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.datasource; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import java.io.IOException; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
import org.opensearch.client.ResponseException; | ||
import org.opensearch.sql.legacy.TestUtils; | ||
import org.opensearch.sql.ppl.PPLIntegTestCase; | ||
|
||
public class DatasourceClusterSettingsIT extends PPLIntegTestCase { | ||
|
||
private static final Logger LOG = LogManager.getLogger(); | ||
@Test | ||
public void testGetDatasourceClusterSettings() throws IOException { | ||
JSONObject clusterSettings = getAllClusterSettings(); | ||
assertThat(clusterSettings.query("/defaults/plugins.query.datasources.encryption.masterkey"), | ||
equalTo(null)); | ||
} | ||
|
||
|
||
@Test | ||
public void testPutDatasourceClusterSettings() throws IOException { | ||
final ResponseException exception = | ||
expectThrows(ResponseException.class, () -> updateClusterSettings(new ClusterSetting(PERSISTENT, | ||
"plugins.query.datasources.encryption.masterkey", | ||
"masterkey"))); | ||
JSONObject resp = new JSONObject(TestUtils.getResponseBody(exception.getResponse())); | ||
assertThat(resp.getInt("status"), equalTo(400)); | ||
assertThat(resp.query("/error/root_cause/0/reason"), | ||
equalTo("final persistent setting [plugins.query.datasources.encryption.masterkey], not updateable")); | ||
assertThat(resp.query("/error/type"), equalTo("illegal_argument_exception")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters