Improving code-coverage for the Handle non transient policy deletion bug fix - london 65/138765/2
authorraviteja.karumuri <raviteja.karumuri@est.tech>
Thu, 15 Aug 2024 11:43:04 +0000 (12:43 +0100)
committerraviteja.karumuri <raviteja.karumuri@est.tech>
Thu, 15 Aug 2024 14:16:47 +0000 (15:16 +0100)
Issue-ID: CCSDK-4048
Change-Id: I8519f8c2e221d817ee54ed8ef3a8bb894d6bb87e
Signed-off-by: Raviteja Karumuri <raviteja.karumuri@est.tech>
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceController.java
a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java
docs/consumedapis/consumedapis.rst
docs/humaninterfaces/humaninterfaces.rst

index 4bf543e..84c8cb3 100644 (file)
@@ -179,7 +179,7 @@ public class ServiceController {
             Service service = removeService(serviceId);
             removePolicies(service, headers);
             return new ResponseEntity<>(HttpStatus.NO_CONTENT);
-        } catch (ServiceException | NullPointerException e) {
+        } catch (ServiceException e) {
             logger.warn("Exception caught during service deletion while deleting service {}: {}", serviceId, e.getMessage());
             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
         }
index a42bd65..c1525ff 100644 (file)
@@ -959,6 +959,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();
@@ -979,6 +980,32 @@ class ApplicationTest {
         testErrorCode(restClient().get("/services?service_id=XXX"), HttpStatus.NOT_FOUND);
     }
 
+    @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 {
index 7606134..8fbde33 100755 (executable)
@@ -17,6 +17,6 @@ The *A1 Interface - Application Protocol Specification (A1-AP)* describes this i
 
 The **London** ONAP A1 Policy functions implement the *A1 Policy* (*A1-P*) parts of A1-AP, supporting versions *v1.1*, *v2.0* and *v3.0*.
 
-An opensource implementation of a `near-RT RIC <https://wiki.o-ran-sc.org/pages/viewpage.action?pageId=1179659>`_ is available from the `O-RAN Software Community <https://o-ran-sc.org>`_. It supports a pre-spec version of the A1-AP. The ONAP A1 Policy functions described here also supports this A1 version (*A1-OSC*).
+An opensource implementation of a `near-RT RIC <https://lf-o-ran-sc.atlassian.net/wiki/spaces/RICP/overview>`_ is available from the `O-RAN Software Community <https://o-ran-sc.org>`_. It supports a pre-spec version of the A1-AP. The ONAP A1 Policy functions described here also supports this A1 version (*A1-OSC*).
 
-An opensource implementation of an `A1 Simulator <https://wiki.o-ran-sc.org/pages/viewpage.action?pageId=3604819>`_ is also available from the `O-RAN Software Community <https://o-ran-sc.org>`_. It supports all versions of A1-AP.
+An opensource implementation of an `A1 Simulator <https://lf-o-ran-sc.atlassian.net/wiki/spaces/RICNR/overview>`_ is also available from the `O-RAN Software Community <https://o-ran-sc.org>`_. It supports all versions of A1-AP.
\ No newline at end of file
index be271b4..64aebd0 100644 (file)
@@ -6,6 +6,6 @@ Human Interfaces
 ================
 
 The NON-RT RIC Control Panel in O-RAN-SC can be used to interact with the Policy Management Service.
-See `NON-RT RIC Control Panel repo <https://gerrit.o-ran-sc.org/r/admin/repos/portal/nonrtric-controlpanel>`_ from the `O-RAN-SC NONRTRIC Project <https://wiki.o-ran-sc.org/display/RICNR>`_.
+See `NON-RT RIC Control Panel repo <https://gerrit.o-ran-sc.org/r/admin/repos/portal/nonrtric-controlpanel>`_ from the `O-RAN-SC NONRTRIC Project <https://lf-o-ran-sc.atlassian.net/wiki/spaces/RICNR/overview>`_.
 
 Any "REST Client" application may be used (Postman, ...) to interact with the Policy Management Service application via the :ref:`pms_api`