Bugfix path elements containing dot 89/114589/1
authorPatrikBuhr <patrik.buhr@est.tech>
Wed, 4 Nov 2020 12:48:27 +0000 (13:48 +0100)
committerPatrikBuhr <patrik.buhr@est.tech>
Wed, 4 Nov 2020 12:49:52 +0000 (13:49 +0100)
Springboot trunkates last URL path element if it contains a dot '.'.
This is a workaround.

Change-Id: I1ae4139468a2669bfd6e33ae9eff88b2fc2a2004
Issue-ID: CCSDK-2502
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyController.java
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/offeredapis/swagger/pms-api.json

index 256b478..8dd2df6 100644 (file)
@@ -97,13 +97,13 @@ public class PolicyController {
     private static Gson gson = new GsonBuilder() //
             .create(); //
 
-    @GetMapping(path = Consts.V2_API_ROOT + "/policy-types/{policyTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
+    @GetMapping(path = "/v2/policy-types/{policytype_id:.+}", produces = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "Returns a policy type definition")
     @ApiResponses(value = { //
             @ApiResponse(code = 200, message = "Policy type", response = PolicyTypeInfo.class), //
-            @ApiResponse(code = 404, message = "Near-RT RIC is not found", response = ErrorResponse.ErrorInfo.class)})
+            @ApiResponse(code = 404, message = "Policy type is not found", response = ErrorResponse.ErrorInfo.class)})
     public ResponseEntity<Object> getPolicyType( //
-            @PathVariable("policyTypeId") String policyTypeId) {
+            @PathVariable("policytype_id") String policyTypeId) {
         try {
             PolicyType type = policyTypes.getType(policyTypeId);
             PolicyTypeInfo info = new PolicyTypeInfo(type.schema());
@@ -134,7 +134,7 @@ public class PolicyController {
         }
     }
 
-    @GetMapping(path = Consts.V2_API_ROOT + "/policies/{policy_id}", produces = MediaType.APPLICATION_JSON_VALUE)
+    @GetMapping(path = Consts.V2_API_ROOT + "/policies/{policy_id:.+}", produces = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "Returns a policy") //
     @ApiResponses(value = { //
             @ApiResponse(code = 200, message = "Policy found", response = PolicyInfo.class), //
@@ -150,7 +150,7 @@ public class PolicyController {
         }
     }
 
-    @DeleteMapping(Consts.V2_API_ROOT + "/policies/{policy_id}")
+    @DeleteMapping(Consts.V2_API_ROOT + "/policies/{policy_id:.+}")
     @ApiOperation(value = "Delete a policy")
     @ApiResponses(value = { //
             @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
index b2fa029..a8fc7e6 100644 (file)
@@ -143,9 +143,9 @@ public class ServiceController {
             @ApiResponse(code = 204, message = "Service unregistered"),
             @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
             @ApiResponse(code = 404, message = "Service not found", response = ErrorResponse.ErrorInfo.class)})
-    @DeleteMapping(Consts.V2_API_ROOT + "/services/{serviceId}")
+    @DeleteMapping(Consts.V2_API_ROOT + "/services/{service_id:.+}")
     public ResponseEntity<Object> deleteService(//
-            @PathVariable("serviceId") String serviceId) {
+            @PathVariable("service_id") String serviceId) {
         try {
             Service service = removeService(serviceId);
             // Remove the policies from the repo and let the consistency monitoring
index 02fdaf9..a0cb2af 100644 (file)
@@ -333,10 +333,10 @@ class ApplicationTest {
 
     @Test
     void testPutPolicy() throws Exception {
-        String serviceName = "service1";
-        String ricId = "ric1";
-        String policyTypeName = "type1";
-        String policyInstanceId = "instance1";
+        String serviceName = "service.1";
+        String ricId = "ric.1";
+        String policyTypeName = "type1_1.2.3";
+        String policyInstanceId = "instance_1.2.3";
 
         putService(serviceName);
         addPolicyType(policyTypeName, ricId);
@@ -352,7 +352,7 @@ class ApplicationTest {
         assertThat(policy).isNotNull();
         assertThat(policy.id()).isEqualTo(policyInstanceId);
         assertThat(policy.ownerServiceId()).isEqualTo(serviceName);
-        assertThat(policy.ric().id()).isEqualTo("ric1");
+        assertThat(policy.ric().id()).isEqualTo(ricId);
         assertThat(policy.isTransient()).isTrue();
 
         // Put a non transient policy
@@ -463,10 +463,11 @@ class ApplicationTest {
 
     @Test
     void testDeletePolicy() throws Exception {
-        addPolicy("id", "typeName", "service1", "ric1");
+        String policyId = "id.1";
+        addPolicy(policyId, "typeName", "service1", "ric1");
         assertThat(policies.size()).isEqualTo(1);
 
-        String url = "/policies/id";
+        String url = "/policies/" + policyId;
         ResponseEntity<String> entity = restClient().deleteForEntity(url).block();
 
         assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
@@ -478,11 +479,13 @@ class ApplicationTest {
 
     @Test
     void testGetPolicyType() throws Exception {
-        addPolicyType("type1", "ric1");
+        String typeId = "AC.D";
+        addPolicyType(typeId, "ric1");
 
         waitForRicState("ric1", RicState.AVAILABLE);
 
-        String url = "/policy-types/type1";
+        String url = "/policy-types/" + typeId;
+
         String rsp = this.restClient().get(url).block();
 
         PolicyTypeInfo info = gson.fromJson(rsp, PolicyTypeInfo.class);
@@ -595,12 +598,12 @@ class ApplicationTest {
     @Test
     void testPutAndGetService() throws Exception {
         // PUT
-        String serviceName = "name";
+        String serviceName = "ac.dc";
         putService(serviceName, 0, HttpStatus.CREATED);
         putService(serviceName, 0, HttpStatus.OK);
 
         // GET one service
-        String url = "/services?service_id=name";
+        String url = "/services?service_id=" + serviceName;
         String rsp = restClient().get(url).block();
         ServiceStatusList info = gson.fromJson(rsp, ServiceStatusList.class);
         assertThat(info.statusList).hasSize(1);
@@ -615,13 +618,13 @@ class ApplicationTest {
         logger.info(rsp);
 
         // Keep alive
-        url = "/services/name/keepalive";
+        url = "/services/" + serviceName + "/keepalive";
         ResponseEntity<?> entity = restClient().putForEntity(url).block();
         assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
 
         // DELETE service
         assertThat(services.size()).isEqualTo(1);
-        url = "/services/name";
+        url = "/services/" + serviceName;
         restClient().delete(url).block();
         assertThat(services.size()).isZero();
 
index 3f684b8..b503ac0 100644 (file)
@@ -35,7 +35,7 @@
             "summary": "Returns status and statistics of this service",
             "deprecated": false,
             "produces": ["application/json"],
-            "operationId": "getStatusUsingGET_1",
+            "operationId": "getStatusUsingGET",
             "responses": {
                 "200": {
                     "schema": {"$ref": "#/definitions/status_info_v2"},
                 "tags": ["A1 Policy Management Version 1.0"]
             }
         },
+        "/v2/services/{service_id}": {"delete": {
+            "summary": "Unregister a service",
+            "deprecated": false,
+            "produces": ["*/*"],
+            "operationId": "deleteServiceUsingDELETE",
+            "responses": {
+                "200": {"description": "Not used"},
+                "401": {"description": "Unauthorized"},
+                "204": {
+                    "schema": {"type": "object"},
+                    "description": "Service unregistered"
+                },
+                "403": {"description": "Forbidden"},
+                "404": {
+                    "schema": {"$ref": "#/definitions/error_information"},
+                    "description": "Service not found"
+                }
+            },
+            "parameters": [{
+                "in": "path",
+                "name": "service_id",
+                "description": "service_id",
+                "type": "string",
+                "required": true
+            }],
+            "tags": ["A1 Policy Management Version 2.0 (in progress)"]
+        }},
         "/policy": {
             "get": {
                 "summary": "Returns a policy configuration",
             "tags": ["A1 Policy Management Version 2.0 (in progress)"],
             "consumes": ["application/json"]
         }},
-        "/v2/policy-types/{policyTypeId}": {"get": {
-            "summary": "Returns a policy type definition",
-            "deprecated": false,
-            "produces": ["application/json"],
-            "operationId": "getPolicyTypeUsingGET",
-            "responses": {
-                "200": {
-                    "schema": {"$ref": "#/definitions/policytype_v2"},
-                    "description": "Policy type"
-                },
-                "401": {"description": "Unauthorized"},
-                "403": {"description": "Forbidden"},
-                "404": {
-                    "schema": {"$ref": "#/definitions/error_information"},
-                    "description": "Near-RT RIC is not found"
-                }
-            },
-            "parameters": [{
-                "in": "path",
-                "name": "policyTypeId",
-                "description": "policyTypeId",
-                "type": "string",
-                "required": true
-            }],
-            "tags": ["A1 Policy Management Version 2.0 (in progress)"]
-        }},
         "/status": {"get": {
             "summary": "Returns status and statistics of this service",
             "deprecated": false,
             "produces": ["*/*"],
-            "operationId": "getStatusUsingGET",
+            "operationId": "getStatusUsingGET_1",
             "responses": {
                 "200": {
                     "schema": {"type": "string"},
             ],
             "tags": ["A1 Policy Management Version 2.0 (in progress)"]
         }},
-        "/v2/services/{serviceId}": {"delete": {
-            "summary": "Unregister a service",
-            "deprecated": false,
-            "produces": ["*/*"],
-            "operationId": "deleteServiceUsingDELETE",
-            "responses": {
-                "200": {"description": "Not used"},
-                "401": {"description": "Unauthorized"},
-                "204": {
-                    "schema": {"type": "object"},
-                    "description": "Service unregistered"
-                },
-                "403": {"description": "Forbidden"},
-                "404": {
-                    "schema": {"$ref": "#/definitions/error_information"},
-                    "description": "Service not found"
-                }
-            },
-            "parameters": [{
-                "in": "path",
-                "name": "serviceId",
-                "description": "serviceId",
-                "type": "string",
-                "required": true
-            }],
-            "tags": ["A1 Policy Management Version 2.0 (in progress)"]
-        }},
         "/r-app/pms-callback": {"post": {
             "summary": "Callback for Near-RT RIC status",
             "deprecated": false,
             "tags": ["R-App Callbacks"],
             "consumes": ["application/json"]
         }},
+        "/v2/policy-types/{policytype_id}": {"get": {
+            "summary": "Returns a policy type definition",
+            "deprecated": false,
+            "produces": ["application/json"],
+            "operationId": "getPolicyTypeUsingGET",
+            "responses": {
+                "200": {
+                    "schema": {"$ref": "#/definitions/policytype_v2"},
+                    "description": "Policy type"
+                },
+                "401": {"description": "Unauthorized"},
+                "403": {"description": "Forbidden"},
+                "404": {
+                    "schema": {"$ref": "#/definitions/error_information"},
+                    "description": "Policy type is not found"
+                }
+            },
+            "parameters": [{
+                "in": "path",
+                "name": "policytype_id",
+                "description": "policytype_id",
+                "type": "string",
+                "required": true
+            }],
+            "tags": ["A1 Policy Management Version 2.0 (in progress)"]
+        }},
         "/service": {"put": {
             "summary": "Register a service",
             "deprecated": false,
             }
         }
     },
-    "host": "localhost:38593",
+    "host": "localhost:36953",
     "definitions": {
         "error_information": {
             "description": "Problem as defined in https://tools.ietf.org/html/rfc7807",