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.
Signed-off-by: Vamsi Manohar <[email protected]>
- Loading branch information
1 parent
a816a58
commit 52a90aa
Showing
2 changed files
with
51 additions
and
4 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
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
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.junit.jupiter.api.Assertions; | ||
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 { | ||
// Assert default cursor settings | ||
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 actual = new JSONObject(TestUtils.getResponseBody(exception.getResponse())); | ||
JSONObject expected = | ||
new JSONObject("{\n" + | ||
" \"error\": {\n" + | ||
" \"root_cause\": [\n" + | ||
" {\n" + | ||
" \"type\": \"settings_exception\",\n" + | ||
" \"reason\": \"final persistent setting [plugins.query.datasources.encryption.masterkey], not updateable\"\n" + | ||
" }\n" + | ||
" ],\n" + | ||
" \"type\": \"settings_exception\",\n" + | ||
" \"reason\": \"final persistent setting [plugins.query.datasources.encryption.masterkey], not updateable\"\n" + | ||
" },\n" + | ||
" \"status\": 400\n" + | ||
"}"); | ||
Assertions.assertEquals(expected, actual); | ||
} | ||
|
||
} |