Rework the loop state

Rework the state loop so there is no bug in the loop state anymore, now
the components are scanned + upgrade to 4.0.4

Issue-ID: CLAMP-384
Change-Id: If7649238ee52864c84bfb9b6b8471d1738752e29
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
diff --git a/src/test/resources/http-cache/third_party_proxy.py b/src/test/resources/http-cache/third_party_proxy.py
index 0db977b..ce61ea0 100755
--- a/src/test/resources/http-cache/third_party_proxy.py
+++ b/src/test/resources/http-cache/third_party_proxy.py
@@ -127,10 +127,28 @@
             with open(cached_file_content, 'w') as f:
                 f.write(jsonGenerated)
         return True
-     elif self.path.startswith("/dcae-operationstatus") and http_type == "GET":
+     elif self.path.startswith("/dcae-operationstatus/install") and http_type == "GET":
         if not _file_available:
-            print "self.path start with /dcae-operationstatus, generating response json..."
-            jsonGenerated =  "{\"operationType\": \"operationType1\", \"status\": \"succeeded\"}"
+            print "self.path start with /dcae-operationstatus/install, generating response json..."
+            jsonGenerated =  "{\"operationType\": \"install\", \"status\": \"succeeded\"}"
+            print "jsonGenerated: " + jsonGenerated
+    
+            try:
+                os.makedirs(cached_file_folder, 0777)
+            except OSError as e:
+                if e.errno != errno.EEXIST:
+                    raise
+                print(cached_file_folder+" already exists")
+    
+            with open(cached_file_header, 'w') as f:
+                f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+            with open(cached_file_content, 'w') as f:
+                f.write(jsonGenerated)
+        return True
+     elif self.path.startswith("/dcae-operationstatus/uninstall") and http_type == "GET":
+        if not _file_available:
+            print "self.path start with /dcae-operationstatus/uninstall, generating response json..."
+            jsonGenerated =  "{\"operationType\": \"uninstall\", \"status\": \"succeeded\"}"
             print "jsonGenerated: " + jsonGenerated
     
             try:
@@ -157,20 +175,31 @@
                 f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
             with open(cached_file_content, 'w') as f:
                 f.write(jsonGenerated)
-        return True;
-     elif self.path.startswith("/dcae-deployments/") and (http_type == "PUT" or http_type == "DELETE"):
-        if not _file_available:
-            print "self.path start with /dcae-deployments/, generating response json..."
-            #jsondata = json.loads(self.data_string)
-            jsonGenerated = "{\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus\",\"test2\":\"test2\"}}"
-            print "jsonGenerated: " + jsonGenerated
-    
-            os.makedirs(cached_file_folder, 0777)
-            with open(cached_file_header, 'w') as f:
-                f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
-            with open(cached_file_content, 'w') as f:
-                f.write(jsonGenerated)
         return True
+     elif self.path.startswith("/dcae-deployments/") and http_type == "PUT":
+            print "self.path start with /dcae-deployments/ DEPLOY, generating response json..."
+            #jsondata = json.loads(self.data_string)
+            jsonGenerated = "{\"operationType\":\"install\",\"status\":\"processing\",\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus/install\"}}"
+            print "jsonGenerated: " + jsonGenerated
+            if not os.path.exists(cached_file_folder):
+                os.makedirs(cached_file_folder, 0777)
+            with open(cached_file_header, 'w+') as f:
+                f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+            with open(cached_file_content, 'w+') as f:
+                f.write(jsonGenerated)
+        	return True
+     elif self.path.startswith("/dcae-deployments/") and http_type == "DELETE":
+            print "self.path start with /dcae-deployments/ UNDEPLOY, generating response json..."
+            #jsondata = json.loads(self.data_string)
+            jsonGenerated = "{\"operationType\":\"uninstall\",\"status\":\"processing\",\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus/uninstall\"}}"
+            print "jsonGenerated: " + jsonGenerated
+            if not os.path.exists(cached_file_folder):
+                os.makedirs(cached_file_folder, 0777)
+            with open(cached_file_header, 'w+') as f:
+                f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+            with open(cached_file_content, 'w+') as f:
+                f.write(jsonGenerated)
+            return True
      elif (self.path.startswith("/pdp/api/") and (http_type == "PUT" or http_type == "DELETE")) or (self.path.startswith("/pdp/api/policyEngineImport") and http_type == "POST"):
         print "self.path start with /pdp/api/, copying body to response ..."
         if not os.path.exists(cached_file_folder):
@@ -180,7 +209,7 @@
         with open(cached_file_content, 'w+') as f:
             f.write(self.data_string)
         return True
-     elif self.path.startswith("/policy/api/v1/policyTypes/") and http_type == "POST":
+     elif self.path.startswith("/policy/api/v1/policytypes/") and http_type == "POST":
         print "self.path start with POST new policy API /pdp/api/, copying body to response ..."
         if not os.path.exists(cached_file_folder):
             os.makedirs(cached_file_folder, 0777)
@@ -189,7 +218,7 @@
         with open(cached_file_content, 'w+') as f:
             f.write(self.data_string)
         return True
-     elif self.path.startswith("/policy/api/v1/policyTypes/") and http_type == "DELETE":
+     elif self.path.startswith("/policy/api/v1/policytypes/") and http_type == "DELETE":
         print "self.path start with DELETE new policy API /policy/api/v1/policyTypes/ ..."
         if not os.path.exists(cached_file_folder):
             os.makedirs(cached_file_folder, 0777)
@@ -199,6 +228,16 @@
         with open(cached_file_content, 'w+') as f:
                 f.write(self.data_string)
         return True
+     elif self.path.startswith("/policy/pap/v1/pdps/policies") and http_type == "POST":
+        print "self.path start with POST new policy API /policy/pap/v1/pdps/ ..."
+        if not os.path.exists(cached_file_folder):
+            os.makedirs(cached_file_folder, 0777)
+    
+        with open(cached_file_header, 'w+') as f:
+                f.write("{\"Content-Length\": \"" + str(len("")) + "\", \"Content-Type\": \""+str("")+"\"}")
+        with open(cached_file_content, 'w+') as f:
+                f.write(self.data_string)
+        return True
      elif self.path.startswith("/policy/api/v1/policytypes/") and http_type == "GET":
         print "self.path start with /policy/api/v1/policytypes/, generating response json..."
         jsonGenerated =  "{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}"
diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties
index 7614e17..0be9e29 100644
--- a/src/test/resources/https/https-test.properties
+++ b/src/test/resources/https/https-test.properties
@@ -30,6 +30,7 @@
 server.ssl.key-store=classpath:https/keystore-test.jks
 server.ssl.key-store-password=testpass
 server.ssl.key-password=testpass
+server.ssl.key-store-type=JKS
 
 ### In order to be user friendly when HTTPS is enabled, 
 ### you can add another HTTP port that will be automatically redirected to HTTPS