Skip to content

Commit

Permalink
Added IT
Browse files Browse the repository at this point in the history
Signed-off-by: Vamsi Manohar <[email protected]>
  • Loading branch information
vamsi-amazon committed Jul 10, 2023
1 parent a816a58 commit 52a90aa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
import java.util.ArrayList;
import java.util.List;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opensearch.action.update.UpdateRequest;
import org.opensearch.client.Request;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
import org.opensearch.sql.datasource.model.DataSourceMetadata;
Expand Down
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);
}

}

0 comments on commit 52a90aa

Please sign in to comment.