summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management/src/test/java')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java3
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java18
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java4
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java8
4 files changed, 21 insertions, 12 deletions
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
index bc22c14d..240dd1df 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/ApplicationTest.java
@@ -193,8 +193,7 @@ class ApplicationTest {
this.addPolicyType("", "ric2");
url = "/rics?policyType=";
- // This tests also validation of trusted certs restClient(true)
- rsp = restClient(true).get(url).block();
+ rsp = restClient().get(url).block();
assertThat(rsp).contains("ric2") //
.doesNotContain("ric1") //
.contains("AVAILABLE");
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
index ab9b7266..e31d0b91 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
@@ -97,8 +97,8 @@ import reactor.util.annotation.Nullable;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = { //
- "server.ssl.key-store=./config/keystore.jks", //
- "app.webclient.trust-store=./config/truststore.jks", //
+ "server.ssl.key-store=./src/test/resources/keystore.jks", //
+ "app.webclient.trust-store=./src/test/resources/truststore.jks", //
"app.vardata-directory=./target/testdata", //
"app.filepath=" //
})
@@ -309,6 +309,13 @@ class ApplicationTest {
}
@Test
+ void testTrustValidation() {
+ addRic("ric1");
+ String rsp = restClient(true).get("/rics").block(); // restClient(true) enables trust validation
+ assertThat(rsp).contains("ric1");
+ }
+
+ @Test
void testGetRics() throws Exception {
addRic("ric1");
this.addPolicyType("type1", "ric1");
@@ -320,9 +327,7 @@ class ApplicationTest {
addRic("ric2");
this.addPolicyType("", "ric2");
url = "/rics?policytype_id=";
-
- // This tests also validation of trusted certs restClient(true)
- rsp = restClient(true).get(url).block();
+ rsp = restClient().get(url).block();
assertThat(rsp).contains("ric2") //
.doesNotContain("ric1") //
.contains("AVAILABLE");
@@ -891,8 +896,7 @@ class ApplicationTest {
}
private AsyncRestClient restClient(boolean useTrustValidation) {
- String baseUrl = "https://localhost:" + port + Consts.V2_API_ROOT;
- return restClient(baseUrl, useTrustValidation);
+ return restClient(baseUrl() + Consts.V2_API_ROOT, useTrustValidation);
}
private AsyncRestClient restClient() {
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
index 030b831f..adb29a70 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ConfigurationControllerTest.java
@@ -162,14 +162,14 @@ class ConfigurationControllerTest {
.keyStorePassword(config.keyStorePassword()) //
.keyStore(config.keyStore()) //
.keyPassword(config.keyPassword()) //
- .isTrustStoreUsed(true) //
+ .isTrustStoreUsed(false) //
.trustStore(config.trustStore()) //
.trustStorePassword(config.trustStorePassword()) //
.httpProxyConfig(config.httpProxyConfig()) //
.build();
AsyncRestClientFactory f = new AsyncRestClientFactory(config);
- return f.createRestClient("https://localhost:" + port);
+ return f.createRestClientNoHttpProxy("https://localhost:" + port);
}
}
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
index 9bd5c502..fae05475 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTaskTest.java
@@ -21,6 +21,7 @@
package org.onap.ccsdk.oran.a1policymanagementservice.tasks;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -67,6 +68,7 @@ class RicSynchronizationTaskTest {
.build();
private static final String RIC_1_NAME = "ric1";
+
private static final Ric RIC_1 = new Ric(ImmutableRicConfig.builder() //
.ricId(RIC_1_NAME) //
.baseUrl("baseUrl1") //
@@ -160,6 +162,7 @@ class RicSynchronizationTaskTest {
RicSynchronizationTask synchronizerUnderTest = spy(createTask());
synchronizerUnderTest.run(RIC_1);
+ await().untilAsserted(() -> RicState.AVAILABLE.equals(RIC_1.getState()));
verify(a1ClientMock, times(1)).getPolicyTypeIdentities();
verifyNoMoreInteractions(a1ClientMock);
@@ -184,6 +187,7 @@ class RicSynchronizationTaskTest {
RicSynchronizationTask synchronizerUnderTest = createTask();
synchronizerUnderTest.run(RIC_1);
+ await().untilAsserted(() -> RicState.AVAILABLE.equals(RIC_1.getState()));
verify(a1ClientMock).getPolicyTypeIdentities();
verifyNoMoreInteractions(a1ClientMock);
@@ -213,7 +217,7 @@ class RicSynchronizationTaskTest {
RicSynchronizationTask synchronizerUnderTest = createTask();
synchronizerUnderTest.run(RIC_1);
-
+ await().untilAsserted(() -> RicState.AVAILABLE.equals(RIC_1.getState()));
verify(a1ClientMock).deleteAllPolicies();
verify(a1ClientMock).putPolicy(POLICY_1);
verifyNoMoreInteractions(a1ClientMock);
@@ -240,6 +244,7 @@ class RicSynchronizationTaskTest {
RicSynchronizationTask synchronizerUnderTest = createTask();
synchronizerUnderTest.run(RIC_1);
+ await().untilAsserted(() -> RicState.AVAILABLE.equals(RIC_1.getState()));
verify(a1ClientMock, times(2)).deleteAllPolicies();
verifyNoMoreInteractions(a1ClientMock);
@@ -264,6 +269,7 @@ class RicSynchronizationTaskTest {
RicSynchronizationTask synchronizerUnderTest = createTask();
synchronizerUnderTest.run(RIC_1);
+ await().untilAsserted(() -> RicState.AVAILABLE.equals(RIC_1.getState()));
verify(a1ClientMock, times(2)).deleteAllPolicies();
verifyNoMoreInteractions(a1ClientMock);