aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml8
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java28
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClientFactory.java (renamed from prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java)8
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClientFactoryTest.java70
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java12
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java4
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java)15
-rw-r--r--prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java2
9 files changed, 96 insertions, 53 deletions
diff --git a/pom.xml b/pom.xml
index 317ff81d..b9e9f81c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.2.0</version>
+ <version>1.2.1</version>
<relativePath/>
</parent>
@@ -48,8 +48,8 @@
<properties>
<java.version>8</java.version>
<immutables.version>2.5.6</immutables.version>
- <spring.version>5.1.0.RELEASE</spring.version>
- <spring-boot.version>2.0.5.RELEASE</spring-boot.version>
+ <spring.version>5.1.2.RELEASE</spring.version>
+ <spring-boot.version>2.1.0.RELEASE</spring-boot.version>
<tomcat.version>8.5.32</tomcat.version>
<slf4j.version>1.7.25</slf4j.version>
<junit-jupiter.version>5.1.0</junit-jupiter.version>
@@ -133,7 +133,7 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-bom</artifactId>
- <version>Bismuth-SR12</version>
+ <version>Californium-SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java
deleted file mode 100644
index bd4355cd..00000000
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AaiRequestException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. 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.prh.exceptions;
-
-public class AaiRequestException extends Exception {
-
- public AaiRequestException(String message) {
- super(message);
- }
-}
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClientFactory.java
index 2d1a7ac4..e4f330e0 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClientFactory.java
@@ -40,9 +40,9 @@ import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClient;
-public class AaiReactiveWebClient {
+public class AaiReactiveWebClientFactory {
- private static final Logger LOGGER = LoggerFactory.getLogger(AaiReactiveWebClient.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(AaiReactiveWebClientFactory.class);
private final String aaiUserName;
private final String aaiUserPassword;
@@ -55,12 +55,12 @@ public class AaiReactiveWebClient {
private final SslFactory sslFactory;
/**
- * Creating AaiReactiveWebClient.
+ * Creating AaiReactiveWebClientFactory.
*
* @param configuration - configuration object
* @param sslFactory - factory for ssl setup
*/
- public AaiReactiveWebClient(SslFactory sslFactory, AaiClientConfiguration configuration) {
+ public AaiReactiveWebClientFactory(SslFactory sslFactory, AaiClientConfiguration configuration) {
this.aaiUserName = configuration.aaiUserName();
this.aaiUserPassword = configuration.aaiUserPassword();
this.aaiHeaders = configuration.aaiHeaders();
diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClientFactoryTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClientFactoryTest.java
new file mode 100644
index 00000000..bd976ab4
--- /dev/null
+++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClientFactoryTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PNF-REGISTRATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. 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.prh.service;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.net.ssl.SSLException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
+import org.onap.dcaegen2.services.prh.ssl.SslFactory;
+
+
+class AaiReactiveWebClientFactoryTest {
+
+ private static final String TRUST_STORE_PATH = "trust_store_path";
+ private static final String TRUST_STORE_PASS_PATH = "trust_store_pass_path";
+ private static final String KEY_STORE_PATH = "key_store_path";
+ private static final String KEY_STORE_PASS_PATH = "key_store_pass_path";
+ private SslFactory sslFactory = mock(SslFactory.class);
+ private AaiClientConfiguration aaiClientConfiguration = mock(AaiClientConfiguration.class);
+ private AaiReactiveWebClientFactory aaiReactiveWebClientFactory;
+
+ @Test
+ void shouldCreateWebClientWithSecureSslContext() throws SSLException {
+ givenEnabledAaiCertAuthConfiguration();
+ aaiReactiveWebClientFactory = new AaiReactiveWebClientFactory(sslFactory, aaiClientConfiguration);
+
+ Assertions.assertNotNull(aaiReactiveWebClientFactory.build());
+ verify(sslFactory).createSecureContext(KEY_STORE_PATH, KEY_STORE_PASS_PATH,
+ TRUST_STORE_PATH, TRUST_STORE_PASS_PATH);
+ }
+
+ @Test
+ void shouldCreateWebClientWithInsecureSslContext() throws SSLException {
+ when(aaiClientConfiguration.enableAaiCertAuth()).thenReturn(false);
+ aaiReactiveWebClientFactory = new AaiReactiveWebClientFactory(sslFactory, aaiClientConfiguration);
+
+ Assertions.assertNotNull(aaiReactiveWebClientFactory.build());
+ verify(sslFactory).createInsecureContext();
+ }
+
+ private void givenEnabledAaiCertAuthConfiguration() {
+ when(aaiClientConfiguration.enableAaiCertAuth()).thenReturn(true);
+ when(aaiClientConfiguration.trustStorePath()).thenReturn(TRUST_STORE_PATH);
+ when(aaiClientConfiguration.trustStorePasswordPath()).thenReturn(TRUST_STORE_PASS_PATH);
+ when(aaiClientConfiguration.keyStorePath()).thenReturn(KEY_STORE_PATH);
+ when(aaiClientConfiguration.keyStorePasswordPath()).thenReturn(KEY_STORE_PASS_PATH);
+ }
+} \ No newline at end of file
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
index 1e1e0491..c9667ed6 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
@@ -65,7 +65,7 @@ public class CloudConfiguration extends AppConfig {
this.prhConfigurationProvider = prhConfigurationProvider;
}
- protected void runTask() {
+ public void runTask() {
Flux.defer(() -> EnvironmentProcessor.evaluate(systemEnvironment))
.subscribeOn(Schedulers.parallel())
.subscribe(this::parsingConfigSuccess, this::parsingConfigError);
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
index 9386b9e8..aa913654 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
@@ -22,7 +22,7 @@ package org.onap.dcaegen2.services.prh.controllers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.onap.dcaegen2.services.prh.configuration.SchedulerConfig;
+import org.onap.dcaegen2.services.prh.tasks.ScheduledTasksRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,25 +42,25 @@ public class ScheduleController {
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleController.class);
- private final SchedulerConfig schedulerConfig;
+ private final ScheduledTasksRunner scheduledTasksRunner;
@Autowired
- public ScheduleController(SchedulerConfig schedulerConfig) {
- this.schedulerConfig = schedulerConfig;
+ public ScheduleController(ScheduledTasksRunner scheduledTasksRunner) {
+ this.scheduledTasksRunner = scheduledTasksRunner;
}
@RequestMapping(value = "start", method = RequestMethod.GET)
@ApiOperation(value = "Start scheduling worker request")
public Mono<ResponseEntity<String>> startTasks() {
LOGGER.trace("Receiving start scheduling worker request");
- return Mono.fromSupplier(schedulerConfig::tryToStartTask).map(this::createStartTaskResponse);
+ return Mono.fromSupplier(scheduledTasksRunner::tryToStartTask).map(this::createStartTaskResponse);
}
@RequestMapping(value = "stopPrh", method = RequestMethod.GET)
@ApiOperation(value = "Receiving stop scheduling worker request")
public Mono<ResponseEntity<String>> stopTask() {
LOGGER.trace("Receiving stop scheduling worker request");
- return schedulerConfig.getResponseFromCancellationOfTasks();
+ return scheduledTasksRunner.getResponseFromCancellationOfTasks();
}
@ApiOperation(value = "Sends success or error response on starting task execution")
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
index 54a8ad89..711d808f 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTask.java
@@ -25,7 +25,7 @@ import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.services.prh.service.AaiReactiveWebClient;
+import org.onap.dcaegen2.services.prh.service.AaiReactiveWebClientFactory;
import org.onap.dcaegen2.services.prh.service.producer.AaiProducerReactiveHttpClient;
import org.onap.dcaegen2.services.prh.ssl.SslFactory;
import org.springframework.web.reactive.function.client.WebClient;
@@ -47,6 +47,6 @@ public abstract class AaiProducerTask {
throws PrhTaskException, SSLException;
WebClient buildWebClient() throws SSLException {
- return new AaiReactiveWebClient(new SslFactory(), resolveConfiguration()).build();
+ return new AaiReactiveWebClientFactory(new SslFactory(), resolveConfiguration()).build();
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
index 76ba5ec6..956ffead 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.dcaegen2.services.prh.configuration;
+package org.onap.dcaegen2.services.prh.tasks;
import io.swagger.annotations.ApiOperation;
import java.time.Duration;
@@ -27,7 +27,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
import javax.annotation.PostConstruct;
-import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
+
+import org.onap.dcaegen2.services.prh.configuration.CloudConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
@@ -46,11 +47,11 @@ import reactor.core.publisher.Mono;
*/
@Configuration
@EnableScheduling
-public class SchedulerConfig {
+public class ScheduledTasksRunner {
private static final int SCHEDULING_DELAY_FOR_PRH_TASKS = 10;
private static final int SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY = 5;
- private static final Logger LOGGER = LoggerFactory.getLogger(SchedulerConfig.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledTasksRunner.class);
private static final Marker ENTRY = MarkerFactory.getMarker("ENTRY");
private static volatile List<ScheduledFuture> scheduledPrhTaskFutureList = new ArrayList<>();
@@ -59,9 +60,9 @@ public class SchedulerConfig {
private final CloudConfiguration cloudConfiguration;
@Autowired
- public SchedulerConfig(TaskScheduler taskScheduler,
- ScheduledTasks scheduledTask,
- CloudConfiguration cloudConfiguration) {
+ public ScheduledTasksRunner(TaskScheduler taskScheduler,
+ ScheduledTasks scheduledTask,
+ CloudConfiguration cloudConfiguration) {
this.taskScheduler = taskScheduler;
this.scheduledTask = scheduledTask;
this.cloudConfiguration = cloudConfiguration;
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java
index 595fd6d4..256d3c21 100644
--- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java
+++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClientTest.java
@@ -96,7 +96,7 @@ class DMaaPConsumerReactiveHttpClientTest {
}
@Test
- void getAppropriateUri_whenPassingCorrectedPathForPnf() throws URISyntaxException {
+ void getAppropriateUri_whenPassingCorrectedPathForPnf() {
Assertions.assertEquals(dmaapConsumerReactiveHttpClient.getUri(),
URI.create("https://54.45.33.2:1234/unauthenticated.SEC_OTHER_OUTPUT/OpenDCAE-c12/c12"));
}