summaryrefslogtreecommitdiffstats
path: root/rest-services
diff options
context:
space:
mode:
authorTomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>2021-05-06 10:27:19 +0200
committerTomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>2021-05-18 09:23:13 +0200
commit9779ca13ed180fc69cdad5336b30a26edfd7d0fa (patch)
tree76bde46fd31315a1728d91670743552d3121e332 /rest-services
parent100e06241c0bce987b53ebe03b103eb19d282a81 (diff)
Add to Java CBS-Client ability to resolve evns in app-config.yaml loaded from ConfigMap
Change-Id: Ic85c1511133594500bdf31b9d491cc70d34ff5d5 Issue-ID: DCAEGEN2-2716 Signed-off-by: Tomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>
Diffstat (limited to 'rest-services')
-rw-r--r--rest-services/cbs-client/pom.xml2
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/exceptions/EnvironmentParsingException.java28
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMap.java4
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsing.java103
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientRest.java1
-rw-r--r--rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java23
-rw-r--r--rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsingTest.java57
-rw-r--r--rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImplIT.java45
-rw-r--r--rest-services/cbs-client/src/test/resources/application_config.yaml36
-rw-r--r--rest-services/cbs-client/src/test/resources/sample_expected_service_config.json53
-rw-r--r--rest-services/cbs-client/src/test/resources/sample_service_config.json16
-rw-r--r--rest-services/dmaap-client/pom.xml2
-rw-r--r--rest-services/http-client/pom.xml2
-rw-r--r--rest-services/model/pom.xml2
-rw-r--r--rest-services/pom.xml2
15 files changed, 356 insertions, 20 deletions
diff --git a/rest-services/cbs-client/pom.xml b/rest-services/cbs-client/pom.xml
index 1fdc9046..02bfb75e 100644
--- a/rest-services/cbs-client/pom.xml
+++ b/rest-services/cbs-client/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.8.3-SNAPSHOT</version>
+ <version>1.8.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/exceptions/EnvironmentParsingException.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/exceptions/EnvironmentParsingException.java
new file mode 100644
index 00000000..0113000d
--- /dev/null
+++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/exceptions/EnvironmentParsingException.java
@@ -0,0 +1,28 @@
+/*
+ * ============LICENSE_START====================================
+ * DCAEGEN2-SERVICES-SDK
+ * =========================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * =========================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=====================================
+ */
+package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.exceptions;
+
+import org.jetbrains.annotations.NotNull;
+
+public class EnvironmentParsingException extends RuntimeException {
+ public EnvironmentParsingException(final @NotNull String message) {
+ super(message);
+ }
+}
diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMap.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMap.java
index 875e20ed..42f53616 100644
--- a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMap.java
+++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMap.java
@@ -37,6 +37,7 @@ public class CbsClientConfigMap implements CbsClient {
private static final Logger LOGGER = LoggerFactory.getLogger(CbsClientConfigMap.class);
private final String configMapFilePath;
+
public CbsClientConfigMap (String configMapFilePath) {
this.configMapFilePath = configMapFilePath;
}
@@ -44,6 +45,7 @@ public class CbsClientConfigMap implements CbsClient {
@Override
public @NotNull Mono<JsonObject> get(CbsRequest request) {
return Mono.just(this.loadConfigMapFile())
+ .map(CbsClientEnvironmentParsing::processEnvironmentVariables)
.doOnNext(this::logConfigMapOutput);
}
@@ -67,6 +69,8 @@ public class CbsClientConfigMap implements CbsClient {
return new Yaml().load(new FileReader(configMapFilePath).getContent());
}
+
+
private void logConfigMapOutput(JsonObject jsonObject) {
LOGGER.info("Got successful output from ConfigMap file");
LOGGER.debug("ConfigMap output: {}", jsonObject);
diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsing.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsing.java
new file mode 100644
index 00000000..17144f1a
--- /dev/null
+++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsing.java
@@ -0,0 +1,103 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.exceptions.EnvironmentParsingException;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * <p>Config Binding Service client environment variables parsing.</p>
+ *
+ * @since 1.8.4
+ */
+public class CbsClientEnvironmentParsing {
+
+ private static final Pattern shellEnvPattern = Pattern.compile("\\$\\{(.+?)}");
+
+ private CbsClientEnvironmentParsing() {}
+
+ /**
+ * <p>
+ * This method will do a lookup of shell variables in provided jsonObject and replace it with found environment variables.
+ * </p>
+ * <p>
+ * In case of failure during resolving environment variables, EnvironmentParsingException is thrown.
+ * </p>
+ *
+ * @param jsonObject
+ * @return JsonObject
+ * @since 1.8.4
+ */
+ public static JsonObject processEnvironmentVariables(JsonObject jsonObject) {
+ JsonObject jsonObjectCopy = jsonObject.deepCopy();
+ processJsonObject(jsonObjectCopy);
+ return jsonObjectCopy;
+ }
+ private static void processJsonObject(JsonObject jsonObject) {
+ for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
+ processJsonObjectEntry(jsonObject, entry);
+ }
+ }
+ private static void processJsonObjectEntry(JsonObject jsonObject, Map.Entry<String, JsonElement> entry) {
+ if (entry.getValue().isJsonArray()) {
+ processJsonArray(entry.getValue().getAsJsonArray());
+ } else if (entry.getValue().isJsonObject()) {
+ processJsonObject(entry.getValue().getAsJsonObject());
+ } else {
+ Matcher matcher = getMatcher(entry.getValue().getAsString());
+ if (matcher.find()) {
+ jsonObject.addProperty(entry.getKey(), getValueFromSystemEnv(matcher.group(1)));
+ }
+ }
+ }
+
+ private static void processJsonArray(JsonArray jsonArray) {
+ for (int i = 0; i < jsonArray.size(); i++) {
+ if (jsonArray.get(i).isJsonObject()) {
+ processJsonObject(jsonArray.get(i).getAsJsonObject());
+ } else if (jsonArray.get(i).isJsonArray()) {
+ processJsonArray(jsonArray.get(i).getAsJsonArray());
+ } else {
+ Matcher matcher = getMatcher(jsonArray.get(i).getAsString());
+ if (matcher.find()) {
+ jsonArray.set(i, new JsonPrimitive(getValueFromSystemEnv(matcher.group(1))));
+ }
+ }
+ }
+ }
+
+ private static Matcher getMatcher(String value) {
+ return shellEnvPattern.matcher(value);
+ }
+
+ private static String getValueFromSystemEnv( String envName) {
+ String envValue = System.getenv(envName);
+ if (envValue == null || "".equals(envValue)) {
+ throw new EnvironmentParsingException("Cannot read " + envName + " from environment.");
+ }
+ return envValue;
+ }
+}
diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientRest.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientRest.java
index 4559a902..3eda6d8a 100644
--- a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientRest.java
+++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientRest.java
@@ -61,6 +61,7 @@ public class CbsClientRest implements CbsClient {
.flatMap(httpClient::call)
.doOnNext(HttpResponse::throwIfUnsuccessful)
.map(resp -> resp.bodyAsJson(JsonObject.class))
+ .map(CbsClientEnvironmentParsing::processEnvironmentVariables)
.doOnNext(this::logCbsResponse);
}
diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java
index 07b44e9e..a9d8407b 100644
--- a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java
+++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientConfigMapTest.java
@@ -22,20 +22,28 @@ package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
+import com.google.gson.stream.JsonReader;
+import org.junit.Rule;
+import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClient;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
-import org.onap.dcaegen2.services.sdk.services.common.FileReader;
-import org.yaml.snakeyaml.Yaml;
-import java.util.LinkedHashMap;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import static org.assertj.core.api.Assertions.assertThat;
public class CbsClientConfigMapTest {
+ private static final String SAMPLE_EXPECTED_CONFIG = "src/test/resources/sample_expected_service_config.json";
+ @Rule
+ public final EnvironmentVariables envs = new EnvironmentVariables();
+
@Test
- void shouldFetchUsingProperConfigMapFile() {
+ void shouldFetchUsingProperConfigMapFile() throws FileNotFoundException {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
String configMapFilePath = "src/test/resources/application_config.yaml";
final CbsClient cut = new CbsClientConfigMap(configMapFilePath);
@@ -46,12 +54,11 @@ public class CbsClientConfigMapTest {
// then
assertThat(result).isNotNull();
- assertThat(result).isEqualTo(covertYamlToJson(configMapFilePath));
+ assertThat(result).isEqualTo(convertToJson(new JsonReader(new FileReader(SAMPLE_EXPECTED_CONFIG))));
}
- private JsonObject covertYamlToJson(String configMapFilePath) {
+ private JsonObject convertToJson(JsonReader jsonReader) {
Gson gson = new GsonBuilder().create();
- return gson.fromJson(gson.toJson(new Yaml().load(new FileReader(configMapFilePath).getContent()),
- LinkedHashMap.class), JsonObject.class);
+ return gson.fromJson(jsonReader, JsonObject.class);
}
}
diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsingTest.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsingTest.java
new file mode 100644
index 00000000..41d757fd
--- /dev/null
+++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientEnvironmentParsingTest.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START====================================
+ * DCAEGEN2-SERVICES-SDK
+ * =========================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * =========================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=====================================
+ */
+package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+import com.google.gson.stream.JsonReader;
+import org.junit.Rule;
+import org.junit.contrib.java.lang.system.EnvironmentVariables;
+import org.junit.jupiter.api.Test;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CbsClientEnvironmentParsingTest {
+
+ private static final String SAMPLE_CONFIG = "src/test/resources/sample_service_config.json";
+ private static final String SAMPLE_EXPECTED_CONFIG = "src/test/resources/sample_expected_service_config.json";
+ @Rule
+ public final EnvironmentVariables envs = new EnvironmentVariables();
+
+ @Test
+ void shouldProcessEnvironmentVariables() throws FileNotFoundException {
+ //given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
+ JsonObject jsonObject = getSampleJsonObject(SAMPLE_CONFIG);
+ //when
+ JsonObject result = CbsClientEnvironmentParsing.processEnvironmentVariables(jsonObject);
+ //then
+ assertThat(result).isEqualTo(getSampleJsonObject(SAMPLE_EXPECTED_CONFIG));
+ }
+
+ private JsonObject getSampleJsonObject(String file) throws FileNotFoundException {
+ Gson gson = new GsonBuilder().create();
+ JsonReader reader = new JsonReader(new FileReader(file));
+ return gson.fromJson(reader, JsonObject.class);
+ }
+}
diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImplIT.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImplIT.java
index 83743a6c..db881a2e 100644
--- a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImplIT.java
+++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/impl/CbsClientImplIT.java
@@ -23,6 +23,8 @@ package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl;
import com.google.gson.JsonObject;
import io.vavr.collection.Stream;
import org.jetbrains.annotations.NotNull;
+import org.junit.Rule;
+import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -35,6 +37,7 @@ import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.test.DummyHttp
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClient;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.exceptions.EnvironmentParsingException;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.exceptions.StreamParsingException;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.streams.DataStreams;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.streams.StreamFromGsonParser;
@@ -66,12 +69,15 @@ class CbsClientImplIT {
private static final String SAMPLE_KEY = "/sample_key.json";
private static final String SAMPLE_CONFIG_KEY = "keystore.path";
private static final String EXPECTED_CONFIG_VALUE_FROM_CBS = "/var/run/security/keystore.p12";
- private static final String EXPECTED_CONFIG_VALUE_FROM_FILE = "/var/run/security/keystore_file.p12";
- private static final String CONFIG_MAP_FILE_PATH = "src/test/resources/sample_local_service_config.json";
+ private static final String CONFIG_MAP_FILE_PATH = "src/test/resources/application_config.yaml";
private static CbsClientConfiguration sampleConfigurationCbsSource;
private static CbsClientConfiguration sampleConfigurationFileSource;
private static DummyHttpServer server;
+
+ @Rule
+ public final EnvironmentVariables envs = new EnvironmentVariables();
+
@BeforeAll
static void setUp() {
server = DummyHttpServer.start(routes ->
@@ -92,6 +98,8 @@ class CbsClientImplIT {
@Test
void testCbsClientWithSingleCall() {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationCbsSource);
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
@@ -108,6 +116,8 @@ class CbsClientImplIT {
@Test
void testCbsClientWithPeriodicCall() {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationCbsSource);
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
@@ -126,6 +136,8 @@ class CbsClientImplIT {
@Test
void testCbsClientWithUpdatesCall() {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationCbsSource);
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
final Duration period = Duration.ofMillis(10);
@@ -143,8 +155,29 @@ class CbsClientImplIT {
}
@Test
+ void testCbsClientWithConfigRetrievedFromFileMissingEnv() {
+ // given
+ envs.set("AAF_USER", "");
+ final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationFileSource);
+ final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
+
+ // when
+ final Mono<JsonObject> result = sut.flatMap(cbsClient -> cbsClient.get(request));
+
+ // then
+ StepVerifier.create(result)
+ .expectErrorSatisfies(ex -> {
+ assertThat(ex).isInstanceOf(EnvironmentParsingException.class);
+ assertThat(ex).hasMessageContaining("Cannot read AAF_USER from environment.");
+ })
+ .verify(Duration.ofSeconds(5));
+ }
+
+ @Test
void testCbsClientWithConfigRetrievedFromFile() {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationFileSource);
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
@@ -153,7 +186,7 @@ class CbsClientImplIT {
// then
StepVerifier.create(result.map(this::sampleConfigValue))
- .expectNext(EXPECTED_CONFIG_VALUE_FROM_FILE)
+ .expectNext(EXPECTED_CONFIG_VALUE_FROM_CBS)
.expectComplete()
.verify(Duration.ofSeconds(5));
}
@@ -161,6 +194,8 @@ class CbsClientImplIT {
@Test
void testCbsClientWithStreamsParsing() {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationCbsSource);
final StreamFromGsonParser<KafkaSink> kafkaSinkParser = StreamFromGsonParsers.kafkaSinkParser();
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
@@ -185,6 +220,8 @@ class CbsClientImplIT {
@Test
void testCbsClientWithStreamsParsingUsingSwitch() {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationCbsSource);
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
// TODO: Use these parsers below
@@ -221,6 +258,8 @@ class CbsClientImplIT {
@Test
void testCbsClientWithStreamsParsingWhenUsingInvalidParser() {
// given
+ envs.set("AAF_USER", "admin");
+ envs.set("AAF_PASSWORD", "admin_secret");
final Mono<CbsClient> sut = CbsClientFactory.createCbsClient(sampleConfigurationCbsSource);
final StreamFromGsonParser<KafkaSource> kafkaSourceParser = StreamFromGsonParsers.kafkaSourceParser();
final CbsRequest request = CbsRequests.getConfiguration(RequestDiagnosticContext.create());
diff --git a/rest-services/cbs-client/src/test/resources/application_config.yaml b/rest-services/cbs-client/src/test/resources/application_config.yaml
index c43b9733..a2466802 100644
--- a/rest-services/cbs-client/src/test/resources/application_config.yaml
+++ b/rest-services/cbs-client/src/test/resources/application_config.yaml
@@ -1,10 +1,38 @@
---
+keystore.path: "/var/run/security/keystore.p12"
streams_publishes:
perf3gpp:
+ testArray:
+ - testPrimitiveArray:
+ - "${AAF_USER}"
+ - "${AAF_PASSWORD}"
+ - nestedArray:
+ - "${AAF_USER}"
+ testPrimitive: "${AAF_USER}"
+ aaf_credentials:
+ username: "${AAF_USER}"
+ password: "${AAF_PASSWORD}"
type: kafka
+ kafka_info:
+ bootstrap_servers: dmaap-mr-kafka:6060
+ topic_name: HVVES_PERF3GPP
+ pnf_ready:
+ aaf_credentials:
+ username: "${AAF_USER}"
+ password: "${AAF_PASSWORD}"
+ type: message_router
+ dmaap_info:
+ topic_url: http://message-router:3904/events/VES_PNF_READY
+ call_trace:
aaf_credentials:
- username: admin
- password: admin_secret
+ username: "${AAF_USER}"
+ password: "${AAF_PASSWORD}"
+ type: kafka
kafka_info:
- bootstrap_servers: message-router-kafka-0:9093
- topic_name: HV_VES_PERF3GPP
+ bootstrap_servers: dmaap-mr-kafka:6060
+ topic_name: HVVES_TRACE
+streams_subscribes:
+ measurements:
+ type: message_router
+ dmaap_info:
+ topic_url: http://message-router:3904/events/VES_MEASUREMENT
diff --git a/rest-services/cbs-client/src/test/resources/sample_expected_service_config.json b/rest-services/cbs-client/src/test/resources/sample_expected_service_config.json
new file mode 100644
index 00000000..2ceda99a
--- /dev/null
+++ b/rest-services/cbs-client/src/test/resources/sample_expected_service_config.json
@@ -0,0 +1,53 @@
+{
+ "keystore.path": "/var/run/security/keystore.p12",
+ "streams_publishes": {
+ "perf3gpp": {
+ "testArray": [{
+ "testPrimitiveArray": ["admin", "admin_secret", {
+ "nestedArray": ["admin"]
+ }
+ ],
+ "testPrimitive": "admin",
+ "aaf_credentials": {
+ "username": "admin",
+ "password": "admin_secret"
+ }
+ }
+ ],
+ "type": "kafka",
+ "kafka_info": {
+ "bootstrap_servers": "dmaap-mr-kafka:6060",
+ "topic_name": "HVVES_PERF3GPP"
+ }
+ },
+ "pnf_ready": {
+ "aaf_credentials": {
+ "username": "admin",
+ "password": "admin_secret"
+ },
+ "type": "message_router",
+ "dmaap_info": {
+ "topic_url": "http://message-router:3904/events/VES_PNF_READY"
+ }
+ },
+ "call_trace": {
+ "aaf_credentials": {
+ "username": "admin",
+ "password": "admin_secret"
+ },
+ "type": "kafka",
+ "kafka_info": {
+ "bootstrap_servers": "dmaap-mr-kafka:6060",
+ "topic_name": "HVVES_TRACE"
+ }
+ }
+ },
+ "streams_subscribes": {
+ "measurements": {
+ "type": "message_router",
+ "dmaap_info": {
+ "topic_url": "http://message-router:3904/events/VES_MEASUREMENT"
+ }
+ }
+ }
+}
diff --git a/rest-services/cbs-client/src/test/resources/sample_service_config.json b/rest-services/cbs-client/src/test/resources/sample_service_config.json
index 266326f4..e5798597 100644
--- a/rest-services/cbs-client/src/test/resources/sample_service_config.json
+++ b/rest-services/cbs-client/src/test/resources/sample_service_config.json
@@ -2,6 +2,14 @@
"keystore.path": "/var/run/security/keystore.p12",
"streams_publishes": {
"perf3gpp": {
+ "testArray": [{
+ "testPrimitiveArray": ["${AAF_USER}", "${AAF_PASSWORD}", {"nestedArray": ["${AAF_USER}"]}],
+ "testPrimitive": "${AAF_USER}",
+ "aaf_credentials": {
+ "username": "${AAF_USER}",
+ "password": "${AAF_PASSWORD}"
+ }
+ }],
"type": "kafka",
"kafka_info": {
"bootstrap_servers": "dmaap-mr-kafka:6060",
@@ -9,12 +17,20 @@
}
},
"pnf_ready": {
+ "aaf_credentials": {
+ "username": "${AAF_USER}",
+ "password": "${AAF_PASSWORD}"
+ },
"type": "message_router",
"dmaap_info": {
"topic_url": "http://message-router:3904/events/VES_PNF_READY"
}
},
"call_trace": {
+ "aaf_credentials": {
+ "username": "${AAF_USER}",
+ "password": "${AAF_PASSWORD}"
+ },
"type": "kafka",
"kafka_info": {
"bootstrap_servers": "dmaap-mr-kafka:6060",
diff --git a/rest-services/dmaap-client/pom.xml b/rest-services/dmaap-client/pom.xml
index bb8953ec..cb1d811f 100644
--- a/rest-services/dmaap-client/pom.xml
+++ b/rest-services/dmaap-client/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.8.3-SNAPSHOT</version>
+ <version>1.8.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/http-client/pom.xml b/rest-services/http-client/pom.xml
index 5df35e12..ffb93b3c 100644
--- a/rest-services/http-client/pom.xml
+++ b/rest-services/http-client/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.8.3-SNAPSHOT</version>
+ <version>1.8.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/model/pom.xml b/rest-services/model/pom.xml
index 6810c3e1..0c009030 100644
--- a/rest-services/model/pom.xml
+++ b/rest-services/model/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.8.3-SNAPSHOT</version>
+ <version>1.8.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/pom.xml b/rest-services/pom.xml
index 8a64cd35..ddc6c25e 100644
--- a/rest-services/pom.xml
+++ b/rest-services/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.onap.dcaegen2.services</groupId>
<artifactId>sdk</artifactId>
- <version>1.8.3-SNAPSHOT</version>
+ <version>1.8.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>