From d58008833b84ea08de8497d30f5d36ae8d54a6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20=D0=9C=D0=B0=D1=81=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2?= Date: Tue, 25 Oct 2022 18:25:58 +0300 Subject: [PATCH] test --- .../pyOpenRPA/Orchestrator/ServerSettings.py | 23 ++++++++++--------- .../Orchestrator/__Orchestrator__.py | 1 + 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py index 1d36fcad..8eb8f5b4 100755 --- a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py +++ b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py @@ -36,19 +36,20 @@ import asyncio # v 1.2.0 Functionallity # # # # # # # # # # # # # Generate JS when page init -def HiddenJSInitGenerate(inRequest, inGSettings): - dUAC = inRequest.UACClientCheck # Alias. +def HiddenJSInitGenerate(inAuthTokenStr): + inGSettings = __Orchestrator__.GSettingsGet() + dUAC = lambda inKeyList: __Orchestrator__.WebUserUACCheck(inAuthTokenStr=inAuthTokenStr, inKeyList=inKeyList) lUACCPTemplateKeyList=["pyOpenRPADict","CPKeyDict"] lL = inGSettings["Logger"] # Alias for logger lJSInitResultStr = "" lRenderFunctionsRobotDict = inGSettings["ServerDict"]["ControlPanelDict"] for lItemKeyStr in lRenderFunctionsRobotDict: lItemDict = lRenderFunctionsRobotDict[lItemKeyStr] - lUACBool = dUAC(inRoleKeyList=lUACCPTemplateKeyList+[lItemKeyStr]) # Check if render function is applicable User Access Rights (UAC) + lUACBool = dUAC(inKeyList=lUACCPTemplateKeyList+[lItemKeyStr]) # Check if render function is applicable User Access Rights (UAC) if lItemKeyStr=="VersionCheck": lUACBool=True # For backward compatibility for the old fron version which not reload page when new orch version is comming if lUACBool: # Run function if UAC is TRUE # JSONGeneratorDef - lJSInitResultStr = lJSInitResultStr + ";" + lItemDict.OnInitJSStr(inRequest=inRequest) + lJSInitResultStr = lJSInitResultStr + ";" + lItemDict.OnInitJSStr(inAuthTokenStr=inAuthTokenStr) return lJSInitResultStr # Generate CP HTML + JSON @@ -135,7 +136,7 @@ def HiddenAgentDictGenerate(inAuthTokenStr): @app.post("/orpa/client/server-data",response_class=JSONResponse, tags=["Client"]) #{"Method": "POST", "URL": "/orpa/client/server-data", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerData, "ResponseContentType": "application/json"}, -async def pyOpenRPA_ServerData(inRequest: Request, inAuthTokenStr:str=Depends(__Orchestrator__.WebAuthDefGet())): +async def pyOpenRPA_ServerData(inRequest: Request, inAuthTokenStr:str=Depends(IdentifyAuthorize)): inGSettings = __Orchestrator__.GSettingsGet() # Extract the hash value from request lValueStr = await inRequest.body() @@ -164,13 +165,13 @@ async def pyOpenRPA_ServerData(inRequest: Request, inAuthTokenStr:str=Depends(__ # GET # /pyOpenRPA/ServerJSInit return JavaScript to init on page -def pyOpenRPA_ServerJSInit(inRequest,inGSettings): - lResultStr = HiddenJSInitGenerate(inRequest=inRequest, inGSettings=inGSettings) - inResponseDict = inRequest.OpenRPAResponseDict +@app.get("/orpa/client/server-js-init",response_class=PlainTextResponse, tags=["Client"]) +def pyOpenRPA_ServerJSInit(inRequest: Request, inAuthTokenStr:str=Depends(IdentifyAuthorize)): + lResultStr = HiddenJSInitGenerate(inAuthTokenStr=inAuthTokenStr) if lResultStr is None: lResultStr = "" # Write content as utf-8 data - inResponseDict["Body"] = bytes(lResultStr, "utf8") + return lResultStr #v1.2.0 Send data container to the client from the server # /pyOpenRPA/ServerLog return {"HashStr" , "ServerLogList": ["row 1", "row 2"]} @@ -191,7 +192,7 @@ async def pyOpenRPA_ServerLog(inRequest: Request, inAuthTokenStr:str=Depends(Ide if lValueStr!=lServerLogListHashStr and lServerLogListHashStr!= "" and lServerLogListHashStr!= None: # Case if Hash is not equal Fix because None can be obtained without JSON decode lFlagDoGenerateBool = False else: # Case Hashes are equal - asyncio.sleep(inGSDict["Client"]["DumpLogListRefreshIntervalSecFloat"]) + await asyncio.sleep(inGSDict["Client"]["DumpLogListRefreshIntervalSecFloat"]) # Return the result if Hash is changed lResult = {"HashStr": lServerLogListHashStr, "ServerLogList": lServerLogList} return lResult @@ -516,7 +517,7 @@ def SettingsUpdate(): {"Method": "POST", "URL": "/orpa/client/user-role-hierarchy-get", "MatchType": "Equal","ResponseDefRequestGlobal": BackwardCompatibility.v1_2_0_UserRoleHierarchyGet, "ResponseContentType": "application/json"}, # New way of the v.1.2.0 functionallity (all defs by the URL from /pyOpenRPA/...) #{"Method": "POST", "URL": "/orpa/client/server-data", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerData, "ResponseContentType": "application/json"}, - {"Method": "GET", "URL": "/orpa/client/server-js-init", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerJSInit, "ResponseContentType": "application/javascript"}, + #{"Method": "GET", "URL": "/orpa/client/server-js-init", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerJSInit, "ResponseContentType": "application/javascript"}, #{"Method": "POST", "URL": "/orpa/client/server-log", "MatchType": "Equal","ResponseDefRequestGlobal": pyOpenRPA_ServerLog, "ResponseContentType": "application/json"}, #{"Method": "GET", "URL": "/orpa/client/screenshot-get", "MatchType": "Equal", "ResponseDefRequestGlobal": pyOpenRPA_Screenshot, "ResponseContentType": "image/png"}, # API diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index 2ce216b2..a04da3ac 100755 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -1118,6 +1118,7 @@ def WebUserUACHierarchyGet(inAuthTokenStr: str=None) -> dict: :type inAuthTokenStr: str, опционально :return: UAC словарь доступа или {}, что означает полный доступ """ + if inAuthTokenStr is None: return {} lDomainUpperStr = WebUserDomainGet(inAuthTokenStr=inAuthTokenStr).upper() lUserUpperStr = WebUserLoginGet(inAuthTokenStr=inAuthTokenStr).upper() if lUserUpperStr is None: return {}