Added Camel Unit Tests 87/125787/2
authorbrunomilitzer <bruno.militzer@est.tech>
Thu, 18 Nov 2021 10:26:50 +0000 (10:26 +0000)
committerbrunomilitzer <bruno.militzer@est.tech>
Thu, 18 Nov 2021 11:35:35 +0000 (11:35 +0000)
Added Camel Unit Tests to test creation of instance properties
Updated credentials for Rest End point

Issue-ID: POLICY-3565
Change-Id: I0899d3052588822f02a8a003eb4bc406bc887713
Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
21 files changed:
common/src/test/resources/demo/config/DEMO.postman_collection.json
common/src/test/resources/demo/config/PolicyAPIConfig.json
common/src/test/resources/demo/config/RuntimeConfig.json
common/src/test/resources/examples/controlloop/PMSH/pmsh.postman2.0_collection.json
common/src/test/resources/examples/controlloop/http-participant/http.postman2.0_collection.json
common/src/test/resources/examples/controlloop/k8s-participant/k8s.postman2.0_collection.json
packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml
participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
participant/participant-impl/participant-impl-policy/src/test/resources/application_test.properties
participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
participant/participant-impl/participant-impl-simulator/src/test/resources/application_test.properties
runtime/src/main/resources/application-noaaf.properties
runtime/src/main/resources/application.properties
runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItTestCase.java
runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeInstantiationResponseItTestCase.java
runtime/src/test/resources/application.properties
runtime/src/test/resources/http-cache/third_party_proxy.py
runtime/src/test/resources/robotframework/robotframework-test.properties
testsuites/performance/src/main/resources/testplans/performance.jmx
testsuites/stability/src/main/resources/testplans/stability.jmx

index 72a8535..31c12bf 100644 (file)
@@ -23,7 +23,7 @@
                                                },
                                                {
                                                        "key": "username",
-                                                       "value": "healthcheck",
+                                                       "value": "runtimeUser",
                                                        "type": "string"
                                                }
                                        ]
@@ -84,7 +84,7 @@
                                                },
                                                {
                                                        "key": "username",
-                                                       "value": "healthcheck",
+                                                       "value": "runtimeUser",
                                                        "type": "string"
                                                }
                                        ]
                                                },
                                                {
                                                        "key": "username",
-                                                       "value": "healthcheck",
+                                                       "value": "runtimeUser",
                                                        "type": "string"
                                                }
                                        ]
                                                },
                                                {
                                                        "key": "username",
-                                                       "value": "healthcheck",
+                                                       "value": "runtimeUser",
                                                        "type": "string"
                                                }
                                        ]
                                                },
                                                {
                                                        "key": "username",
-                                                       "value": "healthcheck",
+                                                       "value": "runtimeUser",
                                                        "type": "string"
                                                }
                                        ]
                                                },
                                                {
                                                        "key": "username",
-                                                       "value": "healthcheck",
+                                                       "value": "runtimeUser",
                                                        "type": "string"
                                                }
                                        ]
index 48e89c5..dbe00a1 100644 (file)
@@ -3,7 +3,7 @@
     "restServerParameters": {
         "host": "0.0.0.0",
         "port": 6968,
-        "userName": "healthcheck",
+        "userName": "policyadmin",
         "password": "zb!XztG34",
         "https": false,
         "aaf": false
index 529557e..fd8948a 100644 (file)
@@ -3,7 +3,7 @@
     "restServerParameters": {
         "host": "0.0.0.0",
         "port": 6969,
-        "userName": "healthcheck",
+        "userName": "runtimeUser",
         "password": "zb!XztG34",
         "https": false,
         "aaf": false
index b31c8ca..6efddc2 100644 (file)
   "auth": {
     "type": "basic",
     "basic": {
-      "username": "healthcheck",
+      "username": "runtimeUser",
       "password": "zb!XztG34"
     }
   }
index b357ae4..14660a9 100644 (file)
@@ -11,7 +11,7 @@ participant:
     clientName: api
     hostname: policy-api
     port: 6969
-    userName: healthcheck
+    userName: policyadmin
     password: zb!XztG34
     useHttps: true
     allowSelfSignedCerts: true
@@ -19,7 +19,7 @@ participant:
     clientName: pap
     hostname: policy-pap
     port: 6969
-    userName: healthcheck
+    userName: policyadmin
     password: zb!XztG34
     useHttps: true
     allowSelfSignedCerts: true
index 5839aae..2aa33c1 100644 (file)
@@ -11,7 +11,7 @@ participant:
     clientName: api
     hostname: policy-api
     port: 6969
-    userName: healthcheck
+    userName: policyadmin
     password: zb!XztG34
     useHttps: true
     allowSelfSignedCerts: true
@@ -19,7 +19,7 @@ participant:
     clientName: pap
     hostname: policy-pap
     port: 6969
-    userName: healthcheck
+    userName: policyadmin
     password: zb!XztG34
     useHttps: true
     allowSelfSignedCerts: true
index 41af8a6..e965370 100644 (file)
@@ -84,7 +84,7 @@ public class CommonTestData {
         map.put("clientName", "pap");
         map.put("hostname", "localhost");
         map.put("port", 6968);
-        map.put("userName", "healthcheck");
+        map.put("userName", "policyadmin");
         map.put("password", "zb!XztG34");
         map.put("https", false);
         map.put("allowSelfSignedCerts", true);
@@ -101,7 +101,7 @@ public class CommonTestData {
         map.put("clientName", "api");
         map.put("hostname", "localhost");
         map.put("port", 6969);
-        map.put("userName", "healthcheck");
+        map.put("userName", "policyadmin");
         map.put("password", "zb!XztG34");
         map.put("https", false);
         map.put("allowSelfSignedCerts", true);
index f857704..4978140 100644 (file)
@@ -7,7 +7,7 @@ server.http-port=8085
 participant.policyApiParameters.clientName=api
 participant.policyApiParameters.hostname=localhost
 participant.policyApiParameters.port=6969
-participant.policyApiParameters.userName=healthcheck
+participant.policyApiParameters.userName=policyadmin
 participant.policyApiParameters.password=zb!XztG34
 participant.policyApiParameters.https=false
 participant.policyApiParameters.allowSelfSignedCerts=true
index f162367..a4a1f99 100644 (file)
@@ -1,4 +1,4 @@
-spring.security.user.name=healthcheck
+spring.security.user.name=runtimeUser
 spring.security.user.password=zb!XztG34
 
 server.servlet.context-path=/onap/participantsim
@@ -6,7 +6,7 @@ server.error.path=/error
 
 participant.restServerParameters.host=0.0.0.0
 participant.restServerParameters.port=6969
-participant.restServerParameters.userName=healthcheck
+participant.restServerParameters.userName=runtimeUser
 participant.restServerParameters.password=zb!XztG34
 participant.restServerParameters.https=false
 participant.restServerParameters.aaf=false
index 12a0870..9f13a31 100644 (file)
@@ -150,10 +150,10 @@ clamp.config.httpclient.connectTimeout=10000
 #
 # Configuration Settings for Policy Engine Components
 clamp.config.policy.api.url=http://localhost:8085
-clamp.config.policy.api.userName=healthcheck
+clamp.config.policy.api.userName=policyadmin
 clamp.config.policy.api.password=zb!XztG34
 clamp.config.policy.pap.url=http://localhost:8085
-clamp.config.policy.pap.userName=healthcheck
+clamp.config.policy.pap.userName=policyadmin
 clamp.config.policy.pap.password=zb!XztG34
 
 #
@@ -194,5 +194,5 @@ clamp.config.cds.password=ccsdkapps
 
 # Configuration settings for ControlLoop Runtime Rest API
 clamp.config.controlloop.runtime.url=http://localhost:6969
-clamp.config.controlloop.runtime.userName=healthcheck
+clamp.config.controlloop.runtime.userName=runtimeUser
 clamp.config.controlloop.runtime.password=zb!XztG34
index 0826004..21b37c6 100644 (file)
@@ -149,10 +149,10 @@ clamp.config.httpclient.connectTimeout=10000
 #
 # Configuration Settings for Policy Engine Components
 clamp.config.policy.api.url=http://policy.api.simpledemo.onap.org:6969
-clamp.config.policy.api.userName=healthcheck
+clamp.config.policy.api.userName=policyadmin
 clamp.config.policy.api.password=zb!XztG34
 clamp.config.policy.pap.url=http://policy.api.simpledemo.onap.org:6969
-clamp.config.policy.pap.userName=healthcheck
+clamp.config.policy.pap.userName=policyadmin
 clamp.config.policy.pap.password=zb!XztG34
 
 #
@@ -204,5 +204,5 @@ clamp.config.cds.password=ccsdkapps
 
 # Configuration settings for ControlLoop Runtime Rest API
 clamp.config.controlloop.runtime.url=http://localhost:6969
-clamp.config.controlloop.runtime.userName=healthcheck
+clamp.config.controlloop.runtime.userName=runtimeUser
 clamp.config.controlloop.runtime.password=zb!XztG34
index eeed51c..79f3b12 100644 (file)
@@ -46,7 +46,7 @@ public class CldsReferencePropertiesItTestCase {
      */
     @Test
     public void testGetStringValue() {
-        assertEquals("healthcheck", refProp.getStringValue("policy.api.userName"));
+        assertEquals("policyadmin", refProp.getStringValue("policy.api.userName"));
     }
 
     /**
index ae80d04..fdb815d 100644 (file)
@@ -41,6 +41,8 @@ public class RuntimeInstantiationResponseItTestCase {
 
     private static final String DIRECT_GET_TOSCA_INSTANTIATION = "direct:get-tosca-instantiation";
 
+    private static final String DIRECT_POST_TOSCA_INSTANTANCE_PROPERTIES = "direct:post-tosca-instance-properties";
+
     private static final String SERVICE_TEMPLATE_NAME = "name";
 
     private static final String SERVICE_TEMPLATE_VERSION = "version";
@@ -51,6 +53,12 @@ public class RuntimeInstantiationResponseItTestCase {
         + "\"version\": \"1.0.1\",\"definition\": {},\"state\": \"UNINITIALISED\",\"orderedState\": \"UNINITIALISED\","
         + "\"description\": \"PMSH control loop instance 0\",\"elements\": {}}]}";
 
+    private static final String SAMPLE_TOSCA_TEMPLATE =
+        "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\","
+            + "\"data_types\": {},\"node_types\": {}, \"policy_types\": {},"
+            + " \"topology_template\": {},"
+            + " \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}";
+
     @Test
     public void testToscaServiceTemplateStatus() {
         ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
@@ -93,4 +101,18 @@ public class RuntimeInstantiationResponseItTestCase {
         assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
             .is2xxSuccessful()).isTrue();
     }
+
+    @Test
+    public void testCommissioningOfToscaServiceTemplateStatus() {
+        ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+        Exchange exchangeResponse =
+            prodTemplate.send(DIRECT_POST_TOSCA_INSTANTANCE_PROPERTIES, ExchangeBuilder.anExchange(camelContext)
+                .withBody(SAMPLE_TOSCA_TEMPLATE)
+                .withProperty("raiseHttpExceptionFlag", "true")
+                .build());
+
+        assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+            .is2xxSuccessful()).isTrue();
+    }
 }
index bc0c290..f2cf0dd 100644 (file)
@@ -139,10 +139,10 @@ clamp.config.httpclient.connectTimeout=10000
 #
 # Configuration Settings for Policy Engine Components
 clamp.config.policy.api.url=http://localhost:${docker.http-cache.port.host}
-clamp.config.policy.api.userName=healthcheck
+clamp.config.policy.api.userName=policyadmin
 clamp.config.policy.api.password=zb!XztG34
 clamp.config.policy.pap.url=http://localhost:${docker.http-cache.port.host}
-clamp.config.policy.pap.userName=healthcheck
+clamp.config.policy.pap.userName=policyadmin
 clamp.config.policy.pap.password=zb!XztG34
 
 # Sdc service properties
@@ -183,5 +183,5 @@ clamp.config.tosca.converter.dictionary.support.enabled=true
 
 # Configuration settings for ControlLoop Runtime Rest API
 clamp.config.controlloop.runtime.url=http://localhost:${docker.http-cache.port.host}
-clamp.config.controlloop.runtime.userName=healthcheck
+clamp.config.controlloop.runtime.userName=runtimeUser
 clamp.config.controlloop.runtime.password=zb!XztG34
index 5c80cdd..67af214 100644 (file)
@@ -331,6 +331,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
          jsonGenerated = "{\"controlLoopList\": [{\"name\": \"PMSHInstance0\",\"version\": \"1.0.1\",\"definition\": {},\"state\": \"UNINITIALISED\",\"orderedState\": \"UNINITIALISED\",\"description\": \"PMSH control loop instance 0\",\"elements\": {}}]}";
          self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
          return True
+     elif (self.path.startswith("/onap/controlloop/v2/instanceProperties")) and http_type == "POST":
+         print("self.path start with POST /onap/controlloop/v2/instanceProperties, copying body to response ...")
+         if not os.path.exists(cached_file_folder):
+             os.makedirs(cached_file_folder, 0o777)
+         with open(cached_file_header, 'w+') as f:
+             f.write("{\"Content-Length\": \"" + str(len(self.data_string)) + "\", \"Content-Type\": \""+str(self.headers['Content-Type'])+"\"}")
+         with open(cached_file_content, 'w+') as f:
+             f.write(self.data_string)
+         return True
      else:
         return False
 
index 499719a..493c83c 100644 (file)
@@ -136,10 +136,10 @@ clamp.config.httpclient.connectTimeout=10000
 #
 # Configuration Settings for Policy Engine Components
 clamp.config.policy.api.url=http://localhost:${docker.http-cache.port.host}
-clamp.config.policy.api.userName=healthcheck
+clamp.config.policy.api.userName=policyadmin
 clamp.config.policy.api.password=zb!XztG34
 clamp.config.policy.pap.url=http://localhost:${docker.http-cache.port.host}
-clamp.config.policy.pap.userName=healthcheck
+clamp.config.policy.pap.userName=policyadmin
 clamp.config.policy.pap.password=zb!XztG34
 
 # Sdc service properties
index bb0cfc9..6b651a9 100644 (file)
@@ -57,7 +57,7 @@
         <collectionProp name="AuthManager.auth_list">
           <elementProp name="" elementType="Authorization">
             <stringProp name="Authorization.url">https://${RUNTIME_HOST}:${RUNTIME_PORT}/onap/controlloop/v2</stringProp>
-            <stringProp name="Authorization.username">healthcheck</stringProp>
+            <stringProp name="Authorization.username">runtimeUser</stringProp>
             <stringProp name="Authorization.password">zb!XztG34</stringProp>
             <stringProp name="Authorization.domain"></stringProp>
             <stringProp name="Authorization.realm"></stringProp>
index 32bb360..b5929c1 100644 (file)
@@ -37,7 +37,7 @@
         <collectionProp name="AuthManager.auth_list">
           <elementProp name="" elementType="Authorization">
             <stringProp name="Authorization.url">https://${RUNTIME_HOST}:${RUNTIME_PORT}/onap/controlloop/v2</stringProp>
-            <stringProp name="Authorization.username">healthcheck</stringProp>
+            <stringProp name="Authorization.username">runtimeUser</stringProp>
             <stringProp name="Authorization.password">zb!XztG34</stringProp>
             <stringProp name="Authorization.domain"></stringProp>
             <stringProp name="Authorization.realm"></stringProp>