|
|
@ -101,6 +101,8 @@ def AuthenticateVerify(inRequest):
|
|
|
|
#Set-cookie
|
|
|
|
#Set-cookie
|
|
|
|
inRequest.OpenRPA["AuthToken"] = lAuthToken
|
|
|
|
inRequest.OpenRPA["AuthToken"] = lAuthToken
|
|
|
|
inRequest.OpenRPASetCookie = {}
|
|
|
|
inRequest.OpenRPASetCookie = {}
|
|
|
|
|
|
|
|
#New engine of server
|
|
|
|
|
|
|
|
inRequest.OpenRPAResponseDict["SetCookies"]["AuthToken"] = lAuthToken
|
|
|
|
#inRequest.OpenRPAResponse["Set-Cookie"]=[]lResult["Set-Cookie"] = lAuthToken
|
|
|
|
#inRequest.OpenRPAResponse["Set-Cookie"]=[]lResult["Set-Cookie"] = lAuthToken
|
|
|
|
#pdb.set_trace()
|
|
|
|
#pdb.set_trace()
|
|
|
|
#inRequest.send_header("Set-Cookie:", f"AuthToken={lAuthToken}")
|
|
|
|
#inRequest.send_header("Set-Cookie:", f"AuthToken={lAuthToken}")
|
|
|
@ -204,11 +206,14 @@ def UserAccessCheckBefore(inMethod, inRequest):
|
|
|
|
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
#Tech def
|
|
|
|
#Tech def
|
|
|
|
#return {"headers":[],"body":"","statuscode":111}
|
|
|
|
#return {"headers":[],"body":"","statuscode":111}
|
|
|
|
def URLItemCheckDo(self, inURLItem, inMethod, inResponseDict):
|
|
|
|
def URLItemCheckDo(self, inURLItem, inMethod):
|
|
|
|
###############################
|
|
|
|
###############################
|
|
|
|
#Tech sub def - do item
|
|
|
|
#Tech sub def - do item
|
|
|
|
################################
|
|
|
|
################################
|
|
|
|
def URLItemDo(inURLItem,inRequest,inGlobalDict,inResponseDict):
|
|
|
|
def URLItemDo(inURLItem,inRequest,inGlobalDict):
|
|
|
|
|
|
|
|
inResponseDict = inRequest.OpenRPAResponseDict
|
|
|
|
|
|
|
|
#Set status code 200
|
|
|
|
|
|
|
|
inResponseDict["StatusCode"] = 200
|
|
|
|
#Content-type
|
|
|
|
#Content-type
|
|
|
|
if "ResponseContentType" in inURLItem:
|
|
|
|
if "ResponseContentType" in inURLItem:
|
|
|
|
inResponseDict["Headers"]["Content-type"] = inURLItem["ResponseContentType"]
|
|
|
|
inResponseDict["Headers"]["Content-type"] = inURLItem["ResponseContentType"]
|
|
|
@ -221,7 +226,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
lFileObject.close()
|
|
|
|
lFileObject.close()
|
|
|
|
#If function is set
|
|
|
|
#If function is set
|
|
|
|
if "ResponseDefRequestGlobalResponse" in inURLItem:
|
|
|
|
if "ResponseDefRequestGlobalResponse" in inURLItem:
|
|
|
|
inURLItem["ResponseDefRequestGlobalResponse"](inRequest,inGlobalDict,inResponseDict)
|
|
|
|
inURLItem["ResponseDefRequestGlobal"](inRequest,inGlobalDict)
|
|
|
|
# TODO If folder path is set
|
|
|
|
# TODO If folder path is set
|
|
|
|
if "ResponseFolderPath" in inURLItem:
|
|
|
|
if "ResponseFolderPath" in inURLItem:
|
|
|
|
#
|
|
|
|
#
|
|
|
@ -233,24 +238,24 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
lURLPath = self.path
|
|
|
|
lURLPath = self.path
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
if lURLPath.startswith(inURLItem["URL"].upper()):
|
|
|
|
if lURLPath.startswith(inURLItem["URL"].upper()):
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict,inResponseDict)
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
# check Match type variant: Contains
|
|
|
|
# check Match type variant: Contains
|
|
|
|
elif inURLItem["MatchType"].upper() == "CONTAINS":
|
|
|
|
elif inURLItem["MatchType"].upper() == "CONTAINS":
|
|
|
|
lURLPath = self.path
|
|
|
|
lURLPath = self.path
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
if lURLPath.contains(inURLItem["URL"].upper()):
|
|
|
|
if lURLPath.contains(inURLItem["URL"].upper()):
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict,inResponseDict)
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
# check Match type variant: Equal
|
|
|
|
# check Match type variant: Equal
|
|
|
|
elif inURLItem["MatchType"].upper() == "EQUAL":
|
|
|
|
elif inURLItem["MatchType"].upper() == "EQUAL":
|
|
|
|
if inURLItem["URL"].upper() == self.path.upper():
|
|
|
|
if inURLItem["URL"].upper() == self.path.upper():
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict,inResponseDict)
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
# check Match type variant: EqualCase
|
|
|
|
# check Match type variant: EqualCase
|
|
|
|
elif inURLItem["MatchType"].upper() == "EQUALCASE":
|
|
|
|
elif inURLItem["MatchType"].upper() == "EQUALCASE":
|
|
|
|
if inURLItem["URL"] == self.path:
|
|
|
|
if inURLItem["URL"] == self.path:
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict,inResponseDict)
|
|
|
|
URLItemDo(inURLItem, self, mGlobalDict)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
#ResponseContentTypeFile
|
|
|
|
#ResponseContentTypeFile
|
|
|
@ -269,20 +274,24 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
#Закрыть файловый объект
|
|
|
|
#Закрыть файловый объект
|
|
|
|
lFileObject.close()
|
|
|
|
lFileObject.close()
|
|
|
|
# ResponseContentTypeFile
|
|
|
|
# ResponseContentTypeFile
|
|
|
|
def ResponseDictSend(self, inResponseDict):
|
|
|
|
def ResponseDictSend(self):
|
|
|
|
|
|
|
|
inResponseDict = self.OpenRPAResponseDict
|
|
|
|
# Send response status code
|
|
|
|
# Send response status code
|
|
|
|
self.send_response(inResponseDict["StatusCode"])
|
|
|
|
self.send_response(inResponseDict["StatusCode"])
|
|
|
|
# Send headers
|
|
|
|
# Send headers
|
|
|
|
for lItemKey, lItemValue in inResponseDict["Headers"].items():
|
|
|
|
for lItemKey, lItemValue in inResponseDict["Headers"].items():
|
|
|
|
self.send_header(lItemKey, lItemValue)
|
|
|
|
self.send_header(lItemKey, lItemValue)
|
|
|
|
|
|
|
|
# Send headers: Set-Cookie
|
|
|
|
|
|
|
|
for lItemKey, lItemValue in inResponseDict["SetCookies"].items():
|
|
|
|
|
|
|
|
self.send_header("Set-Cookie", f"{lItemKey}={lItemValue}")
|
|
|
|
#Close headers section in response
|
|
|
|
#Close headers section in response
|
|
|
|
self.end_headers()
|
|
|
|
self.end_headers()
|
|
|
|
# Write content as utf-8 data
|
|
|
|
# Write content as utf-8 data
|
|
|
|
self.wfile.write(inResponseDict["Body"])
|
|
|
|
self.wfile.write(inResponseDict["Body"])
|
|
|
|
# GET
|
|
|
|
|
|
|
|
def do_GET(self):
|
|
|
|
def do_GET(self):
|
|
|
|
# Prepare result dict
|
|
|
|
# Prepare result dict
|
|
|
|
lResponseDict = {"Headers": {}, "Set-cookies":{}, "Body": "", "StatusCode": None}
|
|
|
|
lResponseDict = {"Headers": {}, "SetCookies":{}, "Body": "", "StatusCode": None}
|
|
|
|
|
|
|
|
self.OpenRPAResponseDict = lResponseDict
|
|
|
|
#####################################
|
|
|
|
#####################################
|
|
|
|
#Do authentication
|
|
|
|
#Do authentication
|
|
|
|
#Check if authentication is turned on
|
|
|
|
#Check if authentication is turned on
|
|
|
@ -309,38 +318,15 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
############################
|
|
|
|
############################
|
|
|
|
#New server engine (url from global dict (URLList))
|
|
|
|
#New server engine (url from global dict (URLList))
|
|
|
|
############################
|
|
|
|
############################
|
|
|
|
for lURLItem in mGlobalDict["URLList"]:
|
|
|
|
for lURLItem in mGlobalDict["Server"]["URLList"]:
|
|
|
|
#Check if all condition are applied
|
|
|
|
#Check if all condition are applied
|
|
|
|
lFlagURLIsApplied=False
|
|
|
|
lFlagURLIsApplied=False
|
|
|
|
lFlagURLIsApplied=self.URLItemCheckDo(lURLItem, "GET", lResponseDict)
|
|
|
|
lFlagURLIsApplied=self.URLItemCheckDo(lURLItem, "GET")
|
|
|
|
if lFlagURLIsApplied:
|
|
|
|
if lFlagURLIsApplied:
|
|
|
|
self.ResponseDictSend(lResponseDict)
|
|
|
|
print("New engine")
|
|
|
|
|
|
|
|
self.ResponseDictSend()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
###################################################
|
|
|
|
###################################################
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == "/":
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('text/html', os.path.join(lOrchestratorFolder, "Web\\Index.xhtml"))
|
|
|
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == '/3rdParty/Semantic-UI-CSS-master/semantic.min.css':
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('text/css', os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.css"))
|
|
|
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == '/3rdParty/Semantic-UI-CSS-master/semantic.min.js':
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript', os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Semantic-UI-CSS-master\\semantic.min.js"))
|
|
|
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == '/3rdParty/jQuery/jquery-3.1.1.min.js':
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript', os.path.join(lOrchestratorFolder,"..\\Resources\\Web\\jQuery\\jquery-3.1.1.min.js"))
|
|
|
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == '/3rdParty/Google/LatoItalic.css':
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('font/css', os.path.join(lOrchestratorFolder, "..\\Resources\\Web\\Google\\LatoItalic.css"))
|
|
|
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == '/3rdParty/Semantic-UI-CSS-master/themes/default/assets/fonts/icons.woff2':
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('font/woff2', os.path.join(lOrchestratorFolder,"..\\Resources\\Web\\Semantic-UI-CSS-master\\themes\\default\\assets\\fonts\\icons.woff2"))
|
|
|
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == '/favicon.ico':
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('image/x-icon', os.path.join(lOrchestratorFolder, "Web\\favicon.ico"))
|
|
|
|
|
|
|
|
#Мост между файлом и http запросом (новый формат)
|
|
|
|
|
|
|
|
if self.path == '/3rdParty/Handlebars/handlebars-v4.1.2.js':
|
|
|
|
|
|
|
|
self.SendResponseContentTypeFile('application/javascript', os.path.join(lOrchestratorFolder,"..\\Resources\\Web\\Handlebars\\handlebars-v4.1.2.js"))
|
|
|
|
|
|
|
|
#Получить скриншот
|
|
|
|
#Получить скриншот
|
|
|
|
if self.path.split("?")[0] == '/GetScreenshot':
|
|
|
|
if self.path.split("?")[0] == '/GetScreenshot':
|
|
|
|
#Сохранить файл на диск
|
|
|
|
#Сохранить файл на диск
|
|
|
@ -389,6 +375,9 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
self.end_headers()
|
|
|
|
self.end_headers()
|
|
|
|
# POST
|
|
|
|
# POST
|
|
|
|
def do_POST(self):
|
|
|
|
def do_POST(self):
|
|
|
|
|
|
|
|
# Prepare result dict
|
|
|
|
|
|
|
|
lResponseDict = {"Headers": {}, "SetCookies":{}, "Body": "", "StatusCode": None}
|
|
|
|
|
|
|
|
self.OpenRPAResponseDict = lResponseDict
|
|
|
|
#####################################
|
|
|
|
#####################################
|
|
|
|
#Do authentication
|
|
|
|
#Do authentication
|
|
|
|
#Check if authentication is turned on
|
|
|
|
#Check if authentication is turned on
|
|
|
|