mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
Delete created profiles at end of test run
This commit is contained in:
@@ -457,7 +457,7 @@ for key in equipment_ids:
|
||||
|
||||
# Skip EAP argument
|
||||
if args.skip_eap == True:
|
||||
#case_ids.remove(test_cases["radius_profile"])
|
||||
case_ids.remove(test_cases["radius_profile"])
|
||||
for x in test_cases:
|
||||
if "eap" in x and test_cases[x] in case_ids:
|
||||
case_ids.remove(test_cases[x])
|
||||
@@ -705,11 +705,14 @@ for key in equipment_ids:
|
||||
print(report_data['tests'][key])
|
||||
# Pass cloud connectivity test case
|
||||
|
||||
###Update report json
|
||||
# Update report json
|
||||
with open(report_path + today + '/report_data.json', 'w') as report_json_file:
|
||||
json.dump(report_data, report_json_file)
|
||||
|
||||
### Create RADIUS profile - used for all EAP SSIDs
|
||||
# Create List of Created Profiles to Delete After Test
|
||||
delete_list = []
|
||||
|
||||
# Create RADIUS profile - used for all EAP SSIDs
|
||||
if args.skip_eap != True:
|
||||
radius_template = "templates/radius_profile_template.json"
|
||||
radius_name = radius_info['name']
|
||||
@@ -730,6 +733,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["radius_profile"], run_id=rid, status_id=1,
|
||||
msg='RADIUS profile created successfully')
|
||||
report_data['tests'][key][test_cases["radius_profile"]] = "passed"
|
||||
# Add created RADIUS profile to list for deletion at end of test
|
||||
delete_list.append(radius_profile)
|
||||
except:
|
||||
radius_profile = 'error'
|
||||
print("RADIUS Profile Create Error, will use existing profile for tests")
|
||||
@@ -761,7 +766,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_eap_bridge"], run_id=rid, status_id=1,
|
||||
msg='5G EAP SSID created successfully - bridge mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_eap_bridge"]] = "passed"
|
||||
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_eap)
|
||||
except:
|
||||
fiveG_eap = "error"
|
||||
print("5G EAP SSID create failed - bridge mode")
|
||||
@@ -783,6 +789,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_wpa2_bridge"], run_id=rid, status_id=1,
|
||||
msg='5G WPA2 SSID created successfully - bridge mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_wpa2_bridge"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_wpa2)
|
||||
except:
|
||||
fiveG_wpa2 = "error"
|
||||
print("5G WPA2 SSID create failed - bridge mode")
|
||||
@@ -802,6 +810,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_wpa_bridge"], run_id=rid, status_id=1,
|
||||
msg='5G WPA SSID created successfully - bridge mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_wpa_bridge"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_wpa)
|
||||
except:
|
||||
fiveG_wpa = "error"
|
||||
print("5G WPA SSID create failed - bridge mode")
|
||||
@@ -823,6 +833,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_eap_bridge"], run_id=rid, status_id=1,
|
||||
msg='2.4G EAP SSID created successfully - bridge mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_eap_bridge"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_eap)
|
||||
except:
|
||||
twoFourG_eap = "error"
|
||||
print("2.4G EAP SSID create failed - bridge mode")
|
||||
@@ -844,6 +856,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_wpa2_bridge"], run_id=rid, status_id=1,
|
||||
msg='2.4G WPA2 SSID created successfully - bridge mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_wpa2_bridge"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_wpa2)
|
||||
except:
|
||||
twoFourG_wpa2 = "error"
|
||||
print("2.4G WPA2 SSID create failed - bridge mode")
|
||||
@@ -863,6 +877,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_wpa_bridge"], run_id=rid, status_id=1,
|
||||
msg='2.4G WPA SSID created successfully - bridge mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_wpa_bridge"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_wpa)
|
||||
except:
|
||||
twoFourG_wpa = "error"
|
||||
print("2.4G WPA SSID create failed - bridge mode")
|
||||
@@ -893,6 +909,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ap_bridge"], run_id=rid, status_id=1,
|
||||
msg='AP profile for bridge tests created successfully')
|
||||
report_data['tests'][key][test_cases["ap_bridge"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(test_profile_id)
|
||||
except:
|
||||
create_ap_profile = "error"
|
||||
test_profile_id = profile_info_dict[fw_model]["profile_id"]
|
||||
@@ -1120,6 +1138,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_eap_nat"], run_id=rid, status_id=1,
|
||||
msg='5G EAP SSID created successfully - NAT mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_eap_nat"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_eap)
|
||||
|
||||
except:
|
||||
fiveG_eap = "error"
|
||||
@@ -1142,6 +1162,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_wpa2_nat"], run_id=rid, status_id=1,
|
||||
msg='5G WPA2 SSID created successfully - NAT mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_wpa2_nat"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_wpa2)
|
||||
except:
|
||||
fiveG_wpa2 = "error"
|
||||
print("5G WPA2 SSID create failed - NAT mode")
|
||||
@@ -1161,6 +1183,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_wpa_nat"], run_id=rid, status_id=1,
|
||||
msg='5G WPA SSID created successfully - NAT mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_wpa_nat"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_wpa)
|
||||
except:
|
||||
fiveG_wpa = "error"
|
||||
print("5G WPA SSID create failed - NAT mode")
|
||||
@@ -1182,6 +1206,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_eap_nat"], run_id=rid, status_id=1,
|
||||
msg='2.4G EAP SSID created successfully - NAT mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_eap_nat"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_eap)
|
||||
except:
|
||||
twoFourG_eap = "error"
|
||||
print("2.4G EAP SSID create failed - NAT mode")
|
||||
@@ -1203,6 +1229,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_wpa2_nat"], run_id=rid, status_id=1,
|
||||
msg='2.4G WPA2 SSID created successfully - NAT mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_wpa2_nat"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_wpa2)
|
||||
except:
|
||||
twoFourG_wpa2 = "error"
|
||||
print("2.4G WPA2 SSID create failed - NAT mode")
|
||||
@@ -1222,6 +1250,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_wpa_nat"], run_id=rid, status_id=1,
|
||||
msg='2.4G WPA SSID created successfully - NAT mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_wpa_nat"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_wpa)
|
||||
except:
|
||||
twoFourG_wpa = "error"
|
||||
print("2.4G WPA SSID create failed - NAT mode")
|
||||
@@ -1251,6 +1281,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ap_nat"], run_id=rid, status_id=1,
|
||||
msg='AP profile for NAT tests created successfully')
|
||||
report_data['tests'][key][test_cases["ap_nat"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(test_profile_id)
|
||||
except:
|
||||
create_ap_profile = "error"
|
||||
test_profile_id = profile_info_dict[fw_model + '_nat']["profile_id"]
|
||||
@@ -1475,6 +1507,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_eap_vlan"], run_id=rid, status_id=1,
|
||||
msg='5G EAP SSID created successfully - Custom VLAN mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_eap_vlan"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_eap)
|
||||
|
||||
except:
|
||||
fiveG_eap = "error"
|
||||
@@ -1497,6 +1531,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_wpa2_vlan"], run_id=rid, status_id=1,
|
||||
msg='5G WPA2 SSID created successfully - custom VLAN mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_wpa2_vlan"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_wpa2)
|
||||
except:
|
||||
fiveG_wpa2 = "error"
|
||||
print("5G WPA2 SSID create failed - custom VLAN mode")
|
||||
@@ -1516,6 +1552,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_5g_wpa_vlan"], run_id=rid, status_id=1,
|
||||
msg='5G WPA SSID created successfully - custom VLAN mode')
|
||||
report_data['tests'][key][test_cases["ssid_5g_wpa_vlan"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(fiveG_wpa)
|
||||
except:
|
||||
fiveG_wpa = "error"
|
||||
print("5G WPA SSID create failed - custom VLAN mode")
|
||||
@@ -1538,6 +1576,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_eap_vlan"], run_id=rid, status_id=1,
|
||||
msg='2.4G EAP SSID created successfully - custom VLAN mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_eap_vlan"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_eap)
|
||||
except:
|
||||
twoFourG_eap = "error"
|
||||
print("2.4G EAP SSID create failed - custom VLAN mode")
|
||||
@@ -1560,6 +1600,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_wpa2_vlan"], run_id=rid, status_id=1,
|
||||
msg='2.4G WPA2 SSID created successfully - custom VLAN mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_wpa2_vlan"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_wpa2)
|
||||
except:
|
||||
twoFourG_wpa2 = "error"
|
||||
print("2.4G WPA2 SSID create failed - custom VLAN mode")
|
||||
@@ -1579,6 +1621,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ssid_2g_wpa_vlan"], run_id=rid, status_id=1,
|
||||
msg='2.4G WPA SSID created successfully - custom VLAN mode')
|
||||
report_data['tests'][key][test_cases["ssid_2g_wpa_vlan"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(twoFourG_wpa)
|
||||
except:
|
||||
twoFourG_wpa = "error"
|
||||
print("2.4G WPA SSID create failed - custom VLAN mode")
|
||||
@@ -1608,6 +1652,8 @@ for key in equipment_ids:
|
||||
client.update_testrail(case_id=test_cases["ap_vlan"], run_id=rid, status_id=1,
|
||||
msg='AP profile for VLAN tests created successfully')
|
||||
report_data['tests'][key][test_cases["ap_vlan"]] = "passed"
|
||||
# Add created profile to list for deletion at end of test
|
||||
delete_list.append(test_profile_id)
|
||||
except:
|
||||
create_ap_profile = "error"
|
||||
test_profile_id = profile_info_dict[fw_model + '_vlan']["profile_id"]
|
||||
@@ -1837,8 +1883,23 @@ for key in equipment_ids:
|
||||
with open(report_path + today + '/report_data.json', 'w') as report_json_file:
|
||||
json.dump(report_data, report_json_file)
|
||||
|
||||
## Post-test Profile Cleanup
|
||||
###########################################################################
|
||||
################# Post-test Prfofile Cleanup ##############################
|
||||
###########################################################################
|
||||
|
||||
# Set AP to use permanently available profile to allow for deletion of RADIUS, SSID, and AP profiles
|
||||
print("Cleaning up! Deleting created test profiles")
|
||||
print("Set AP to profile not created in test")
|
||||
ap_profile = CloudSDK.set_ap_profile(equipment_id, profile_info_dict[fw_model]["profile_id"], cloudSDK_url, bearer)
|
||||
time.sleep(5)
|
||||
|
||||
# Delete profiles in delete_list
|
||||
for x in delete_list:
|
||||
delete_profile = CloudSDK.delete_profile(cloudSDK_url, bearer, str(x))
|
||||
if delete_profile == "SUCCESS":
|
||||
print("profile", x, "delete successful")
|
||||
else:
|
||||
print("Error deleting profile")
|
||||
|
||||
# Dump all sanity test results to external json file again just to be sure
|
||||
with open('sanity_status.json', 'w') as json_file:
|
||||
|
||||
@@ -264,4 +264,17 @@ class CloudSDK:
|
||||
#print(radius_profile)
|
||||
#print(ssid_profile)
|
||||
radius_profile_id = radius_profile['id']
|
||||
return radius_profile_id
|
||||
return radius_profile_id
|
||||
|
||||
def delete_profile(cloudSDK_url, bearer, profile_id):
|
||||
url = cloudSDK_url + "/portal/profile?profileId="+profile_id
|
||||
payload = {}
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + bearer
|
||||
}
|
||||
del_profile = requests.request("DELETE", url, headers=headers, data=payload)
|
||||
status_code = del_profile.status_code
|
||||
if status_code is 200:
|
||||
return("SUCCESS")
|
||||
else:
|
||||
return ("ERROR")
|
||||
|
||||
@@ -137,7 +137,7 @@ test_cases = {
|
||||
|
||||
## Other profiles
|
||||
radius_profile = 129
|
||||
rf_profile = 3459
|
||||
rf_profile = 10
|
||||
|
||||
###Testing AP Profile Information
|
||||
profile_info_dict = {
|
||||
@@ -146,7 +146,7 @@ profile_info_dict = {
|
||||
"childProfileIds": [
|
||||
129,
|
||||
3,
|
||||
3459,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
@@ -189,7 +189,7 @@ profile_info_dict = {
|
||||
18,
|
||||
201,
|
||||
202,
|
||||
3459,
|
||||
10,
|
||||
14,
|
||||
15
|
||||
],
|
||||
@@ -235,7 +235,7 @@ profile_info_dict = {
|
||||
22,
|
||||
24,
|
||||
25,
|
||||
3459
|
||||
10
|
||||
],
|
||||
"fiveG_WPA2_SSID": "EC420_5G_WPA2",
|
||||
"fiveG_WPA2_PSK": "Connectus123$",
|
||||
@@ -270,7 +270,7 @@ profile_info_dict = {
|
||||
"childProfileIds": [
|
||||
32,
|
||||
129,
|
||||
3459,
|
||||
10,
|
||||
28,
|
||||
29,
|
||||
205,
|
||||
@@ -313,7 +313,7 @@ profile_info_dict = {
|
||||
81,
|
||||
193,
|
||||
82,
|
||||
3459,
|
||||
10,
|
||||
78,
|
||||
79
|
||||
],
|
||||
@@ -351,7 +351,7 @@ profile_info_dict = {
|
||||
129,
|
||||
72,
|
||||
73,
|
||||
3459,
|
||||
10,
|
||||
75,
|
||||
203,
|
||||
76,
|
||||
@@ -396,7 +396,7 @@ profile_info_dict = {
|
||||
211,
|
||||
212,
|
||||
90,
|
||||
3459,
|
||||
10,
|
||||
91,
|
||||
93,
|
||||
94
|
||||
@@ -438,7 +438,7 @@ profile_info_dict = {
|
||||
85,
|
||||
87,
|
||||
88,
|
||||
3459,
|
||||
10,
|
||||
207
|
||||
],
|
||||
"fiveG_WPA2_SSID": "ECW5211_5G_WPA2_NAT",
|
||||
@@ -476,7 +476,7 @@ profile_info_dict = {
|
||||
320,
|
||||
129,
|
||||
337,
|
||||
3459,
|
||||
10,
|
||||
333,
|
||||
334,
|
||||
335
|
||||
@@ -514,7 +514,7 @@ profile_info_dict = {
|
||||
"childProfileIds": [
|
||||
129,
|
||||
313,
|
||||
3459,
|
||||
10,
|
||||
314,
|
||||
315,
|
||||
316,
|
||||
@@ -562,7 +562,7 @@ profile_info_dict = {
|
||||
354,
|
||||
355,
|
||||
356,
|
||||
3459,
|
||||
10,
|
||||
351
|
||||
],
|
||||
"fiveG_WPA2_SSID": "EC420_5G_WPA2_VLAN",
|
||||
@@ -601,7 +601,7 @@ profile_info_dict = {
|
||||
359,
|
||||
360,
|
||||
361,
|
||||
3459,
|
||||
10,
|
||||
362,
|
||||
363
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user