aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/resources')
-rwxr-xr-xsrc/test/resources/http-cache/third_party_proxy.py94
-rw-r--r--src/test/resources/https/https-test.properties1
-rw-r--r--src/test/resources/logback.xml2
3 files changed, 77 insertions, 20 deletions
diff --git a/src/test/resources/http-cache/third_party_proxy.py b/src/test/resources/http-cache/third_party_proxy.py
index 0db977bb..0381ab18 100755
--- a/src/test/resources/http-cache/third_party_proxy.py
+++ b/src/test/resources/http-cache/third_party_proxy.py
@@ -127,10 +127,10 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
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:
@@ -145,24 +145,29 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
with open(cached_file_content, 'w') as f:
f.write(jsonGenerated)
return True
- elif self.path.startswith("/sdc/v1/catalog/services/") and http_type == "POST":
+ elif self.path.startswith("/dcae-operationstatus/uninstall") and http_type == "GET":
if not _file_available:
- print "self.path start with /sdc/v1/catalog/services/, generating response json..."
- 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 "self.path start with /dcae-operationstatus/uninstall, generating response json..."
+ jsonGenerated = "{\"operationType\": \"uninstall\", \"status\": \"succeeded\"}"
print "jsonGenerated: " + jsonGenerated
- os.makedirs(cached_file_folder, 0777)
+ 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-deployments/") and (http_type == "PUT" or http_type == "DELETE"):
+ return True
+ elif self.path.startswith("/sdc/v1/catalog/services/") and http_type == "POST":
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 "self.path start with /sdc/v1/catalog/services/, generating response json..."
+ 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)
@@ -171,6 +176,30 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
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 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
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,8 +218,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
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":
- print "self.path start with DELETE new policy API /policy/api/v1/policyTypes/ ..."
+ 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,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
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\"}"
@@ -241,7 +279,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
url = '%s%s' % (HOST, self.path)
response = requests.get(url, auth=AUTH, headers=HEADERS, stream=True)
@@ -254,6 +294,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data currently present in cache: %s" % (cached_file_folder,))
@@ -292,7 +334,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
print("Request for data currently not present in cache: %s" % (cached_file_folder,))
@@ -308,6 +352,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data present in cache: %s" % (cached_file_folder,))
@@ -339,7 +385,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not _file_available:
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
print("Request for data currently not present in cache: %s" % (cached_file_folder,))
@@ -355,6 +403,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data present in cache: %s" % (cached_file_folder,))
@@ -389,7 +439,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not _file_available:
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
print("Request for data currently not present in cache: %s" % (cached_file_folder,))
@@ -405,6 +457,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data present in cache: %s" % (cached_file_folder,))
diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties
index 7614e177..0be9e298 100644
--- a/src/test/resources/https/https-test.properties
+++ b/src/test/resources/https/https-test.properties
@@ -30,6 +30,7 @@ server.port=${clamp.it.tests.https}
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
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 00000000..07e58785
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,2 @@
+<!-- Empty Configuration to prevent creating log files by Units Tests (e.g LoggingUtilsTest) ! -->
+<configuration />