aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2018-09-26 11:58:30 +0100
committermark.j.leonard <mark.j.leonard@gmail.com>2018-09-26 12:02:22 +0100
commit392d41cdfc989d08cf5b79ea9a20e1f82665b447 (patch)
tree146df533a232f12705ef0c59ab1bd10cabdb7b9d /src/test/java/org
parentecd35f117eb0118f9cbd96fe132a1c359214bfc7 (diff)
Implement client authentication to ElasticSearch
Add configuration to the existing Elastic Search properties to allow Basic Authentication and/or TLS (SSL) connectivity using HTTPS. The new configuration is optional and this commit is intended to be backwards compatible with existing deployments. Change-Id: I19ec3da9ff810c3f6eabd6f5faf71adde182c861 Issue-ID: AAI-1650 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java b/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java
index 3cfb58a..1c75af2 100644
--- a/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java
+++ b/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpControllerTest.java
@@ -1,4 +1,4 @@
-/**
+/**
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
@@ -29,6 +29,7 @@ import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import java.util.Properties;
+import org.eclipse.jetty.util.security.Password;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Ignore;
@@ -62,6 +63,9 @@ public class ElasticSearchHttpControllerTest {
Properties properties = new Properties();
properties.put(ElasticSearchConfig.ES_IP_ADDRESS, "127.0.0.1");
properties.put(ElasticSearchConfig.ES_HTTP_PORT, "9200");
+ properties.put(ElasticSearchConfig.ES_URI_SCHEME, "http");
+ properties.put(ElasticSearchConfig.ES_AUTH_USER, "your_user_here");
+ properties.put(ElasticSearchConfig.ES_AUTH_ENC, Password.obfuscate("your_password_here"));
elasticSearch = new ElasticSearchHttpController(new ElasticSearchConfig(properties));
testDocument = new AAIEntityTestObject();
@@ -155,7 +159,12 @@ public class ElasticSearchHttpControllerTest {
@Test
public void testDeleteDocument() throws Exception {
- OperationResult result = elasticSearch.deleteDocument(TEST_INDEX_NAME, testDocument);
+ OperationResult result = elasticSearch.getDocument(TEST_INDEX_NAME, testDocument);
+ if (result.getResultCode() == 404) {
+ testCreateDocument();
+ }
+
+ result = elasticSearch.deleteDocument(TEST_INDEX_NAME, testDocument);
assertThat(result.getResult(), containsString(TEST_INDEX_NAME));
result = elasticSearch.getDocument(TEST_INDEX_NAME, testDocument);
@@ -173,8 +182,8 @@ public class ElasticSearchHttpControllerTest {
doc.setSearchTagIDs("" + i);
doc.setSearchTags("service-instance-id");
- // OperationResult result = elasticSearch.createDocument(TEST_INDEX_NAME, doc, false);
- // assertThat(result.getResultCode(), anyOf(equalTo(201), equalTo(400)));
+ OperationResult result = elasticSearch.createDocument(TEST_INDEX_NAME, doc, false);
+ assertThat(result.getResultCode(), anyOf(equalTo(201), equalTo(400)));
}
}