summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsamuel liard <samuel.liard@gmail.com>2021-04-26 17:24:35 +0200
committersamuel liard <samuel.liard@gmail.com>2021-04-27 08:22:54 +0200
commit34ab41dfd55ea6f2c06725eb6e47c8b2689dccb4 (patch)
treeb2284c9ed16b4d1e9c4e54f4bfb18f70dbaa565b
parenta054e25534e6cb5783e6c74638e8cb726744b590 (diff)
:Sonar issues review, fix weak cryptography problem. Reformat code
Issue-ID: SO-3625 Signed-off-by: sliard <samuel.liard@gmail.com> Change-Id: Ied243d59ebd92e158c451f2cdd694895103de2eb
-rw-r--r--so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java7
-rw-r--r--so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java24
-rw-r--r--so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro1.java33
-rw-r--r--so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro2.java24
-rw-r--r--so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro3.java24
-rw-r--r--so-simulator/src/main/java/org/onap/so/simulator/scenarios/sdnc/grapi/QueryVFModuleGR.java9
6 files changed, 58 insertions, 63 deletions
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java
index b42441bcae..f7e829335e 100644
--- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java
+++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java
@@ -1,5 +1,8 @@
package org.onap.so.simulator.actions.aai;
+import com.consol.citrus.actions.AbstractTestAction;
+import com.consol.citrus.context.TestContext;
+import java.security.SecureRandom;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
@@ -7,8 +10,6 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.consol.citrus.actions.AbstractTestAction;
-import com.consol.citrus.context.TestContext;
public class ProcessNetwork extends AbstractTestAction {
@@ -17,7 +18,7 @@ public class ProcessNetwork extends AbstractTestAction {
public void doExecute(TestContext context) {
final Logger logger = LoggerFactory.getLogger(ProcessNetwork.class);
try {
- int random = (int) (Math.random() * 50 + 1);
+ int random = (new SecureRandom()).nextInt(50) + 1;
AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java
index 383e1bfd5f..4989e99e20 100644
--- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java
+++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java
@@ -14,19 +14,21 @@ import com.consol.citrus.context.TestContext;
public class ProcessVnfc extends AbstractTestAction {
+ private static final String VNF_SERVER_1_NAME = "ssc_server_1";
+
@Override
public void doExecute(TestContext context) {
final Logger logger = LoggerFactory.getLogger(ProcessVnfc.class);
try {
logger.debug("running ProcessVnfc scenario");
- logger.debug("requestAction: " + context.getVariable("requestAction"));
- logger.debug("serviceAction: " + context.getVariable("serviceAction"));
- logger.debug("cloudOwner: " + context.getVariable("cloudOwner"));
- logger.debug("cloundRegion: " + context.getVariable("cloudRegion"));
- logger.debug("tenant: " + context.getVariable("tenant"));
- logger.debug("vfModuleId: " + context.getVariable("vfModuleId"));
- logger.debug("vnfId: " + context.getVariable("vnfId"));
+ logger.debug("requestAction: {}", context.getVariable("requestAction"));
+ logger.debug("serviceAction: {}", context.getVariable("serviceAction"));
+ logger.debug("cloudOwner: {}", context.getVariable("cloudOwner"));
+ logger.debug("cloundRegion: {}", context.getVariable("cloudRegion"));
+ logger.debug("tenant: {}", context.getVariable("tenant"));
+ logger.debug("vfModuleId: {}", context.getVariable("vfModuleId"));
+ logger.debug("vnfId: {}", context.getVariable("vnfId"));
AAIResourcesClient aaiResourceClient = new AAIResourcesClient();
@@ -34,9 +36,9 @@ public class ProcessVnfc extends AbstractTestAction {
&& context.getVariable("serviceAction").equals("assign")) {
AAIResourceUri vnfcURI =
- AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc("ssc_server_1"));
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(VNF_SERVER_1_NAME));
Vnfc vnfc = new Vnfc();
- vnfc.setVnfcName("ssc_server_1");
+ vnfc.setVnfcName(VNF_SERVER_1_NAME);
vnfc.setNfcNamingCode("oamfw");
vnfc.setNfcFunction("EPC-OAM-FIREWALL");
vnfc.setProvStatus("PREPROV");
@@ -53,8 +55,8 @@ public class ProcessVnfc extends AbstractTestAction {
if (aaiResourceClient.exists(vnfcURI)) {
Optional<VfModule> vfModule = aaiResourceClient.get(vfModuleURI).asBean(VfModule.class);
- if (vfModule.get().getVfModuleName().contains("macro")) {
- String vnfcName = "ssc_server_1" + vfModule.get().getVfModuleName()
+ if (vfModule.isPresent() && vfModule.get().getVfModuleName().contains("macro")) {
+ String vnfcName = VNF_SERVER_1_NAME + vfModule.get().getVfModuleName()
.substring(vfModule.get().getVfModuleName().length() - 1);
vnfc.setVnfcName(vnfcName);
vnfcURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName));
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro1.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro1.java
index 29a9aff93c..140ac3c532 100644
--- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro1.java
+++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro1.java
@@ -1,22 +1,24 @@
package org.onap.so.simulator.scenarios.openstack.macro;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;
import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
import com.consol.citrus.simulator.scenario.Scenario;
import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
/**
- * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete
+ * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete.
*
*/
@Scenario("Openstack-QueryStackByID-Macro1")
@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_1/*", method = RequestMethod.GET)
public class QueryStackByIdMacro1 extends AbstractSimulatorScenario {
+ private static final String FILE_STACK_CREATED_PATH = "openstack/gr_api/Stack_Created.json";
+ private static final String FILE_STACK_DELETED_PATH = "openstack/gr_api/Stack_Deleted.json";
@Override
public void run(ScenarioDesigner scenario) {
@@ -31,38 +33,31 @@ public class QueryStackByIdMacro1 extends AbstractSimulatorScenario {
scenario.variable("stackName", "macro_module_1");
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
// Create (module_2)
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
// Create (module_3)
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
// Create (module_2 recreate)
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
// Delete
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
// Delete
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
// Poll
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
}
}
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro2.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro2.java
index 15f0b611a0..05d87cd314 100644
--- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro2.java
+++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro2.java
@@ -1,22 +1,24 @@
package org.onap.so.simulator.scenarios.openstack.macro;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;
import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
import com.consol.citrus.simulator.scenario.Scenario;
import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
/**
- * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete
+ * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete.
*
*/
@Scenario("Openstack-QueryStackByID-Macro2")
@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_2/*", method = RequestMethod.GET)
public class QueryStackByIdMacro2 extends AbstractSimulatorScenario {
+ private static final String FILE_STACK_CREATED_PATH = "openstack/gr_api/Stack_Created.json";
+ private static final String FILE_STACK_DELETED_PATH = "openstack/gr_api/Stack_Deleted.json";
@Override
public void run(ScenarioDesigner scenario) {
@@ -31,22 +33,18 @@ public class QueryStackByIdMacro2 extends AbstractSimulatorScenario {
scenario.variable("stackName", "macro_module_2");
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
// Delete
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
// Poll
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
}
}
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro3.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro3.java
index b7808dc2ff..15a6fa3029 100644
--- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro3.java
+++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryStackByIdMacro3.java
@@ -1,22 +1,24 @@
package org.onap.so.simulator.scenarios.openstack.macro;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;
import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
import com.consol.citrus.simulator.scenario.Scenario;
import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
/**
- * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete
+ * This scenario is used by the following test cases: Resume Service Instance Macro 3 Modules 1 To Complete.
*
*/
@Scenario("Openstack-QueryStackByID-Macro3")
@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_3/*", method = RequestMethod.GET)
public class QueryStackByIdMacro3 extends AbstractSimulatorScenario {
+ private static final String FILE_STACK_CREATED_PATH = "openstack/gr_api/Stack_Created.json";
+ private static final String FILE_STACK_DELETED_PATH = "openstack/gr_api/Stack_Deleted.json";
@Override
public void run(ScenarioDesigner scenario) {
@@ -31,22 +33,18 @@ public class QueryStackByIdMacro3 extends AbstractSimulatorScenario {
scenario.variable("stackName", "macro_module_3");
// Poll
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
// Delete
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Created.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_CREATED_PATH));
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
// Poll
scenario.http().receive().get();
- scenario.http().send().response(HttpStatus.OK)
- .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
+ scenario.http().send().response(HttpStatus.OK).payload(new ClassPathResource(FILE_STACK_DELETED_PATH));
}
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/sdnc/grapi/QueryVFModuleGR.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/sdnc/grapi/QueryVFModuleGR.java
index 4e6b15158c..6e5122f6d1 100644
--- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/sdnc/grapi/QueryVFModuleGR.java
+++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/sdnc/grapi/QueryVFModuleGR.java
@@ -1,12 +1,13 @@
package org.onap.so.simulator.scenarios.sdnc.grapi;
+import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
+import com.consol.citrus.simulator.scenario.Scenario;
+import com.consol.citrus.simulator.scenario.ScenarioDesigner;
+import java.security.SecureRandom;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
-import com.consol.citrus.simulator.scenario.Scenario;
-import com.consol.citrus.simulator.scenario.ScenarioDesigner;
@Scenario("SDNC-GRAPI-QueryVFModule")
@RequestMapping(
@@ -17,7 +18,7 @@ public class QueryVFModuleGR extends AbstractSimulatorScenario {
@Override
public void run(ScenarioDesigner scenario) {
scenario.http().receive().get();
- int random = (int) (Math.random() * 50 + 1);
+ int random = (new SecureRandom()).nextInt(50) + 1;
scenario.variable("vfModuleName", "vfModuleName" + random);