diff options
author | saul.gill <saul.gill@est.tech> | 2021-06-29 12:57:29 +0100 |
---|---|---|
committer | saul.gill <saul.gill@est.tech> | 2021-07-02 12:34:08 +0100 |
commit | c19601d2080baa401cd17286985b6a0ee47d9a07 (patch) | |
tree | e8e69ef79f3ea1ff8bb0d6a3efe7da8a8d88914a /runtime/src/test/resources | |
parent | 7d04c23c7c51738d68f325e450ac408c1ae9905f (diff) |
Added ITs for Commissioning Camel Endpoints
Changed emulator to deal with new endpoint tests
Added spring property to deal with camel endpoint issue
Fixed lingering checkstyle violations
Issue-ID: POLICY-3440
Change-Id: I5810913c4418e7893f3ad848618deec1b1a85a0f
Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'runtime/src/test/resources')
-rw-r--r-- | runtime/src/test/resources/application.properties | 5 | ||||
-rw-r--r-- | runtime/src/test/resources/http-cache/third_party_proxy.py | 61 |
2 files changed, 48 insertions, 18 deletions
diff --git a/runtime/src/test/resources/application.properties b/runtime/src/test/resources/application.properties index 60704acf5..54a89078d 100644 --- a/runtime/src/test/resources/application.properties +++ b/runtime/src/test/resources/application.properties @@ -4,6 +4,7 @@ # ================================================================================ # Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights # reserved. +# Modifications Copyright (C) 2021 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +17,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END============================================ # =================================================================== # @@ -180,6 +183,6 @@ clamp.config.tosca.converter.default.datatypes=classpath:/clds/tosca-converter/d clamp.config.tosca.converter.dictionary.support.enabled=true # Configuration settings for ControlLoop Runtime Rest API -clamp.config.controlloop.runtime.url=http://localhost:6969 +clamp.config.controlloop.runtime.url=http://localhost:${docker.http-cache.port.host} clamp.config.controlloop.runtime.userName=healthcheck clamp.config.controlloop.runtime.password=zb!XztG34 diff --git a/runtime/src/test/resources/http-cache/third_party_proxy.py b/runtime/src/test/resources/http-cache/third_party_proxy.py index 7fe316852..50bd43a35 100644 --- a/runtime/src/test/resources/http-cache/third_party_proxy.py +++ b/runtime/src/test/resources/http-cache/third_party_proxy.py @@ -5,6 +5,7 @@ # ================================================================================ # Copyright (C) 2018 AT&T Intellectual Property. All rights # reserved. +# Modifications Copyright (C) 2021 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +18,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END============================================ # =================================================================== # @@ -94,23 +97,23 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): def _get_cached_file_folder_name(self,folder): cached_file_folder = '%s/%s' % (folder, self.path,) print("Cached file name before escaping : %s" % cached_file_folder) - cached_file_folder = cached_file_folder.replace('<','<').replace('>','>').replace('?','?').replace('*','*').replace('\\','*').replace(':',':').replace('|','|') + cached_file_folder = cached_file_folder.replace('+','').replace('<','<').replace('>','>').replace('?','?').replace('*','*').replace('\\','*').replace(':',':').replace('|','|') print("Cached file name after escaping (used for cache storage) : %s" % cached_file_folder) return cached_file_folder - + def _get_cached_content_file_name(self,cached_file_folder): return "%s/.file" % (cached_file_folder,) - + def _get_cached_header_file_name(self,cached_file_folder): return "%s/.header" % (cached_file_folder,) - + def _execute_content_generated_cases(self,http_type): print("Testing special cases, cache files will be sent to :" +TMP_ROOT) cached_file_folder = self._get_cached_file_folder_name(TMP_ROOT) cached_file_content = self._get_cached_content_file_name(cached_file_folder) cached_file_header = self._get_cached_header_file_name(cached_file_folder) _file_available = os.path.exists(cached_file_content) - + if self.path.startswith("/dcae-service-types?asdcResourceId=") and http_type == "GET": if not _file_available: print "self.path start with /dcae-service-types?asdcResourceId=, generating response json..." @@ -120,7 +123,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): print "typeId generated: " + typeName + " and typeName: "+ typeId jsonGenerated = "{\"totalCount\":1, \"items\":[{\"typeId\":\"" + typeId + "\", \"typeName\":\"" + typeName +"\"}]}" 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\"}") @@ -132,14 +135,14 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): 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: @@ -150,14 +153,14 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): print "self.path start with /dcae-operationstatus/uninstall, generating response json..." jsonGenerated = "{\"operationType\": \"uninstall\", \"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: @@ -169,7 +172,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): jsondata = json.loads(self.data_string) jsonGenerated = "{\"artifactName\":\"" + jsondata['artifactName'] + "\",\"artifactType\":\"" + jsondata['artifactType'] + "\",\"artifactURL\":\"" + self.path + "\",\"artifactDescription\":\"" + jsondata['description'] + "\",\"artifactChecksum\":\"ZjJlMjVmMWE2M2M1OTM2MDZlODlmNTVmZmYzNjViYzM=\",\"artifactUUID\":\"" + str(uuid.uuid4()) + "\",\"artifactVersion\":\"1\"}" 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\"}") @@ -187,7 +190,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}") with open(cached_file_content, 'w+') as f: f.write(jsonGenerated) - return True + 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) @@ -222,7 +225,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): 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) - + 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: @@ -265,10 +268,34 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): with open(cached_file_content, 'w') as f: f.write(response) return True + elif (self.path.startswith("/onap/controlloop/v2/commission/toscaservicetemplate")) and http_type == "GET": + if not _file_available: + cached_file_folder = cached_file_folder.split('bridgeEndpoint')[0] + print ("cached file folder for onap is %s: ", cached_file_folder) + print "self.path start with /onap/controlloop/v2/commission/, generating response json..." + jsonGenerated = "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\"data_types\": {},\"node_types\": {}, \"policy_types\": {}, \"topology_template\": {}, \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}" + 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("/onap/controlloop/v2/commission")) and http_type == "POST": + print "self.path start with POST /onap/controlloop/v2/commission, copying body to response ..." + 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(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 - + def do_GET(self): cached_file_folder = "" cached_file_content ="" @@ -352,7 +379,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): _file_available = os.path.exists(cached_file_content) if not _file_available: - + if not HOST: self.send_response(404) self.end_headers() @@ -492,6 +519,6 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): httpd = SocketServer.ForkingTCPServer(('', PORT), Proxy) httpd.allow_reuse_address = True print "Listening on port "+ str(PORT) + "(Press Ctrl+C/Ctrl+Z to stop HTTPD Caching script)" -print "Caching folder " + CACHE_ROOT + ", Tmp folder for generated files " + TMP_ROOT +print "Caching folder " + CACHE_ROOT + ", Tmp folder for generated files " + TMP_ROOT signal.signal(signal.SIGINT, signal_handler) -httpd.serve_forever()
\ No newline at end of file +httpd.serve_forever() |