aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/resources/http-cache
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-04-08 18:32:26 +0200
committersebdet <sebastien.determe@intl.att.com>2019-04-08 18:32:26 +0200
commit919ef9dc0a2f392868533e498897b12fe0faa321 (patch)
treef89f90164905eb593508a24248c127204bf9a6d9 /src/test/resources/http-cache
parentef6583ce9b1d007ee6a43048f49a63067383a7ad (diff)
Create submit route
Create required components for Submit route in camel + unit tests + Policy payload generation + emulator feature for new policy api Issue-ID: CLAMP-303 Change-Id: If9033cfa3f4e346e2cbd7f891baff1f2c04a40a2 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test/resources/http-cache')
-rwxr-xr-xsrc/test/resources/http-cache/third_party_proxy.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/test/resources/http-cache/third_party_proxy.py b/src/test/resources/http-cache/third_party_proxy.py
index 30f510752..f19aa0da4 100755
--- a/src/test/resources/http-cache/third_party_proxy.py
+++ b/src/test/resources/http-cache/third_party_proxy.py
@@ -171,7 +171,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
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"):
+ 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):
os.makedirs(cached_file_folder, 0777)
@@ -180,6 +180,25 @@ 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":
+ 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)
+ 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
+ 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)
+
+ 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
else:
return False
@@ -337,7 +356,10 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
cached_file_header=""
print("\n\n\nGot a DELETE for %s " % self.path)
self.check_credentials()
- self.data_string = self.rfile.read(int(self.headers['Content-Length']))
+ if self.headers.get('Content-Length') is not None:
+ self.data_string = self.rfile.read(int(self.headers['Content-Length']))
+ else:
+ self.data_string = "empty generated"
print("self.headers:\n %s" % self.headers)
is_special = self._execute_content_generated_cases("DELETE")