aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-11-16 13:47:01 +0000
committerGerrit Code Review <gerrit@onap.org>2021-11-16 13:47:01 +0000
commit469cd2266c732713b01ebbe4d31b2e7640f91dd7 (patch)
treebfaf69a5877ef24fe393f983ab032ad7d38c41e2 /mso-api-handlers
parentcb944daf25ee1ff65d032cbc30cd29c6ee1dfef1 (diff)
parent16785537a48d0ca0847b826226d7d81731dba271 (diff)
Merge "Disable VnfDeleteValidator for non-alacarte requests."
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java18
2 files changed, 19 insertions, 2 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
index 44bab7e087..3dc4e8e4ac 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
@@ -19,7 +19,8 @@ public class VnfDeleteValidator implements RequestValidator {
@Override
public boolean shouldRunFor(String requestUri, ServiceInstancesRequest request, Actions action) {
return Pattern.compile("[Vv][5-8]/serviceInstances/[^/]+/vnfs/[^/]+").matcher(requestUri).matches()
- && action.equals(Action.deleteInstance);
+ && action.equals(Action.deleteInstance)
+ && Boolean.TRUE.equals(request.getRequestDetails().getRequestParameters().getALaCarte());
}
@Override
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java
index 6eb6fc95d6..9b1410439e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VnfDeleteValidatorTest.java
@@ -15,6 +15,8 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.apihandlerinfra.infra.rest.validators.VnfDeleteValidator;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -31,10 +33,24 @@ public class VnfDeleteValidatorTest {
private Map<String, String> instanceIdMap = new HashMap<>();
+ public ServiceInstancesRequest createServiceInstancesRequest(boolean alacarte) {
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ sir.setRequestDetails(new RequestDetails());
+ sir.getRequestDetails().setRequestParameters(new RequestParameters());
+ sir.getRequestDetails().getRequestParameters().setaLaCarte(alacarte);
+ return sir;
+ }
+
@Test
public void validateURIMatchTest() {
assertEquals(true, vnfValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/vnfs/asdfasdf",
- new ServiceInstancesRequest(), Action.deleteInstance));
+ createServiceInstancesRequest(true), Action.deleteInstance));
+ }
+
+ @Test
+ public void validateURIMatchNonAlacarteTest() {
+ assertEquals(false, vnfValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/vnfs/asdfasdf",
+ createServiceInstancesRequest(false), Action.deleteInstance));
}
@Test