Skip to content

Commit c376e69

Browse files
authored
Merge pull request #403 from AutomationSolutionz/auth
Authentication System 2.0
2 parents 5d1af8c + 324d875 commit c376e69

10 files changed

Lines changed: 350 additions & 437 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ AutomationLog/
2525
iosSimulator/*
2626
node_state.json
2727
*.zvt
28+
Framework/session.bin
29+
session.bin
2830

2931
# Nodejs gitignore
3032
# Logs

.vscode/launch.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,38 @@
1515
"type": "python",
1616
"request": "launch",
1717
"program": "${file}",
18-
"console": "internalConsole",
19-
"internalConsoleOptions": "openOnSessionStart"
18+
"console": "integratedTerminal",
2019
},
2120
{
2221
"name": "Python: node_cli",
2322
"type": "python",
2423
"request": "launch",
2524
"program": "${workspaceFolder}/node_cli.py",
26-
"console": "internalConsole",
27-
"internalConsoleOptions": "openOnSessionStart"
25+
"console": "integratedTerminal",
2826
},
2927
{
3028
"name": "Python: node_cli custom log dir",
3129
"type": "python",
3230
"request": "launch",
3331
"program": "${workspaceFolder}/node_cli.py",
3432
"args": ["-d /home/szxo3/Desktop/test_node_dir"],
35-
"console": "internalConsole",
36-
"internalConsoleOptions": "openOnSessionStart"
33+
"console": "integratedTerminal",
3734
},
3835
{
3936
"name": "Python: local_run",
4037
"type": "python",
4138
"request": "launch",
4239
"program": "${workspaceFolder}/node_cli.py",
4340
"args": ["--local_run"],
44-
"console": "internalConsole",
45-
"internalConsoleOptions": "openOnSessionStart"
41+
"console": "integratedTerminal",
4642
},
4743
{
4844
"name": "Python: node_cli with GH_TOKEN",
4945
"type": "python",
5046
"request": "launch",
5147
"program": "${workspaceFolder}/node_cli.py",
5248
"args": ["--gh", "TOKEN_HERE"],
53-
"console": "internalConsole",
54-
"internalConsoleOptions": "openOnSessionStart"
49+
"console": "integratedTerminal",
5550
},
5651
]
5752
}

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Changelog
22

33

4-
# Version 18
4+
# Version 19
55

66
### [Current changes]
7-
-
7+
- **[Change]** Support for the new Authentication System 2.0 has been added.
8+
- **[Change]** Improved reconnect time of node by 10x-30x once it detects a live server.
9+
- **[Change]** Removed unnecessary codes + APIs.
10+
- **[Change]** Improved general login time because of the above change.
811

912
### [18.1.0][Jan 13, 2024]
1013
- **[Add]** AI Test recorder extension

Framework/Built_In_Automation/Sequential_Actions/common_functions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,7 +4593,7 @@ def upload_attachment_to_testcase(data_set):
45934593
CommonUtil.ExecLog(sModuleInfo, "Please insert attachment path ", 3)
45944594
return "zeuz_failed"
45954595
headers = RequestFormatter.add_api_key_to_headers({})
4596-
res = requests.post(
4596+
res = RequestFormatter.request("post",
45974597
RequestFormatter.form_uri("test_case_file_upload/"),
45984598
files={"file": open(var_path, 'rb')},
45994599
data={"file_upload_tc": var_id},
@@ -4647,7 +4647,7 @@ def download_attachment_from_testcase(data_set):
46474647
headers = RequestFormatter.add_api_key_to_headers({})
46484648
url = RequestFormatter.form_uri(f"static/tc_folder/{var_id}/{var_name}")
46494649
local_filename = url.split('/')[-1]
4650-
with requests.get(url, stream=True, verify=False,**headers) as r:
4650+
with RequestFormatter.request("get", url, stream=True, verify=False,**headers) as r:
46514651
r.raise_for_status()
46524652
with open(var_path+'/'+local_filename, 'wb') as f:
46534653
for chunk in r.iter_content(chunk_size=8192):
@@ -4690,7 +4690,7 @@ def upload_attachment_to_step(data_set):
46904690
CommonUtil.ExecLog(sModuleInfo, "Please insert attachment path ", 3)
46914691
return "zeuz_failed"
46924692
headers = RequestFormatter.add_api_key_to_headers({})
4693-
res = requests.post(
4693+
res = RequestFormatter.request("post",
46944694
RequestFormatter.form_uri("step_file_upload/"),
46954695
files={"file": open(var_path,'rb')},
46964696
data={"file_upload_step": var_id, },
@@ -4744,7 +4744,7 @@ def download_attachment_from_step(data_set):
47444744
headers = RequestFormatter.add_api_key_to_headers({})
47454745
url = RequestFormatter.form_uri(f"static/step_folder/{var_id}/{var_name}")
47464746
local_filename = url.split('/')[-1]
4747-
with requests.get(url, stream=True, verify=False,**headers) as r:
4747+
with RequestFormatter.request("get", url, stream=True, verify=False,**headers) as r:
47484748
r.raise_for_status()
47494749
with open(var_path+'/'+local_filename, 'wb') as f:
47504750
for chunk in r.iter_content(chunk_size=8192):
@@ -4784,7 +4784,7 @@ def upload_attachment_to_global(data_set):
47844784
return "zeuz_failed"
47854785

47864786
headers = RequestFormatter.add_api_key_to_headers({})
4787-
res = requests.post(
4787+
res = RequestFormatter.request("post",
47884788
RequestFormatter.form_uri("global_file_upload/"),
47894789
files={"file": open(var_path,'rb')},
47904790
verify=False,
@@ -4830,7 +4830,7 @@ def download_attachment_from_global(data_set):
48304830
headers = RequestFormatter.add_api_key_to_headers({})
48314831
url = RequestFormatter.form_uri(f"static/global_folder/{var_name}")
48324832
local_filename = url.split('/')[-1]
4833-
with requests.get(url, stream=True, verify=False,**headers) as r:
4833+
with RequestFormatter.request("get", url, stream=True, verify=False,**headers) as r:
48344834
r.raise_for_status()
48354835
with open(var_path+'/'+local_filename, 'wb') as f:
48364836
for chunk in r.iter_content(chunk_size=8192):
@@ -5889,7 +5889,7 @@ def data_store_read(data_set):
58895889
headers = RequestFormatter.add_api_key_to_headers({})
58905890
headers['headers']['content-type'] = 'application/json'
58915891
headers['headers']['X-API-KEY'] = ConfigModule.get_config_value("Authentication", "api-key")
5892-
res = requests.get(
5892+
res = RequestFormatter.request("get",
58935893
RequestFormatter.form_uri('data_store/data_store/custom_operation/'),
58945894
params=json.dumps(params),
58955895
verify=False,
@@ -6047,7 +6047,7 @@ def data_store_insert(data_set):
60476047
headers['headers']['content-type'] = 'application/json'
60486048
headers['headers']['X-API-KEY'] = ConfigModule.get_config_value("Authentication", "api-key")
60496049

6050-
res = requests.post(
6050+
res = RequestFormatter.request("post",
60516051
RequestFormatter.form_uri('data_store/data_store/data_store_list/'),
60526052
data=json.dumps(data),
60536053
verify=False,

Framework/MainDriverApi.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ def set_device_info_according_to_user_order(device_order, device_dict, test_cas
12181218
if "local" in device_order["mobile"]:
12191219
pass
12201220
elif "browser_stack" in device_order["mobile"]:
1221-
project = f"PROJECT: {user_info_object['project']} & TEAM: {user_info_object['team']}"
1221+
project = f"PROJECT:{user_info_object['project_id']} & TEAM:{user_info_object['team_id']}"
12221222
# build = f"{test_case_no} : {test_case_name}"
12231223
build = kwargs['run_id']
12241224
# Todo: session_name will be the run_id of the test case. So, we can reference with our zeuz better
@@ -1251,8 +1251,8 @@ def set_device_info_according_to_user_order(device_order, device_dict, test_cas
12511251
}
12521252
# Todo: remove this section. Changing this for new device_info.
12531253
# elif "browser_stack" in device_order and device_order["browser_stack"]:
1254-
# project = user_info_object["project"]
1255-
# team = user_info_object["team"]
1254+
# project ["project"]
1255+
# team ["team"]
12561256
#
12571257
# project = "PROJECT:'" + project + "' TEAM:'" + team + "'"
12581258
# build = test_case_no + " :: " + test_case_name
@@ -1421,21 +1421,19 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
14211421
for _ in range(5):
14221422
try:
14231423
if perf_report_html is None:
1424-
res = requests.post(
1424+
res = RequestFormatter.request("post",
14251425
RequestFormatter.form_uri("create_report_log_api/"),
14261426
data={"execution_report": json.dumps(tc_report)},
1427-
verify=False,
1428-
**RequestFormatter.add_api_key_to_headers({}))
1427+
verify=False)
14291428
else:
1430-
res = requests.post(
1429+
res = RequestFormatter.request("post",
14311430
RequestFormatter.form_uri("create_report_log_api/"),
14321431
data={"execution_report": json.dumps(tc_report),
14331432
"processed_tc_id":processed_tc_id
14341433

14351434
},
14361435
files=[("file",perf_report_html)],
1437-
verify=False,
1438-
**RequestFormatter.add_api_key_to_headers({}))
1436+
verify=False)
14391437

14401438

14411439
if res.status_code == 200:
@@ -1475,12 +1473,11 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
14751473
files_list = []
14761474
for zips in opened_zips:
14771475
files_list.append(("file",zips))
1478-
res = requests.post(
1476+
res = RequestFormatter.request("post",
14791477
RequestFormatter.form_uri("save_log_and_attachment_api/"),
14801478
files=files_list,
14811479
data={"machine_name": Userid},
1482-
verify=False,
1483-
**RequestFormatter.add_api_key_to_headers({}))
1480+
verify=False)
14841481
if res.status_code == 200:
14851482
try:
14861483
res_json = res.json()
@@ -1564,7 +1561,7 @@ def download_attachment(attachment_info: Dict[str, Any]):
15641561
file_name = url[file_name_start_pos:]
15651562
file_path = attachment_info["download_dir"] / file_name
15661563

1567-
r = requests.get(url, stream=True)
1564+
r = RequestFormatter.request("get", url, stream=True)
15681565
if r.status_code == requests.codes.ok:
15691566
with open(file_path, 'wb') as f:
15701567
for data in r.iter_content(chunk_size=512*1024):
@@ -1659,7 +1656,7 @@ def download_or_copy(attachment):
16591656

16601657

16611658
# main function
1662-
def main(device_dict, user_info_object):
1659+
def main(device_dict, all_run_id_info):
16631660
try:
16641661
# get module info
16651662
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
@@ -1679,8 +1676,6 @@ def main(device_dict, user_info_object):
16791676
# get local machine user id
16801677
Userid = (CommonUtil.MachineInfo().getLocalUser()).lower()
16811678

1682-
save_path = Path(ConfigModule.get_config_value("sectionOne", "temp_run_file_path", temp_ini_file)) / "attachments"
1683-
16841679
# FIXME: Need to decide what to do with the following code or how to
16851680
# handle it differently in case there are residual folders from previous
16861681
# test cases inside the attachments folder.
@@ -1699,9 +1694,12 @@ def main(device_dict, user_info_object):
16991694
# TODO: Remove all_file_specific_steps at a later period. keeping this
17001695
# only for custom driver purpose
17011696

1702-
json_path = save_path.glob("*.zeuz.json").__next__()
1703-
with open(json_path, "r", encoding="utf-8") as f:
1704-
all_run_id_info = json.loads(f.read())
1697+
# Ensure that the path exists
1698+
# save_path = Path(ConfigModule.get_config_value("sectionOne", "temp_run_file_path", temp_ini_file)) / "attachments"
1699+
# save_path.mkdir(exist_ok=True, parents=True)
1700+
# json_path = save_path.glob("*.zeuz.json").__next__()
1701+
# with open(json_path, "r", encoding="utf-8") as f:
1702+
# all_run_id_info = json.loads(f.read())
17051703

17061704
if len(all_run_id_info) == 0:
17071705
CommonUtil.ExecLog("", "No Test Run Schedule found for the current user : %s" % Userid, 2)
@@ -1888,6 +1886,10 @@ def main(device_dict, user_info_object):
18881886
performance_test_case = True
18891887
test_case_no = testcase_info["testcase_no"]
18901888
test_case_name = testcase_info["title"]
1889+
user_info_object = {
1890+
"project_id": run_id_info["project_id"],
1891+
"team_id": str(run_id_info["team_id"]),
1892+
}
18911893
set_device_info_according_to_user_order(device_order, device_dict, test_case_no, test_case_name, user_info_object, Userid, run_id=run_id)
18921894
CommonUtil.disabled_step = []
18931895

0 commit comments

Comments
 (0)