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.
Restrict master key reading from cluster settings API (opensearch-pro…
…ject#1825) Signed-off-by: Vamsi Manohar <[email protected]>
- Loading branch information
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("settings_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