summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'a1-policy-management/src/test')
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java2
-rw-r--r--a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java27
2 files changed, 29 insertions, 0 deletions
diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java
index ac9d1fba..555f4639 100644
--- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java
+++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientTest.java
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClientResponseException;
@@ -40,6 +41,7 @@ import reactor.util.Loggers;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
+@SpringBootTest
class AsyncRestClientTest {
private static final String BASE_URL = "BaseUrl";
private static final String REQUEST_URL = "/test";
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 69ee12ba..0519c2d5 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
@@ -956,6 +956,7 @@ class ApplicationTest {
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
// DELETE service
+ addPolicy("id1", "type1", serviceName);
assertThat(services.size()).isEqualTo(1);
url = "/services/" + serviceName;
restClient().delete(url).block();
@@ -977,6 +978,32 @@ class ApplicationTest {
}
@Test
+ @DisplayName("test delete Service with no authorization")
+ void testDeleteServiceWithNoAuth() throws Exception {
+ // PUT service
+ String serviceName = "ac.dc";
+ putService(serviceName, 0, HttpStatus.CREATED);
+
+ // No Authorization to Delete
+ this.applicationConfig
+ .setAuthProviderUrl(baseUrl() + OpenPolicyAgentSimulatorController.ACCESS_CONTROL_URL_REJECT);
+ addPolicy("id1", "type1", serviceName);
+ assertThat(services.size()).isEqualTo(1);
+ String url = "/services/" + serviceName;
+ restClient().delete(url).block();
+ assertThat(services.size()).isZero();
+ assertThat(policies.size()).isEqualTo(1);
+ testErrorCode(restClient().get("/policies/id1"), HttpStatus.UNAUTHORIZED);
+ }
+
+ @Test
+ @DisplayName("test delete Service with no service")
+ void testDeleteServiceWithNoService() {
+ String url = "/services/" + "NoService";
+ testErrorCode(restClient().delete(url), HttpStatus.NOT_FOUND);
+ }
+
+ @Test
@DisplayName("test Service Supervision")
void testServiceSupervision() throws Exception {
putService("service1", 2, HttpStatus.CREATED);