diff --git a/libs/tip_2x/README.md b/libs/tip_2x/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/libs/SetupLibrary.py b/libs/tip_2x/SetupLibrary.py similarity index 100% rename from libs/SetupLibrary.py rename to libs/tip_2x/SetupLibrary.py diff --git a/libs/openwrt_ctl.py b/libs/tip_2x/openwrt_ctl.py similarity index 99% rename from libs/openwrt_ctl.py rename to libs/tip_2x/openwrt_ctl.py index ec3f18174..e2b322e26 100755 --- a/libs/openwrt_ctl.py +++ b/libs/tip_2x/openwrt_ctl.py @@ -18,14 +18,13 @@ $ pip3 install pexpect-serial import sys - - if sys.version_info[0] != 3: print("This script requires Python 3") exit() try: import importlib + re = importlib.import_module("re") logging = importlib.import_module("logging") time = importlib.import_module("time") diff --git a/libs/tip_2x/setup.py b/libs/tip_2x/setup.py new file mode 100644 index 000000000..e69de29bb diff --git a/libs/tip_2x/tip_2x.py b/libs/tip_2x/tip_2x.py new file mode 100644 index 000000000..10f9d0ecf --- /dev/null +++ b/libs/tip_2x/tip_2x.py @@ -0,0 +1,134 @@ +""" + Telecom Infra Project OpenWifi 2.X (Ucentral libraries for Test Automation) + + +""" +import importlib + +import pytest + +logging = importlib.import_module("logging") + +ap_lib = importlib.import_module("ap_lib") +controller = importlib.import_module("controller") + +""" + Custom Class Imports needed for OpenWifi 2.X +""" + +ConfigureController = controller.ConfigureController +Controller = controller.Controller +FMSUtils = controller.FMSUtils +ProvUtils = controller.ProvUtils +UProfileUtility = controller.UProfileUtility +APLIBS = ap_lib.APLIBS + + +class tip_2x: + """ + Standard OpenWifi wlan-testing specific variables + + """ + controller_data = {} + device_under_tests_info = [] + """ + OpenWifi 2.x Specific Variables that will be only scoped in tip_2x Library + + """ + ow_sec_url = "" + ow_sec_login_username = "" + ow_sec_login_password = "" + target = "tip_2x" + controller_library_object = object() + dut_library_object = object() + + def __init__(self, controller_data=None, target=None, + device_under_tests_info=[], logging_level=logging.INFO): + logging.basicConfig(format='%(asctime)s - %(message)s', level=logging_level) + if target != self.target: + logging.error("Target version is : " + target + " Expected target is tip_2x.") + pytest.exit("Target should be 'tip_2x', Current Target is : " + target) + if controller_data is None: + controller_data = {} + self.controller_data = controller_data + self.device_under_tests_info = device_under_tests_info + self.setup_metadata() + + """ + Controller and Access Point specific metadata that is related to OpenWifi 2.x + """ + + def setup_metadata(self): + logging.info("setting up the Controller metadata for tip_2x Library: " + str(self.controller_data)) + logging.info("setting up the DUT metadata for tip_2x Library: " + str(self.device_under_tests_info)) + logging.info("Number of DUT's configured: " + str(len(self.device_under_tests_info))) + self.ow_sec_url = self.controller_data["url"] + self.ow_sec_login_username = self.controller_data["username"] + self.ow_sec_login_password = self.controller_data["password"] + + def setup_objects(self): + self.controller_library_object = Controller() + self.dut_library_object = APLIBS() + + """ Standard getter methods. Should be available for all type of libraries. Commonly used by wlan-testing""" + + def get_dut_library_object(self): + return self.dut_library_object + + def get_controller_library_object(self): + return self.controller_library_object + + def get_controller_data(self): + return self.controller_data + + def get_device_under_tests_info(self): + return self.device_under_tests_info + + def get_number_of_dut(self): + return len(self.device_under_tests_info) + + def get_dut_logs(self, dut_idx=0): + return self.dut_library_object.get_logs(idx=0) + + def get_controller_logs(self): + pass + + def setup_configuration(self): + pass + + def get_dut_version(self): + pass + + def get_controller_version(self): + pass + + # def get_controller_logs(self): + # pass + # + # def setup_configuration(self): + # pass + + +if __name__ == '__main__': + basic_1 = { + "target": "tip_2x", + "controller": { + "url": "https://sec-qa01.cicd.lab.wlan.tip.build:16001", + "username": "tip@ucentral.com", + "password": "OpenWifi%123" + }, + "device_under_tests": [{ + "model": "wallys_dr40x9", + "mode": "wifi5", + "serial": "c44bd1005b30", + "jumphost": True, + "ip": "10.28.3.100", + "username": "lanforge", + "password": "pumpkin77", + "port": 22, + "serial_tty": "/dev/ttyAP8", + "version": "next-latest" + }], + "traffic_generator": {} + } + var = tip_2x(controller_data=basic_1["controller"], device_under_tests_info=basic_1["device_under_tests"]) diff --git a/tests/e2e/advanced/conftest.py b/tests/e2e/advanced/conftest.py index 6a2a5207e..dd9c96dd2 100644 --- a/tests/e2e/advanced/conftest.py +++ b/tests/e2e/advanced/conftest.py @@ -1,128 +1,128 @@ -import os -import sys - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -if "libs" not in sys.path: - sys.path.append(f'../libs') - -from controller.controller_1x.controller import ProfileUtility -from controller.controller_2x.controller import UProfileUtility -from controller.controller_3x.controller import CController -import time -from lanforge.lf_tests import RunTest -from lanforge.lf_tools import ChamberView -import pytest -import allure - - -@pytest.fixture(scope="session") -def instantiate_profile(request): - if request.config.getoption("1.x"): - yield ProfileUtility - elif request.config.getoption("cc.1"): - yield CController - else: - yield UProfileUtility - - -@pytest.fixture(scope="session") -def create_lanforge_chamberview(lf_tools): - scenario_object, scenario_name = lf_tools.Chamber_View() - return scenario_name - - -@pytest.fixture(scope="session") -def setup_vlan(): - vlan_id = [100] - allure.attach(body=str(vlan_id), name="VLAN Created: ") - yield vlan_id[0] - - - -@pytest.fixture(scope="class") -def setup_profiles(request, setup_controller, testbed, get_equipment_ref, fixtures_ver, - instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info, - run_lf, cc_1, lf_reports): - lf_tools.reset_scenario() - param = dict(request.param) - - # VLAN Setup - if request.param["mode"] == "VLAN": - - vlan_list = list() - refactored_vlan_list = list() - ssid_modes = request.param["ssid_modes"].keys() - for mode in ssid_modes: - for ssid in range(len(request.param["ssid_modes"][mode])): - if "vlan" in request.param["ssid_modes"][mode][ssid]: - vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) - else: - pass - if vlan_list: - [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] - vlan_list = refactored_vlan_list - for i in range(len(vlan_list)): - if vlan_list[i] > 4095 or vlan_list[i] < 1: - vlan_list.pop(i) - if request.param["mode"] == "VLAN": - lf_tools.add_vlan(vlan_ids=vlan_list) - print("fixture version ", fixtures_ver) - if cc_1: - return_var = fixtures_ver.setup_profiles(request, param, run_lf, instantiate_profile, get_configuration, - get_markers, - lf_tools, lf_reports) - else: - return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_ref, - instantiate_profile, - get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, - radius_accounting_info, run_lf=run_lf) - - yield return_var - - -@pytest.fixture(scope="session") -def station_names_twog(request, get_configuration): - station_names = [] - for i in range(0, int(request.config.getini("num_stations"))): - station_names.append(get_configuration["traffic_generator"]["details"]["2.4G-Station-Name"] + "0" + str(i)) - yield station_names - - -@pytest.fixture(scope="session") -def station_names_fiveg(request, get_configuration): - station_names = [] - for i in range(0, int(request.config.getini("num_stations"))): - station_names.append(get_configuration["traffic_generator"]["details"]["5G-Station-Name"] + "0" + str(i)) - yield station_names - - -@pytest.fixture(scope="session") -def num_stations(request): - num_sta = int(request.config.getini("num_stations")) - yield num_sta - - -@pytest.fixture(scope="class") -def get_vif_state(get_apnos, get_configuration): - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") - vif_config = list(ap_ssh.get_vif_config_ssids()) - vif_state = list(ap_ssh.get_vif_state_ssids()) - vif_state.sort() - vif_config.sort() - allure.attach(name="vif_state", body=str(vif_state)) - yield vif_state - -@pytest.fixture(scope="class") -def get_vlan_list(get_apnos, get_configuration): - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") - vlan_list = list(ap_ssh.get_vlan()) - vlan_list.sort() - allure.attach(name="vlan_list", body=str(vlan_list)) - yield vlan_list - +# import os +# import sys +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# if "libs" not in sys.path: +# sys.path.append(f'../libs') +# +# from controller.controller_1x.controller import ProfileUtility +# from controller.controller_2x.controller import UProfileUtility +# from controller.controller_3x.controller import CController +# import time +# from lanforge.lf_tests import RunTest +# from lanforge.lf_tools import ChamberView +# import pytest +# import allure +# +# +# @pytest.fixture(scope="session") +# def instantiate_profile(request): +# if request.config.getoption("1.x"): +# yield ProfileUtility +# elif request.config.getoption("cc.1"): +# yield CController +# else: +# yield UProfileUtility +# +# +# @pytest.fixture(scope="session") +# def create_lanforge_chamberview(lf_tools): +# scenario_object, scenario_name = lf_tools.Chamber_View() +# return scenario_name +# +# +# @pytest.fixture(scope="session") +# def setup_vlan(): +# vlan_id = [100] +# allure.attach(body=str(vlan_id), name="VLAN Created: ") +# yield vlan_id[0] +# +# +# +# @pytest.fixture(scope="class") +# def setup_profiles(request, setup_controller, testbed, get_equipment_ref, fixtures_ver, +# instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info, +# run_lf, cc_1, lf_reports): +# lf_tools.reset_scenario() +# param = dict(request.param) +# +# # VLAN Setup +# if request.param["mode"] == "VLAN": +# +# vlan_list = list() +# refactored_vlan_list = list() +# ssid_modes = request.param["ssid_modes"].keys() +# for mode in ssid_modes: +# for ssid in range(len(request.param["ssid_modes"][mode])): +# if "vlan" in request.param["ssid_modes"][mode][ssid]: +# vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) +# else: +# pass +# if vlan_list: +# [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] +# vlan_list = refactored_vlan_list +# for i in range(len(vlan_list)): +# if vlan_list[i] > 4095 or vlan_list[i] < 1: +# vlan_list.pop(i) +# if request.param["mode"] == "VLAN": +# lf_tools.add_vlan(vlan_ids=vlan_list) +# print("fixture version ", fixtures_ver) +# if cc_1: +# return_var = fixtures_ver.setup_profiles(request, param, run_lf, instantiate_profile, get_configuration, +# get_markers, +# lf_tools, lf_reports) +# else: +# return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_ref, +# instantiate_profile, +# get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, +# radius_accounting_info, run_lf=run_lf) +# +# yield return_var +# +# +# @pytest.fixture(scope="session") +# def station_names_twog(request, get_configuration): +# station_names = [] +# for i in range(0, int(request.config.getini("num_stations"))): +# station_names.append(get_configuration["traffic_generator"]["details"]["2.4G-Station-Name"] + "0" + str(i)) +# yield station_names +# +# +# @pytest.fixture(scope="session") +# def station_names_fiveg(request, get_configuration): +# station_names = [] +# for i in range(0, int(request.config.getini("num_stations"))): +# station_names.append(get_configuration["traffic_generator"]["details"]["5G-Station-Name"] + "0" + str(i)) +# yield station_names +# +# +# @pytest.fixture(scope="session") +# def num_stations(request): +# num_sta = int(request.config.getini("num_stations")) +# yield num_sta +# +# +# @pytest.fixture(scope="class") +# def get_vif_state(get_apnos, get_configuration): +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") +# vif_config = list(ap_ssh.get_vif_config_ssids()) +# vif_state = list(ap_ssh.get_vif_state_ssids()) +# vif_state.sort() +# vif_config.sort() +# allure.attach(name="vif_state", body=str(vif_state)) +# yield vif_state +# +# @pytest.fixture(scope="class") +# def get_vlan_list(get_apnos, get_configuration): +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") +# vlan_list = list(ap_ssh.get_vlan()) +# vlan_list.sort() +# allure.attach(name="vlan_list", body=str(vlan_list)) +# yield vlan_list +# diff --git a/tests/e2e/basic/conftest.py b/tests/e2e/basic/conftest.py index ee36f7307..09a073030 100644 --- a/tests/e2e/basic/conftest.py +++ b/tests/e2e/basic/conftest.py @@ -1,152 +1,152 @@ -import json -import os -import sys - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -if "libs" not in sys.path: - sys.path.append(f'../libs') - -from controller.controller_1x.controller import ProfileUtility -from controller.controller_2x.controller import UProfileUtility -from controller.controller_3x.controller import CController -import time -from lanforge.lf_tools import ChamberView -import pytest -import allure - - -@pytest.fixture(scope="session") -def instantiate_profile(request): - if request.config.getoption("1.x"): - yield ProfileUtility - elif request.config.getoption("cc.1"): - yield CController - else: - yield UProfileUtility - - -@pytest.fixture(scope="session") -def create_lanforge_chamberview(lf_tools): - scenario_object, scenario_name = lf_tools.Chamber_View() - return scenario_name - - -@pytest.fixture(scope="session") -def create_lanforge_chamberview_dut(lf_tools, run_lf): - if not run_lf: - dut_object, dut_name = lf_tools.Create_Dut() - return dut_name - return "" - - -@pytest.fixture(scope="class") -def setup_profiles(request, setup_controller, testbed, get_equipment_ref, fixtures_ver, reset_scenario_lf, - instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, run_lf, - get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info, cc_1): - param = dict(request.param) - - # VLAN Setup - if request.param["mode"] == "VLAN": - - vlan_list = list() - refactored_vlan_list = list() - ssid_modes = request.param["ssid_modes"].keys() - for mode in ssid_modes: - for ssid in range(len(request.param["ssid_modes"][mode])): - if "vlan" in request.param["ssid_modes"][mode][ssid]: - vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) - else: - pass - if vlan_list: - [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] - vlan_list = refactored_vlan_list - for i in range(len(vlan_list)): - if vlan_list[i] > 4095 or vlan_list[i] < 1: - vlan_list.pop(i) - if request.param["mode"] == "VLAN": - lf_tools.reset_scenario() - lf_tools.add_vlan(vlan_ids=vlan_list) - - # call this, if 1.x - print("fixture version ", fixtures_ver) - if cc_1: - return_var = fixtures_ver.setup_profiles(request, param, run_lf, instantiate_profile, get_configuration, get_markers, lf_tools) - else: - return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_ref, - instantiate_profile, - get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, - radius_accounting_info, run_lf=run_lf) - - yield return_var - - -@pytest.fixture(scope="session") -def station_names_twog(request, get_configuration): - station_names = [] - for i in range(0, int(request.config.getini("num_stations"))): - station_names.append(get_configuration["traffic_generator"]["details"]["2.4G-Station-Name"] + "0" + str(i)) - yield station_names - - -@pytest.fixture(scope="session") -def station_names_fiveg(request, get_configuration): - station_names = [] - for i in range(0, int(request.config.getini("num_stations"))): - station_names.append(get_configuration["traffic_generator"]["details"]["5G-Station-Name"] + "0" + str(i)) - yield station_names - - -@pytest.fixture(scope="session") -def station_names_ax(request, get_configuration): - station_names = [] - for i in range(0, int(request.config.getini("num_stations"))): - station_names.append(get_configuration["traffic_generator"]["details"]["AX-Station-Name"] + "0" + str(i)) - yield station_names - - -@pytest.fixture(scope="session") -def num_stations(request): - num_sta = int(request.config.getini("num_stations")) - yield num_sta - - -@pytest.fixture(scope="class") -def get_vif_state(get_apnos, get_configuration, request, lf_tools, run_lf): - if request.config.getoption("1.x"): - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") - vif_state = list(ap_ssh.get_vif_state_ssids()) - vif_state.sort() - yield vif_state - else: - yield lf_tools.ssid_list - - -@pytest.fixture(scope="session") -def dfs_start(fixtures_ver, get_apnos, get_configuration): - dfs_start = fixtures_ver.dfs(get_apnos, get_configuration) - yield dfs_start - - -@pytest.fixture(scope="class") -def get_vlan_list(get_apnos, get_configuration): - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") - vlan_list = list(ap_ssh.get_vlan()) - vlan_list.sort() - yield vlan_list - - -@pytest.fixture(scope="session") -def reset_scenario_lf(request, lf_tools, run_lf): - if not run_lf: - lf_tools.reset_scenario() - def teardown_session(): - lf_tools.reset_scenario() - - request.addfinalizer(teardown_session) - yield "" - +# import json +# import os +# import sys +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# if "libs" not in sys.path: +# sys.path.append(f'../libs') +# +# from controller.controller_1x.controller import ProfileUtility +# from controller.controller_2x.controller import UProfileUtility +# from controller.controller_3x.controller import CController +# import time +# from lanforge.lf_tools import ChamberView +# import pytest +# import allure +# +# +# @pytest.fixture(scope="session") +# def instantiate_profile(request): +# if request.config.getoption("1.x"): +# yield ProfileUtility +# elif request.config.getoption("cc.1"): +# yield CController +# else: +# yield UProfileUtility +# +# +# @pytest.fixture(scope="session") +# def create_lanforge_chamberview(lf_tools): +# scenario_object, scenario_name = lf_tools.Chamber_View() +# return scenario_name +# +# +# @pytest.fixture(scope="session") +# def create_lanforge_chamberview_dut(lf_tools, run_lf): +# if not run_lf: +# dut_object, dut_name = lf_tools.Create_Dut() +# return dut_name +# return "" +# +# +# @pytest.fixture(scope="class") +# def setup_profiles(request, setup_controller, testbed, get_equipment_ref, fixtures_ver, reset_scenario_lf, +# instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, run_lf, +# get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info, cc_1): +# param = dict(request.param) +# +# # VLAN Setup +# if request.param["mode"] == "VLAN": +# +# vlan_list = list() +# refactored_vlan_list = list() +# ssid_modes = request.param["ssid_modes"].keys() +# for mode in ssid_modes: +# for ssid in range(len(request.param["ssid_modes"][mode])): +# if "vlan" in request.param["ssid_modes"][mode][ssid]: +# vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) +# else: +# pass +# if vlan_list: +# [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] +# vlan_list = refactored_vlan_list +# for i in range(len(vlan_list)): +# if vlan_list[i] > 4095 or vlan_list[i] < 1: +# vlan_list.pop(i) +# if request.param["mode"] == "VLAN": +# lf_tools.reset_scenario() +# lf_tools.add_vlan(vlan_ids=vlan_list) +# +# # call this, if 1.x +# print("fixture version ", fixtures_ver) +# if cc_1: +# return_var = fixtures_ver.setup_profiles(request, param, run_lf, instantiate_profile, get_configuration, get_markers, lf_tools) +# else: +# return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_ref, +# instantiate_profile, +# get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, +# radius_accounting_info, run_lf=run_lf) +# +# yield return_var +# +# +# @pytest.fixture(scope="session") +# def station_names_twog(request, get_configuration): +# station_names = [] +# for i in range(0, int(request.config.getini("num_stations"))): +# station_names.append(get_configuration["traffic_generator"]["details"]["2.4G-Station-Name"] + "0" + str(i)) +# yield station_names +# +# +# @pytest.fixture(scope="session") +# def station_names_fiveg(request, get_configuration): +# station_names = [] +# for i in range(0, int(request.config.getini("num_stations"))): +# station_names.append(get_configuration["traffic_generator"]["details"]["5G-Station-Name"] + "0" + str(i)) +# yield station_names +# +# +# @pytest.fixture(scope="session") +# def station_names_ax(request, get_configuration): +# station_names = [] +# for i in range(0, int(request.config.getini("num_stations"))): +# station_names.append(get_configuration["traffic_generator"]["details"]["AX-Station-Name"] + "0" + str(i)) +# yield station_names +# +# +# @pytest.fixture(scope="session") +# def num_stations(request): +# num_sta = int(request.config.getini("num_stations")) +# yield num_sta +# +# +# @pytest.fixture(scope="class") +# def get_vif_state(get_apnos, get_configuration, request, lf_tools, run_lf): +# if request.config.getoption("1.x"): +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") +# vif_state = list(ap_ssh.get_vif_state_ssids()) +# vif_state.sort() +# yield vif_state +# else: +# yield lf_tools.ssid_list +# +# +# @pytest.fixture(scope="session") +# def dfs_start(fixtures_ver, get_apnos, get_configuration): +# dfs_start = fixtures_ver.dfs(get_apnos, get_configuration) +# yield dfs_start +# +# +# @pytest.fixture(scope="class") +# def get_vlan_list(get_apnos, get_configuration): +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") +# vlan_list = list(ap_ssh.get_vlan()) +# vlan_list.sort() +# yield vlan_list +# +# +# @pytest.fixture(scope="session") +# def reset_scenario_lf(request, lf_tools, run_lf): +# if not run_lf: +# lf_tools.reset_scenario() +# def teardown_session(): +# lf_tools.reset_scenario() +# +# request.addfinalizer(teardown_session) +# yield "" +# diff --git a/tests/e2e/conftest.1 b/tests/e2e/conftest.1 new file mode 100644 index 000000000..d5daa9a33 --- /dev/null +++ b/tests/e2e/conftest.1 @@ -0,0 +1,1020 @@ +""" + Pytest fixtures: High level Resource Management and base setup fixtures +""" +import datetime +import os +import random +import string +import sys +import re + +import allure + +ALLURE_ENVIRONMENT_PROPERTIES_FILE = 'environment.properties' +ALLUREDIR_OPTION = '--alluredir' + +sys.path.append( + os.path.dirname( + os.path.realpath(__file__) + ) +) +if "libs" not in sys.path: + sys.path.append(f'../libs') +for folder in 'py-json', 'py-scripts': + if folder not in sys.path: + sys.path.append(f'../lanforge/lanforge-scripts/{folder}') + +sys.path.append(f"../lanforge/lanforge-scripts/py-scripts/tip-cicd-sanity") + +sys.path.append(f'../libs') +sys.path.append(f'../libs/lanforge/') + +from LANforge.LFUtils import * + +if 'py-json' not in sys.path: + sys.path.append('../py-scripts') +from apnos.apnos import APNOS +from controller.controller_1x.controller import FirmwareUtility +import pytest +from lanforge.lf_tests import RunTest +from cv_test_manager import cv_test +from configuration import CONFIGURATION +from configuration import PERFECTO_DETAILS +from configuration import open_flow +from configuration import RADIUS_SERVER_DATA +from configuration import RADIUS_ACCOUNTING_DATA +from configuration import RATE_LIMITING_RADIUS_SERVER_DATA +from configuration import RATE_LIMITING_RADIUS_ACCOUNTING_DATA +from lanforge.scp_util import SCP_File +from testrails.testrail_api import APIClient +from testrails.reporting import Reporting +from lf_tools import ChamberView +from libs.lanforge.pull_report import Report +from os import path +from typing import Any, Callable, Optional + +from _pytest.fixtures import SubRequest +from pytest import fixture + +from fixtures_1x import Fixtures_1x +from fixtures_2x import Fixtures_2x +from fixtures_3x import Fixtures_3x +from controller.controller_3x.controller import CController + +import logging + +LOGGER = logging.getLogger(__name__) + + +def pytest_addoption(parser): + """pytest addoption function: contains ini objects and options""" + parser.addini("tr_url", "Test Rail URL") + parser.addini("tr_prefix", "Test Rail Prefix (Generally Testbed_name_)") + parser.addini("tr_user", "Testrail Username") + parser.addini("tr_pass", "Testrail Password") + parser.addini("tr_project_id", "Testrail Project ID") + parser.addini("milestone", "milestone Id") + + parser.addini("influx_host", "Influx Host", default="influx.cicd.lab.wlan.tip.build") + parser.addini("influx_port", "Influx Port", default=80) + parser.addini("influx_token", "Influx Token", default="TCkdATXAbHmNbn4QyNaj43WpGBYxFrzV") + parser.addini("influx_bucket", "influx bucket", default="tip-cicd") + parser.addini("influx_org", "influx organization", default="tip") + parser.addini(name="firmware", type='string', help="AP Firmware build URL", default="0") + parser.addini("cloud_ctlr", "AP Firmware build URL", default="0") + + parser.addini("num_stations", "Number of Stations/Clients for testing") + + # change behaviour + parser.addoption( + "--skip-upgrade", + action="store_true", + default=False, + help="skip updating firmware on the AP (useful for local testing)" + ) + parser.addoption( + "--skip-env", + action="store_true", + default=False, + help="skip adding to env data" + ) + + parser.addoption( + "--skip-lanforge", + action="store_true", + default=False, + help="skip to do any interactions on lanforge (to be used in case of interop)" + ) + + # change behaviour + parser.addoption( + "--exit-on-fail", + action="store_true", + default=False, + help="skip updating firmware on the AP (useful for local testing)" + ) + + # change to Ucentral Ctlr + parser.addoption( + "--1.x", + action="store_true", + default=False, + help="Option to run Test Cases on 1.x SDK" + ) + + # change behaviour + parser.addoption( + "--force-upgrade", + action="store_true", + default=False, + help="force Upgrading Firmware even if it is already latest version" + ) + parser.addoption( + "--force-upload", + action="store_true", + default=False, + help="force Uploading Firmware even if it is already latest version" + ) + # this has to be the last argument + # example: --access-points ECW5410 EA8300-EU + parser.addoption( + "--testbed", + # nargs="+", + default="basic-01", + help="AP Model which is needed to test" + ) + parser.addoption( + "--use-testrail", + action="store_false", + default=True, + help="Stop using Testrails" + ) + parser.addoption( + "--run-lf", + action="store_true", + default=False, + help="skip cloud controller and AP, run only lanforge tests on a ssid preconfigured" + ) + parser.addoption( + "--cc.1", + action="store_true", + default=False, + help="Option to run Test Cases on cc version 1" + + ) + parser.addoption( + "--roaming_delay", + default=1, + help="Roaming delay interval" + ) + parser.addoption( + "--iteration", + default=1, + help="Roaming iterations" + ) + parser.addoption( + "--duration", + default=1, + help="Roaming duration in minutes" + ) + parser.addoption( + "--client", + default=1, + help="Number of clients to be created" + ) + parser.addoption( + "--skip-pcap", + action="store_true", + default=False, + help="skip packet capture for sanity" + ) + parser.addoption( + "--device", + default="iPhone-11", + help="Device Model which is needed to test" + ) + + # Perfecto Parameters + parser.addini("perfectoURL", "Cloud URL") + parser.addini("securityToken", "Security Token") + parser.addini("platformName-iOS", "iOS Platform") + parser.addini("platformName-android", "Android Platform") + parser.addini("model-iOS", "iOS Devices") + parser.addini("model-android", "Android Devices") + parser.addini("bundleId-iOS", "iOS Devices") + parser.addini("bundleId-iOS-Settings", "iOS Settings App") + parser.addini("appPackage-android", "Android Devices") + parser.addini("bundleId-iOS-Safari", "Safari BundleID") + parser.addini("wifi-SSID-2g-Pwd", "Wifi 2g Password") + parser.addini("Default-SSID-5gl-perfecto-b", "Wifi 5g AP Name") + parser.addini("Default-SSID-2g-perfecto-b", "Wifi 2g AP Name") + parser.addini("Default-SSID-perfecto-b", "Wifi AP Name") + parser.addini("bundleId-iOS-Ping", "Ping Bundle ID") + parser.addini("browserType-iOS", "Mobile Browser Name") + parser.addini("projectName", "Project Name") + parser.addini("projectVersion", "Project Version") + parser.addini("jobName", "CI Job Name") + parser.addini("jobNumber", "CI Job Number") + parser.addini("reportTags", "Report Tags") + parser.addoption( + "--access-points-perfecto", + # nargs="+", + default=["Perfecto"], + help="list of access points to test" + ) + + +""" +Test session base fixture +""" + +@pytest.fixture(scope="session") +def testbed(request): + """yields the testbed option selection""" + var = request.config.getoption("--testbed") + allure.attach(name="testbed name", body=var) + yield var + + +@pytest.fixture(scope="session") +def device(request): + """yields the device option selection""" + var = request.config.getoption("--device") + yield var + + +@pytest.fixture(scope="session") +def should_upload_firmware(request): + """yields the --force-upload option for firmware upload selection""" + yield request.config.getoption("--force-upload") + + +@pytest.fixture(scope="session") +def run_lf(request): + """yields the --run-lf option for skipping configuration on AP and using Cloud controller""" + var = request.config.getoption("--run-lf") + yield var + + +@pytest.fixture(scope="session") +def cc_1(request): + """yields the --cc.1 option for skipping configuration on AP and using Cloud controller of available framework""" + var = request.config.getoption("--cc.1") + yield var + + +@pytest.fixture(scope="session") +def roaming_delay(request): + """yields the --roaming_delay option """ + var = request.config.getoption("--roaming_delay") + allure.attach(name="roaming delay provided in seconds", body=str(var)) + yield var + + +@pytest.fixture(scope="session") +def iteration(request): + """yields the --iteration option for a test to provide how frequenty roam should happen """ + var = request.config.getoption("--iteration") + allure.attach(name="iteration", body=var) + yield var + + +@pytest.fixture(scope="session") +def duration(request): + """yields the --duration option for a test to provide how long roam should happen """ + var = request.config.getoption("--duration") + allure.attach(name="duration in minutes", body=str(var)) + yield var + + +@pytest.fixture(scope="session") +def client(request): + """yields the --client option for getting user specified client number""" + var = request.config.getoption("--client") + allure.attach(name="number of clients", body=var) + yield var + + +@pytest.fixture(scope="session") +def skip_pcap(request): + """yields the --skip-pcap option for skipping the packet capture for sanity""" + var = request.config.getoption("--skip-pcap") + yield var + + +@pytest.fixture(scope="session") +def should_upgrade_firmware(request): + """yields the --force-upgrade option for firmware upgrade selection""" + yield request.config.getoption("--force-upgrade") + + +@pytest.fixture(scope="session") +def exit_on_fail(request): + """yields the --exit-on-fail option for exiting the test case if it fails without teardown""" + yield request.config.getoption("--exit-on-fail") + + +@pytest.fixture(scope="session") +def radius_info(): + """yields the radius server information from lab info file""" + yield RADIUS_SERVER_DATA + + +@pytest.fixture(scope="session") +def radius_accounting_info(): + """yields the radius accounting information from lab info file""" + yield RADIUS_ACCOUNTING_DATA + + +@pytest.fixture(scope="session") +def rate_radius_info(): + """yields the radius server information from lab info file""" + yield RATE_LIMITING_RADIUS_SERVER_DATA + + +@pytest.fixture(scope="session") +def rate_radius_accounting_info(): + """yields the radius accounting information from lab info file""" + yield RATE_LIMITING_RADIUS_ACCOUNTING_DATA + + +@pytest.fixture(scope="session") +def get_configuration(testbed, request): + """yields the selected testbed information from lab info file (configuration.py)""" + if request.config.getini("cloud_ctlr") != "0": + CONFIGURATION[testbed]["controller"]["url"] = request.config.getini("cloud_ctlr") + if request.config.getini("firmware") != "0": + version = request.config.getini("firmware") + version_list = version.split(",") + for i in range(len(CONFIGURATION[testbed]["access_point"])): + CONFIGURATION[testbed]["access_point"][i]["version"] = version_list[0] + LOGGER.info("Selected the lab Info data: " + str((CONFIGURATION[testbed]))) + yield CONFIGURATION[testbed] + + +@pytest.fixture(scope="session") +def get_device_configuration(device, request): + """yields the selected device information from lab info file (configuration.py)""" + + LOGGER.info("Selected the lab Info data: " + str((PERFECTO_DETAILS[device]))) + print(PERFECTO_DETAILS[device]) + yield PERFECTO_DETAILS[device] + + +@pytest.fixture(scope="session") +def get_apnos(): + """yields the LIBRARY for APNOS, Reduces the use of imports across files""" + yield APNOS + + +@pytest.fixture(scope="session") +def get_equipment_ref(request, setup_controller, testbed, get_configuration): + """""" + if request.config.getoption("1.x"): + equipment_id_list = [] + for i in get_configuration['access_point']: + equipment_id_list.append(setup_controller.get_equipment_id( + serial_number=i['serial'])) + else: + equipment_id_list = [] + for i in get_configuration['access_point']: + equipment_id_list.append(i['serial']) + yield equipment_id_list + + +@pytest.fixture(scope="session") +def get_sdk_version(fixtures_ver, run_lf, cc_1): + version = "" + if not run_lf and not cc_1: + version = fixtures_ver.get_sdk_version() + print(version) + yield version + + +@pytest.fixture(scope="session") +def get_uci_show(fixtures_ver, get_apnos, get_configuration): + uci_show = fixtures_ver.get_uci_show(get_apnos, get_configuration) + yield uci_show + + +@pytest.fixture(scope="session") +def get_ap_version(fixtures_ver, get_apnos, get_configuration, cc_1): + if not cc_1: + ap_version = fixtures_ver.get_ap_version(get_apnos, get_configuration) + yield ap_version + else: + yield True + + +@pytest.fixture(scope="session") +def skip_lf(request): + yield request.config.getoption("--skip-lanforge") + + +@pytest.fixture(scope="session") +def get_openflow(): + yield open_flow + + +# Controller Fixture +@pytest.fixture(scope="session") +def setup_controller(request, get_configuration, add_env_properties, fixtures_ver): + """sets up the controller connection and yields the sdk_client object""" + sdk_client = fixtures_ver.controller_obj + if not cc_1: + request.addfinalizer(fixtures_ver.disconnect) + yield sdk_client + + +# Prov Controller Fixture +@pytest.fixture(scope="session") +def setup_prov_controller(request, get_configuration, add_env_properties, fixtures_ver): + """sets up the prov controller connection and yields the sdk_client object""" + sdk_client = fixtures_ver.prov_controller_obj + request.addfinalizer(fixtures_ver.disconnect) + yield sdk_client + + +@pytest.fixture(scope="session") +def setup_firmware(setup_controller): + """ Fixture to Setup Firmware with the selected sdk """ + setup_controller.instantiate_firmware() + yield True + + +@pytest.fixture(scope="session") +def instantiate_firmware(request, setup_controller, get_configuration): + """sets up firmware utility and yields the object for firmware upgrade""" + if request.config.getoption("--1.x"): + firmware_client_obj = [] + + for access_point_info in get_configuration['access_point']: + version = access_point_info["version"] + if request.config.getini("build").__contains__("https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/"): + version = request.config.getini("build") + firmware_client = FirmwareUtility(sdk_client=setup_controller, + model=access_point_info["model"], + version_url=version) + firmware_client_obj.append(firmware_client) + yield firmware_client_obj + else: + # 2.x + pass + + +@pytest.fixture(scope="session") +def get_latest_firmware(request, instantiate_firmware): + """yields the list of firmware version""" + if request.config.getoption("--1.x"): + fw_version_list = [] + try: + + for fw_obj in instantiate_firmware: + latest_firmware = fw_obj.get_fw_version() + latest_firmware = latest_firmware.replace(".tar.gz", "") + fw_version_list.append(latest_firmware) + except Exception as e: + print(e) + fw_version_list = [] + + yield fw_version_list + else: + # 2.x + pass + + +@pytest.fixture(scope="session") +def upload_firmware(request, should_upload_firmware, instantiate_firmware): + """yields the firmware_id that is uploaded to cloud""" + if request.config.getoption("--1.x"): + firmware_id_list = [] + for i in range(0, len(instantiate_firmware)): + firmware_id = instantiate_firmware[i].upload_fw_on_cloud(force_upload=should_upload_firmware) + firmware_id_list.append(firmware_id) + yield firmware_id_list + else: + # 2.x release + yield True + + +@pytest.fixture(scope="session") +def upgrade_firmware(request, instantiate_firmware, get_equipment_ref, check_ap_firmware_cloud, get_latest_firmware, + should_upgrade_firmware, should_upload_firmware, get_apnos, get_configuration): + """yields the status of upgrade of firmware. waits for 300 sec after each upgrade request""" + print(should_upgrade_firmware, should_upload_firmware) + if request.config.getoption("--1.x"): + status_list = [] + active_fw_list = [] + try: + for access_point in get_configuration['access_point']: + ap_ssh = get_apnos(access_point, sdk="1.x") + active_fw = ap_ssh.get_active_firmware() + active_fw_list.append(active_fw) + except Exception as e: + print(e) + active_fw_list = [] + print(active_fw_list, get_latest_firmware) + if get_latest_firmware != active_fw_list: + if request.config.getoption("--skip-upgrade"): + status = "skip-upgrade" + status_list.append(status) + else: + + for i in range(0, len(instantiate_firmware)): + status = instantiate_firmware[i].upgrade_fw(equipment_id=get_equipment_ref[i], force_upload=True, + force_upgrade=should_upgrade_firmware) + status_list.append(status) + else: + if should_upgrade_firmware: + for i in range(0, len(instantiate_firmware)): + status = instantiate_firmware[i].upgrade_fw(equipment_id=get_equipment_ref[i], + force_upload=should_upload_firmware, + force_upgrade=should_upgrade_firmware) + status_list.append(status) + else: + status = "skip-upgrade Version Already Available" + status_list.append(status) + yield status_list + else: + # 2.x release + pass + + +@pytest.fixture(scope="session") +def check_ap_firmware_cloud(request, setup_controller, get_equipment_ref): + """yields the active version of firmware on cloud""" + if request.config.getoption("--1.x"): + ap_fw_list = [] + for i in get_equipment_ref: + ap_fw_list.append(setup_controller.get_ap_firmware_old_method(equipment_id=i)) + yield ap_fw_list + else: + # 2.x + pass + + +@pytest.fixture(scope="session") +def check_ap_firmware_ssh(get_configuration, request): + """yields the active version of firmware on ap""" + if request.config.getoption("--1.x"): + active_fw_list = [] + try: + for access_point in get_configuration['access_point']: + ap_ssh = APNOS(access_point) + active_fw = ap_ssh.get_active_firmware() + active_fw_list.append(active_fw) + except Exception as e: + print(e) + active_fw_list = [] + yield active_fw_list + else: + # 2.x + pass + + +@pytest.fixture(scope="session") +def setup_test_run(setup_controller, request, upgrade_firmware, get_configuration, + get_equipment_ref, get_latest_firmware, + get_apnos): + """used to upgrade the firmware on AP and should be called on each test case on a module level""" + if request.config.getoption("--1.x"): + active_fw_list = [] + try: + for access_point in get_configuration['access_point']: + ap_ssh = get_apnos(access_point, sdk="1.x") + active_fw = ap_ssh.get_active_firmware() + active_fw_list.append(active_fw) + except Exception as e: + print(e) + active_fw_list = [] + print(active_fw_list, get_latest_firmware) + if active_fw_list == get_latest_firmware: + yield True + else: + pytest.exit("AP is not Upgraded tp Target Firmware versions") + else: + # 2.x + pass + + +""" +Instantiate Reporting +""" + + +@pytest.fixture(scope="session") +def update_report(request, testbed, get_configuration): + """used to update the test report on testrail/allure""" + if request.config.getoption("--use-testrail"): + tr_client = Reporting() + else: + tr_client = APIClient(request.config.getini("tr_url"), request.config.getini("tr_user"), + request.config.getini("tr_pass"), request.config.getini("tr_project_id")) + if request.config.getoption("--use-testrail"): + tr_client.rid = "skip testrails" + else: + projId = tr_client.get_project_id(project_name=request.config.getini("tr_project_id")) + test_run_name = request.config.getini("tr_prefix") + testbed + "_" + str( + datetime.date.today()) + "_" + get_configuration['access_point'][0]['version'] + tr_client.create_testrun(name=test_run_name, case_ids=list(TEST_CASES.values()), project_id=projId, + milestone_id=request.config.getini("milestone"), + description="Automated Nightly Sanity test run for new firmware build") + rid = tr_client.get_run_id(test_run_name=test_run_name) + tr_client.rid = rid + yield tr_client + + +""" +FRAMEWORK MARKER LOGIC +""" + + +@pytest.fixture(scope="session") +def get_security_flags(): + """used to get the essential markers on security and band""" + # Add more classifications as we go + security = ["open", "wpa", "wep", "wpa2_personal", "wpa3_personal", "wpa3_personal_mixed", + "wpa_wpa2_enterprise_mixed", "wpa2_eap", "wpa2_only_eap", + "wpa_wpa2_personal_mixed", "wpa_enterprise", "wpa2_enterprise", "wpa3_enterprise_mixed", + "wpa3_enterprise", "twog", "fiveg", "radius"] + yield security + + +@pytest.fixture(scope="session") +def get_markers(request, get_security_flags): + """used to get the markers on the selected test case class, used in setup_profiles""" + session = request.node + markers = list() + security = get_security_flags + security_dict = dict().fromkeys(security) + for item in session.items: + for j in item.iter_markers(): + markers.append(j.name) + for i in security: + if set(markers).__contains__(i): + security_dict[i] = True + else: + security_dict[i] = False + + yield security_dict + + +@pytest.fixture(scope="session") +def test_access_point(fixtures_ver, request, get_configuration, get_apnos): + """used to check the manager status of AP, should be used as a setup to verify if ap can reach cloud""" + status = fixtures_ver.get_ap_cloud_connectivity_status(get_configuration, get_apnos) + + def teardown_session(): + data = [] + data.append(False) + for s in status: + data.append(s[0]) + print(data) + if False not in data: + pytest.exit("AP is Not connected to ucentral gw") + allure.attach(name=str(status), body="") + + request.addfinalizer(teardown_session) + yield status + + +@pytest.fixture(scope="session") +def test_ap_connection_status(fixtures_ver, request, get_configuration, get_apnos): + """used to check the manager status of AP, should be used as a setup to verify if ap can reach cloud""" + connection, redirector_value = fixtures_ver.get_ap_status_logs(get_configuration, get_apnos) + yield connection, redirector_value + + +@pytest.fixture(scope="session") +def traffic_generator_connectivity(testbed, get_configuration): + """Verify if traffic generator is reachable""" + if get_configuration['traffic_generator']['name'] == "lanforge": + lanforge_ip = get_configuration['traffic_generator']['details']['ip'] + lanforge_port = get_configuration['traffic_generator']['details']['port'] + # Condition : + # if gui connection is not available + # yield False + # Condition : + # If Gui Connection is available + # yield the gui version + try: + cv = cv_test(lanforge_ip, lanforge_port) + url_data = cv.get_ports("/") + lanforge_GUI_version = url_data["VersionInfo"]["BuildVersion"] + lanforge_gui_git_version = url_data["VersionInfo"]["GitVersion"] + lanforge_gui_build_date = url_data["VersionInfo"]["BuildDate"] + print(lanforge_GUI_version, lanforge_gui_build_date, lanforge_gui_git_version) + if not (lanforge_GUI_version or lanforge_gui_build_date or lanforge_gui_git_version): + yield False + else: + yield lanforge_GUI_version + except: + yield False + else: + yield True + + +@pytest.fixture(scope="session") +def create_lanforge_chamberview_dut(lf_tools, skip_lf, run_lf): + dut_name = "" + if (not run_lf) and (not skip_lf): + dut_object, dut_name = lf_tools.Create_Dut() + return dut_name + + +@pytest.fixture(scope="session") +def lf_tools(get_configuration, testbed, skip_lf, run_lf, get_ap_version, cc_1): + """ Create a DUT on LANforge""" + if not skip_lf: + obj = ChamberView(lanforge_data=get_configuration["traffic_generator"]["details"], + testbed=testbed, run_lf=run_lf, access_point_data=get_configuration["access_point"], + cc_1=cc_1, ap_version=get_ap_version) + else: + obj = False + yield obj + + +@pytest.fixture(scope="session") +def lf_reports(): + obj = Report() + yield obj + + +@pytest.fixture(scope="session") +def lf_test(get_configuration, setup_influx, request, skip_lf, run_lf, skip_pcap): + if not skip_lf: + if request.config.getoption("--exit-on-fail"): + obj = RunTest(configuration_data=get_configuration, influx_params=setup_influx, + debug=True, run_lf=run_lf, skip_pcap=skip_pcap) + if request.config.getoption("--exit-on-fail") is False: + obj = RunTest(configuration_data=get_configuration, influx_params=setup_influx, + debug=False, run_lf=run_lf, skip_pcap=skip_pcap) + yield obj + + +@pytest.fixture(scope="session") +def setup_influx(request, testbed, get_configuration): + """ Setup Influx Parameters: Used in CV Automation""" + influx_params = { + "influx_host": request.config.getini("influx_host"), + "influx_port": request.config.getini("influx_port"), + "influx_token": request.config.getini("influx_token"), + "influx_bucket": request.config.getini("influx_bucket"), + "influx_org": request.config.getini("influx_org"), + "influx_tag": [testbed, get_configuration["access_point"][0]["model"]], + } + yield influx_params + + +# Need for Perforce Mobile Device Execution +def pytest_sessionstart(session): + session.results = dict() + + +@fixture(scope='session', autouse=True) +def add_allure_environment_property(request: SubRequest) -> Optional[Callable]: + environment_properties = dict() + + def maker(key: str, value: Any): + environment_properties.update({key: value}) + + yield maker + + alluredir = request.config.getoption(ALLUREDIR_OPTION) + + if not alluredir or not os.path.isdir(alluredir) or not environment_properties: + return + + allure_env_path = path.join(alluredir, ALLURE_ENVIRONMENT_PROPERTIES_FILE) + + with open(allure_env_path, 'w') as _f: + data = '\n'.join([f'{variable}={value}' for variable, value in environment_properties.items()]) + _f.write(data) + + +@fixture(scope='session') +def add_env_properties(request, get_configuration, get_sdk_version, get_apnos, fixtures_ver, cc_1, + add_allure_environment_property: Callable) -> None: + if request.config.getoption("--skip-env"): + add_allure_environment_property('Cloud-Controller-SDK-URL', get_configuration["controller"]["url"]) + return + if cc_1: + for i in range(len(get_configuration["access_point"])): + add_allure_environment_property(str('Access-Point-Model' + str(i + 1)), + get_configuration["access_point"][i]["model"]) + else: + add_allure_environment_property('Access-Point-Model', get_configuration["access_point"][0]["model"]) + add_allure_environment_property('SDK-Version', get_sdk_version) + try: + if not cc_1: + add_allure_environment_property('Access-Point-Firmware-Version', + fixtures_ver.get_ap_version(get_apnos, get_configuration)[0].split("\n")[1]) + except Exception as e: + print(e) + pass + if cc_1: + listkey = list(get_configuration["controller"].keys()) + if "version" in listkey: + add_allure_environment_property('Cloud-Controller-SDK-URL', get_configuration["controller"]["url"]) + add_allure_environment_property('Controller-Version', get_configuration["controller"]["version"]) + for i in range(len(get_configuration["access_point"])): + add_allure_environment_property(str('AP-Name-' + str(i + 1)), + get_configuration["access_point"][i]["ap_name"]) + for i in range(len(get_configuration["access_point"])): + add_allure_environment_property(str('AP-Serial-Number-' + str(i + 1)), + get_configuration["access_point"][i]["serial"]) + add_allure_environment_property('LANforge-Chipset-Info', + get_configuration["traffic_generator"]["details"]["Chip-set-info"]) + else: + pass + else: + add_allure_environment_property('Cloud-Controller-SDK-URL', get_configuration["controller"]["url"]) + add_allure_environment_property('AP-Serial-Number', get_configuration["access_point"][0]["serial"] + "\n") + + +@fixture(scope="session") +def add_firmware_property_after_upgrade(add_allure_environment_property, fixtures_ver, get_apnos, + get_configuration): + # try: + add_allure_environment_property('Access-Point-Firmware-Version', + fixtures_ver.get_ap_version(get_apnos, get_configuration)[0].split("\n")[1]) + # except Exception as e: + # print(e) + # pass + + +@pytest.fixture(scope="session") +def fixtures_ver(request, get_configuration, run_lf, cc_1): + if request.config.getoption("1.x") is False and request.config.getoption("cc.1") is False: + print("2.x") + obj = Fixtures_2x(configuration=get_configuration, run_lf=run_lf) + if request.config.getoption("1.x"): + print("1.x") + obj = Fixtures_1x(configuration=get_configuration) + if request.config.getoption("cc.1"): + print(" fixture version cc.1") + obj = Fixtures_3x(configuration=get_configuration, run_lf=run_lf, cc_1=cc_1) + yield obj + + +@pytest.fixture(scope="session") +def firmware_upgrade(fixtures_ver, get_apnos, get_configuration): + upgrade_status = fixtures_ver.setup_firmware(get_apnos, get_configuration) + yield upgrade_status + + +""" +Logs related Fixtures +""" + + +@pytest.fixture(scope="function") +def get_ap_logs(request, get_apnos, get_configuration, run_lf): + if not run_lf: + S = 9 + instance_name = ''.join(random.choices(string.ascii_uppercase + string.digits, k=S)) + for ap in get_configuration['access_point']: + ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x") + ap_ssh.run_generic_command(cmd="logger start testcase: " + instance_name) + + # Adding memory Profile code before every test start + output = ap_ssh.get_memory_profile() + allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) + + def collect_logs(): + for ap in get_configuration['access_point']: + ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x") + ap_ssh.run_generic_command(cmd="logger stop testcase: " + instance_name) + ap_logs = ap_ssh.get_logread(start_ref="start testcase: " + instance_name, + stop_ref="stop testcase: " + instance_name) + allure.attach(name='logread', body=str(ap_logs)) + + # Adding memory Profile code after every test completion + output = ap_ssh.get_memory_profile() + allure.attach(name="ucode /usr/share/ucentral/sysinfo.uc ", body=str(output)) + + request.addfinalizer(collect_logs) + + +@pytest.fixture(scope="function") +def get_lf_logs(request, get_apnos, get_configuration): + ip = get_configuration["traffic_generator"]["details"]["ip"] + port = get_configuration["traffic_generator"]["details"]["ssh_port"] + + def collect_logs_lf(): + log_0 = "/home/lanforge/lanforge_log_0.txt" + log_1 = "/home/lanforge/lanforge_log_1.txt" + obj = SCP_File(ip=ip, port=port, username="root", password="lanforge", remote_path=log_0, + local_path=".") + obj.pull_file() + allure.attach.file(source="lanforge_log_0.txt", + name="lanforge_log_0") + obj = SCP_File(ip=ip, port=port, username="root", password="lanforge", remote_path=log_1, + local_path=".") + obj.pull_file() + allure.attach.file(source="lanforge_log_1.txt", + name="lanforge_log_1") + + request.addfinalizer(collect_logs_lf) + + +@pytest.fixture(scope="function") +def get_apnos_logs(get_apnos, get_configuration): + all_logs = [] + for ap in get_configuration['access_point']: + ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x") + logs = ap_ssh.logread() + all_logs.append(logs) + yield all_logs + + +@pytest.fixture(scope="function") +def get_controller_logs(get_configuration, ): + obj = CController(controller_data=get_configuration['controller'], ap_data=get_configuration['access_point']) + summary = obj.show_ap_summary() + print(summary) + allure.attach(name='show ap summary', body=str(summary)) + + +@pytest.fixture(scope="function") +def get_ap_config_slots(get_configuration): + obj = CController(controller_data=get_configuration['controller'], ap_data=get_configuration['access_point']) + slot = obj.show_ap_config_slots() + # print(slot) + allure.attach(name="ap_slots", body=str(slot)) + + +@pytest.fixture(scope="session") +def get_apnos_max_clients(get_apnos, get_configuration): + all_logs = [] + for ap in get_configuration['access_point']: + ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x") + ap_ssh.run_generic_command(cmd="chmod +x /usr/share/ucentral/wifi_max_user.uc") + a = ap_ssh.run_generic_command(cmd="/usr/share/ucentral/wifi_max_user.uc") + try: + all_logs.append(a[1]) + except Exception as e: + pass + yield all_logs + + +@pytest.fixture(scope="function") +def get_ap_channel(get_apnos, get_configuration): + all_data = [] + dict_band_channel = {} + for ap in get_configuration['access_point']: + ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x") + a = ap_ssh.run_generic_command(cmd="iw dev | grep channel") + print("ap command output:- ", a) + try: + a = a[1:] + for i in a: + if i == '': + continue + j = int(re.findall('\d+', i)[0]) + print(j) + if j >= 36: + dict_band_channel["5G"] = j + continue + elif j < 36: + dict_band_channel["2G"] = j + continue + if not "2G" in dict_band_channel: + dict_band_channel["2G"] = "AUTO" + if not "5G" in dict_band_channel: + dict_band_channel["5G"] = "AUTO" + all_data.append(dict_band_channel) + except Exception as e: + print(e) + pass + print(all_data) + yield all_data + + +@pytest.fixture(scope="function") +def disable_band5ghz(get_configuration): + obj = CController(controller_data=get_configuration['controller'], ap_data=get_configuration['access_point']) + shut = obj.ap_5ghz_shutdown() + print(shut) + + +@pytest.fixture(scope="function") +def disable_band2ghz(get_configuration): + obj = CController(controller_data=get_configuration['controller'], ap_data=get_configuration['access_point']) + shut = obj.ap_2ghz_shutdown() + print(shut) + + +@pytest.fixture(scope="function") +def disable_band6ghz(get_configuration): + obj = CController(controller_data=get_configuration['controller'], ap_data=get_configuration['access_point']) + shut = obj.ap_6ghz_shutdown() + print(shut) + + +@pytest.fixture(scope="function") +def enable_all_bands(get_configuration): + obj = CController(controller_data=get_configuration['controller'], ap_data=get_configuration['access_point']) + obj.no_ap_5ghz_shutdown() + obj.no_ap_2ghz_shutdown() + obj.no_ap_6ghz_shutdown() diff --git a/tests/e2e/interOp/conftest.py b/tests/e2e/interOp/conftest.py index 679dde2ba..d1473ce8e 100644 --- a/tests/e2e/interOp/conftest.py +++ b/tests/e2e/interOp/conftest.py @@ -1,730 +1,730 @@ -import datetime -import sys -import os -import time -import warnings -from selenium.common.exceptions import NoSuchElementException -import urllib3 -from perfecto.model.model import Job, Project -from perfecto import (PerfectoExecutionContext, PerfectoReportiumClient, TestContext, TestResultFactory) -import pytest -import logging -import re -import allure -import requests -from xml.etree import ElementTree as ET -from time import gmtime, strftime - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -if "libs" not in sys.path: - sys.path.append(f'../libs') -import allure -from apnos.apnos import APNOS -from controller.controller_1x.controller import Controller -from controller.controller_1x.controller import ProfileUtility -from controller.controller_2x.controller import UProfileUtility -from controller.controller_1x.controller import FirmwareUtility -import pytest -import logging -from configuration import RADIUS_SERVER_DATA - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -if "tests" not in sys.path: - sys.path.append(f'../tests') - -from configuration import CONFIGURATION -from configuration import PERFECTO_DETAILS - -from urllib3 import exceptions - -reporting_client = None -testCaseNameList = [] -testCaseStatusList = [] -testCaseErrorMsg = [] -testCaseReportURL = [] - - -@pytest.fixture(scope="function") -def get_PassPointConniOS_data(request, get_device_configuration): - passPoint_data = { - "netAnalyzer-inter-Con-Xpath": "//*[@label='Network Connected']/parent::*/XCUIElementTypeButton", - "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], - "bundleId-iOS-Ping": get_device_configuration["bundleId-iOS-Ping"] - } - yield passPoint_data - - -@pytest.fixture(scope="function") -def get_APToMobileDevice_data(request, get_device_configuration): - passPoint_data = { - "webURL": "https://www.google.com", - "lblSearch": "//*[@class='gLFyf']", - "elelSearch": "(//*[@class='sbic sb43'])[1]", - "BtnRunSpeedTest": "//*[text()='RUN SPEED TEST']", - "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], - "bundleId-iOS-Safari": get_device_configuration["bundleId-iOS-Safari"], - "downloadMbps": "//*[@id='knowledge-verticals-internetspeedtest__download']/P[@class='spiqle']", - "UploadMbps": "//*[@id='knowledge-verticals-internetspeedtest__upload']/P[@class='spiqle']", - # Android - "platformName-android": get_device_configuration["platformName-android"], - "appPackage-android": get_device_configuration["appPackage-android"] - } - yield passPoint_data - - -@pytest.fixture(scope="function") -def get_AccessPointConn_data(request, get_device_configuration): - passPoint_data = { - "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], - "bundleId-iOS-Ping": get_device_configuration["bundleId-iOS-Ping"] - } - yield passPoint_data - - -@pytest.fixture(scope="function") -def get_ToggleAirplaneMode_data(request, get_device_configuration): - passPoint_data = { - "webURL": "https://www.google.com", - "lblSearch": "//*[@class='gLFyf']", - "elelSearch": "(//*[@class='sbic sb43'])[1]", - "BtnRunSpeedTest": "//*[text()='RUN SPEED TEST']", - "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], - "bundleId-iOS-Safari": get_device_configuration["bundleId-iOS-Safari"], - "downloadMbps": "//*[@id='knowledge-verticals-internetspeedtest__download']/P[@class='spiqle']", - "UploadMbps": "//*[@id='knowledge-verticals-internetspeedtest__upload']/P[@class='spiqle']", - # Android - "platformName-android": get_device_configuration["platformName-android"], - "appPackage-android": get_device_configuration["appPackage-android"] - } - yield passPoint_data - - -@pytest.fixture(scope="function") -def get_ToggleWifiMode_data(request,get_device_configuration): - passPoint_data = { - # iOS - "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], - # Android - "platformName-android": get_device_configuration["platformName-android"], - "appPackage-android": get_device_configuration["appPackage-android"] - } - yield passPoint_data - - -@pytest.fixture(scope="function") -def get_lanforge_data(testbed): - lanforge_data = {} - if CONFIGURATION[testbed]['traffic_generator']['name'] == 'lanforge': - lanforge_data = { - "lanforge_ip": CONFIGURATION[testbed]['traffic_generator']['details']['ip'], - "lanforge-port-number": CONFIGURATION[testbed]['traffic_generator']['details']['port'], - "lanforge_2dot4g": CONFIGURATION[testbed]['traffic_generator']['details']['2.4G-Radio'][0], - "lanforge_5g": CONFIGURATION[testbed]['traffic_generator']['details']['5G-Radio'][0], - "lanforge_2dot4g_prefix": CONFIGURATION[testbed]['traffic_generator']['details']['2.4G-Station-Name'], - "lanforge_5g_prefix": CONFIGURATION[testbed]['traffic_generator']['details']['5G-Station-Name'], - "lanforge_2dot4g_station": CONFIGURATION[testbed]['traffic_generator']['details']['2.4G-Station-Name'], - "lanforge_5g_station": CONFIGURATION[testbed]['traffic_generator']['details']['5G-Station-Name'], - "lanforge_bridge_port": CONFIGURATION[testbed]['traffic_generator']['details']['upstream'], - "lanforge_vlan_port": CONFIGURATION[testbed]['traffic_generator']['details']['upstream'] + ".100", - "vlan": 100 - } - yield lanforge_data - - -@pytest.fixture(scope="session") -def instantiate_profile(request): - if request.config.getoption("1.x"): - yield ProfileUtility - else: - yield UProfileUtility - - - -@pytest.fixture(scope="session") -def upload_firmware(should_upload_firmware, instantiate_firmware, get_latest_firmware): - firmware_id = instantiate_firmware.upload_fw_on_cloud(fw_version=get_latest_firmware, - force_upload=should_upload_firmware) - yield firmware_id - - -@pytest.fixture(scope="session") -def upgrade_firmware(request, instantiate_firmware, get_equipment_ref, check_ap_firmware_cloud, get_latest_firmware, - should_upgrade_firmware): - if get_latest_firmware != check_ap_firmware_cloud: - if request.config.getoption("--skip-upgrade"): - status = "skip-upgrade" - else: - status = instantiate_firmware.upgrade_fw(equipment_id=get_equipment_ref, force_upload=False, - force_upgrade=should_upgrade_firmware) - else: - if should_upgrade_firmware: - status = instantiate_firmware.upgrade_fw(equipment_id=get_equipment_ref, force_upload=False, - force_upgrade=should_upgrade_firmware) - else: - status = "skip-upgrade" - yield status - - -@pytest.fixture(scope="session") -def check_ap_firmware_cloud(setup_controller, get_equipment_ref): - yield setup_controller.get_ap_firmware_old_method(equipment_id=get_equipment_ref) - - -""" - -Profiles Related Fixtures - -""" - - -@pytest.fixture(scope="module") -def get_current_profile_cloud(instantiate_profile): - ssid_names = [] - for i in instantiate_profile.profile_creation_ids["ssid"]: - ssid_names.append(instantiate_profile.get_ssid_name_by_profile_id(profile_id=i)) - yield ssid_names - - -@pytest.fixture(scope="session") -def setup_vlan(): - vlan_id = [100] - yield vlan_id[0] - - -@pytest.fixture(scope="class") -def setup_profiles(request, setup_controller, testbed, get_equipment_ref, fixtures_ver, skip_lf, get_openflow, run_lf, - instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info): - - param = dict(request.param) - if not skip_lf: - lf_tools.reset_scenario() - # VLAN Setup - if request.param["mode"] == "VLAN": - - vlan_list = list() - refactored_vlan_list = list() - ssid_modes = request.param["ssid_modes"].keys() - for mode in ssid_modes: - for ssid in range(len(request.param["ssid_modes"][mode])): - if "vlan" in request.param["ssid_modes"][mode][ssid]: - vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) - else: - pass - if vlan_list: - [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] - vlan_list = refactored_vlan_list - for i in range(len(vlan_list)): - if vlan_list[i] > 4095 or vlan_list[i] < 1: - vlan_list.pop(i) - if request.param["mode"] == "VLAN": - lf_tools.add_vlan(vlan_ids=vlan_list) - - # call this, if 1.x - return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_ref, - instantiate_profile, - get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, - radius_accounting_info, skip_lf=skip_lf, open_flow=get_openflow, run_lf=run_lf) - print("sleeping for 120 sec.") - time.sleep(180) - print("Done sleeping") - yield return_var - - -@pytest.fixture(scope="function") -def update_ssid(request, instantiate_profile, setup_profile_data): - requested_profile = str(request.param).replace(" ", "").split(",") - profile = setup_profile_data[requested_profile[0]][requested_profile[1]][requested_profile[2]] - status = instantiate_profile.update_ssid_name(profile_name=profile["profile_name"], - new_profile_name=requested_profile[3]) - setup_profile_data[requested_profile[0]][requested_profile[1]][requested_profile[2]]["profile_name"] = \ - requested_profile[3] - setup_profile_data[requested_profile[0]][requested_profile[1]][requested_profile[2]]["ssid_name"] = \ - requested_profile[3] - time.sleep(90) - yield status - - -# @pytest.fixture(scope="module", autouse=True) -def failure_tracking_fixture(request): - tests_failed_before_module = request.session.testsfailed - print("\n\ntests_failed_before_module: ") - print(tests_failed_before_module) - tests_failed_during_module = request.session.testsfailed - tests_failed_before_module - print("tests_failed_during_module: ") - print(tests_failed_during_module) - yield tests_failed_during_module - - - -empty_get_vif_state_list = [] - -@pytest.fixture(scope="class") -def get_vif_state(get_apnos, get_configuration, request, lf_tools, skip_lf): - if not skip_lf: - if request.config.getoption("1.x"): - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") - vif_state = list(ap_ssh.get_vif_state_ssids()) - vif_state.sort() - yield vif_state - else: - yield lf_tools.ssid_list - else: - yield empty_get_vif_state_list - -@pytest.hookimpl(tryfirst=True, hookwrapper=True) -def pytest_runtest_makereport(item, call): - outcome = yield - result = outcome.get_result() - # testCaseStatusValue = "" - testCasePassedStatusValue = "" - testCaseFailedStatusValue = "" - testCaseNameList = [] - testCaseStatusList = [] - testCaseErrorMsg = [] - testCaseReportURL = [] - - if os.environ.get('PYTEST_CURRENT_TEST') is not None: - if (str(os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]).strip()).startswith("test_unique"): - return 0 - - # if os.environ.get('PYTEST_CURRENT_TEST') is not None and ((os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]).strip()).startswith("test_unique_ssid"): - # return 0; - - if result.when == 'call': - item.session.results[item] = result - - # Gets the Current Test Case Name - TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] - nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) - # print("TestCasefullNameTEST: " + TestCaseFullName) - try: - # TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') - TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') - # print ("\nTestCaseName: " + TestCaseName) - except Exception as e: - TestCaseName = nCurrentTestMethodNameSplit - print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") - # print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") - - # exception = call.excinfo.value - # exception_class = call.excinfo.type - # exception_class_name = call.excinfo.typename - - # exception_traceback = call.excinfo.traceback - - if result.outcome == "failed": - exception_type_and_message_formatted = call.excinfo.exconly() - testCaseFailedStatusValue = "FAILED" - reporting_client.test_stop(TestResultFactory.create_failure(str(testCaseErrorMsg))) - testCaseNameList.append(TestCaseName) - testCaseStatusList.append(testCaseFailedStatusValue) - testCaseErrorMsg.append(exception_type_and_message_formatted) - testCaseReportURL.append(reporting_client.report_url()) - - print("\n TestStatus: " + testCaseFailedStatusValue) - print(" FailureMsg: " + str(testCaseErrorMsg)) - reportPerfecto(TestCaseName, testCaseFailedStatusValue, testCaseErrorMsg, - str(reporting_client.report_url())) - - if result.outcome == "passed": - testCasePassedStatusValue = "PASSED" - reporting_client.test_stop(TestResultFactory.create_success()) - testCaseNameList.append(TestCaseName) - testCaseStatusList.append(testCasePassedStatusValue) - testCaseReportURL.append(reporting_client.report_url()) - print("\n TestStatus: " + testCasePassedStatusValue) - reportPerfecto(TestCaseName, testCasePassedStatusValue, "N/A", str(reporting_client.report_url())) - - if result.outcome == "skipped": - testCaseSkippedStatusValue = "SKIPPED" - exception_type_Skipped_message_formatted = call.excinfo.exconly() - reporting_client.test_stop(TestResultFactory.create_failure(str(exception_type_Skipped_message_formatted))) - testCaseNameList.append(TestCaseName) - testCaseStatusList.append("SKIPPED") - testCaseErrorMsg.append(str(exception_type_Skipped_message_formatted)) - testCaseReportURL.append(reporting_client.report_url()) - print("\n TestStatus: " + testCaseSkippedStatusValue) - print(" FailureMsg: " + str(testCaseErrorMsg)) - reportPerfecto(TestCaseName, testCaseSkippedStatusValue, testCaseErrorMsg, - str(reporting_client.report_url())) - - -def pytest_sessionfinish(session, exitstatus): - - try: - if reporting_client is not None: - print() - skipped_amount = 0 - # print('Perfecto TestCase Execution Status:', exitstatus) - passed_amount = sum(1 for result in session.results.values() if result.passed) - failed_amount = sum(1 for result in session.results.values() if result.failed) - skipped_amount = sum(1 for result in session.results.values() if result.skipped) - # print(f'There are {passed_amount} passed and {failed_amount} failed tests') - TotalExecutedCount = failed_amount + passed_amount + skipped_amount - - print('\n------------------------------------') - print('TestCase Execution Summary') - print('------------------------------------') - print('Total TestCase Executed: ' + str(TotalExecutedCount)) - print('Total Passed: ' + str(passed_amount)) - print('Total Failed: ' + str(failed_amount)) - print('Total Skipped: ' + str(skipped_amount) + "\n") - try: - for index in range(len(testCaseNameList)): - print(str(index + 1) + ") " + str(testCaseNameList[index]) + " : " + str(testCaseStatusList[index])) - print(" ReportURL: " + str(testCaseReportURL[index])) - print(" FailureMsg: " + str(testCaseErrorMsg[index]) + "\n") - except Exception as e: - print('No Interop Test Cases Executed') - else: - pass - - except Exception as e: - pass - print('\n------------------------------------------------------------------\n\n\n\n') - - -@pytest.fixture(scope="function") -def setup_perfectoMobile_android(request, get_device_configuration): - from appium import webdriver - driver = None - reporting_client = None - - warnings.simplefilter("ignore", ResourceWarning) - urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) - - capabilities = { - 'platformName': get_device_configuration["platformName-android"], - 'model': get_device_configuration["model-android"], - 'browserName': 'mobileOS', - # 'automationName' : 'Appium', - 'securityToken': PERFECTO_DETAILS["securityToken"], - 'useAppiumForWeb': 'false', - 'useAppiumForHybrid': 'false', - # 'bundleId' : request.config.getini("appPackage-android"), - } - - if not is_device_Available_timeout(request, capabilities['model']): - print("Unable to get device.") - pytest.exit("Exiting Pytest") - - driver = webdriver.Remote( - 'https://' + PERFECTO_DETAILS["perfectoURL"] + '.perfectomobile.com/nexperience/perfectomobile/wd/hub', - capabilities) - driver.implicitly_wait(2) - - TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] - nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) - try: - # TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') - TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') - print("\n\nExecuting TestCase: " + TestCaseName) - except Exception as e: - TestCaseName = nCurrentTestMethodNameSplit - print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") - # print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") - - projectname = PERFECTO_DETAILS["projectName"] - projectversion = PERFECTO_DETAILS["projectVersion"] - jobname = get_device_configuration["jobName"] - jobnumber = get_device_configuration["jobNumber"] - tags = PERFECTO_DETAILS["reportTags"] - testCaseName = TestCaseName - - # print("\nSetting Perfecto ReportClient....") - perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber), - Project(projectname, projectversion)) - reporting_client = PerfectoReportiumClient(perfecto_execution_context) - reporting_client.test_start(testCaseName, TestContext([], "Perforce")) - reportClient(reporting_client) - - try: - params = {'property': 'model'} - deviceModel = driver.execute_script('mobile:handset:info', params) - except: - pass - - def teardown(): - try: - print("\n---------- Tear Down ----------") - try: - params = {'property': 'model'} - deviceModel = driver.execute_script('mobile:handset:info', params) - allure.dynamic.link( - str(reporting_client.report_url()), - name=str(deviceModel)) - except: - print("fail to attach video link") - - print('Report-Url: ' + reporting_client.report_url()) - - print("----------------------------------------------------------\n\n\n\n") - driver.close() - except Exception as e: - print(" -- Exception While Tear Down --") - driver.close() - print(e) - finally: - try: - driver.quit() - except Exception as e: - print(" -- Exception Not Able To Quit --") - print(e) - - request.addfinalizer(teardown) - - if driver is None: - yield -1 - else: - yield driver, reporting_client - - -def reportClient(value): - global reporting_client # declare a to be a global - reporting_client = value # this sets the global value of a - - -def reportPerfecto(testCaseName, testCaseStatus, testErrorMsg, reportURL): - global testCaseNameList # declare a to be a global - global testCaseStatusList - global testCaseErrorMsg - global testCaseReportURL - - testCaseNameList.append(testCaseName) - testCaseStatusList.append(testCaseStatus) - testCaseErrorMsg.append(str(testErrorMsg)) - testCaseReportURL.append(reportURL) - - -@pytest.fixture(scope="class") -def setup_perfectoMobileWeb(request, get_device_configuration): - from selenium import webdriver - rdriver = None - reporting_client = None - - warnings.simplefilter("ignore", ResourceWarning) - urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) - - capabilities = { - 'platformName': get_device_configuration["platformName-iOS"], - 'model': get_device_configuration["model-iOS"], - 'browserName': get_device_configuration["browserType-iOS"], - 'securityToken': get_device_configuration["securityToken"], - } - - if not is_device_Available_timeout(request, capabilities['model']): - print("Unable to get device.") - pytest.exit("Exiting Pytest") - - rdriver = webdriver.Remote( - 'https://' + PERFECTO_DETAILS["perfectoURL"] + '.perfectomobile.com/nexperience/perfectomobile/wd/hub', - capabilities) - rdriver.implicitly_wait(2) - - projectname = PERFECTO_DETAILS["projectName"] - projectversion = PERFECTO_DETAILS["projectVersion"] - jobname = get_device_configuration["jobName"] - jobnumber = get_device_configuration["jobNumber"] - tags = PERFECTO_DETAILS["reportTags"] - testCaseName = get_device_configuration["jobName"] - - print("Setting Perfecto ReportClient....") - perfecto_execution_context = PerfectoExecutionContext(rdriver, tags, Job(jobname, jobnumber), - Project(projectname, projectversion)) - reporting_client = PerfectoReportiumClient(perfecto_execution_context) - reporting_client.test_start(testCaseName, TestContext([], "Perforce")) - - def teardown(): - try: - print(" -- Tear Down --") - reporting_client.test_stop(TestResultFactory.create_success()) - print('Report-Url: ' + reporting_client.report_url() + '\n') - rdriver.close() - except Exception as e: - print(" -- Exception Not Able To close --") - print(e.message) - finally: - try: - rdriver.quit() - except Exception as e: - print(" -- Exception Not Able To Quit --") - print(e.message) - - request.addfinalizer(teardown) - - if rdriver is None: - yield -1 - else: - yield rdriver, reporting_client - - -@pytest.fixture(scope="function") -def setup_perfectoMobile_iOS(request, get_device_configuration): - from appium import webdriver - driver = None - reporting_client = None - - warnings.simplefilter("ignore", ResourceWarning) - urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) - - capabilities = { - 'platformName': get_device_configuration["platformName-iOS"], - 'model': get_device_configuration["model-iOS"], - 'browserName': 'safari', - # 'automationName' : 'Appium', - 'securityToken': PERFECTO_DETAILS["securityToken"], - 'useAppiumForWeb': 'false', - 'autoAcceptAlerts': 'true', - # 'bundleId' : request.config.getini("bundleId-iOS"), - 'useAppiumForHybrid': 'false', - } - - # Check if the device is available - if not is_device_Available_timeout(request, capabilities['model']): - print("Unable to get device.") - pytest.exit("Exiting Pytest") - - driver = webdriver.Remote( - 'https://' + PERFECTO_DETAILS["perfectoURL"] + '.perfectomobile.com/nexperience/perfectomobile/wd/hub', - capabilities) - driver.implicitly_wait(2) - - TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] - nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) - try: - # TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') - TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') - print("\n\nExecuting TestCase: " + TestCaseName) - except Exception as e: - TestCaseName = nCurrentTestMethodNameSplit - print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") - # print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") - - projectname = PERFECTO_DETAILS["projectName"] - projectversion = PERFECTO_DETAILS["projectVersion"] - jobname = get_device_configuration["jobName"] - jobnumber = get_device_configuration["jobNumber"] - tags = PERFECTO_DETAILS["reportTags"] - testCaseName = TestCaseName - - print("\nSetting Perfecto ReportClient....") - perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber), - Project(projectname, projectversion)) - reporting_client = PerfectoReportiumClient(perfecto_execution_context) - reporting_client.test_start(testCaseName, TestContext([], "Perforce")) - reportClient(reporting_client) - try: - params = {'property': 'model'} - deviceModel = driver.execute_script('mobile:handset:info', params) - except: - pass - - def teardown(): - try: - print("\n---------- Tear Down ----------") - print('Report-Url: ' + reporting_client.report_url()) - try: - allure.dynamic.link( - str(reporting_client.report_url()), - name=str(deviceModel)) - except: - print("fail to attach video link") - print("----------------------------------------------------------\n\n\n\n") - driver.close() - except Exception as e: - print(" -- Exception While Tear Down --") - driver.close() - print(e) - finally: - try: - driver.quit() - except Exception as e: - print(" -- Exception Not Able To Quit --") - print(e) - - request.addfinalizer(teardown) - - if driver is None: - yield -1 - else: - yield driver, reporting_client -# Does a HTTP GET request to Perfecto cloud and gets response and information related to a headset -def response_device(request, model): - securityToken = PERFECTO_DETAILS["securityToken"] - perfectoURL = PERFECTO_DETAILS["perfectoURL"] - url = f"https://{perfectoURL}.perfectomobile.com/services/handsets?operation=list&securityToken={securityToken}&model={model}" - resp = requests.get(url=url) - return ET.fromstring(resp.content) - -# Get an attribute value from the handset response -def get_attribute_device(responseXml, attribute): - try: - return responseXml.find('handset').find(attribute).text - except: - print(f"Unable to get value of {attribute} from response") - return "" - -# Checks to see if a particular handset is available -def is_device_available(request, model): - try: - responseXml = response_device(request, model) - except: - print("Unable to get response.") - raise Exception("Unable to get response.") - device_available = get_attribute_device(responseXml, 'available') - print("Result:" + device_available) - if device_available == 'true': - return True - else: - allocated_to = get_attribute_device(responseXml, 'allocatedTo') - print("The device is currently allocated to:" + allocated_to) - return False - -# Checks whether the device is available or not.If the device is not available rechecks depending upon the - -# Checks whether the device is available or not.If the device is not available rechecks depending upon the -# 'timerValue' and 'timerThreshold' values.With the current parameters it will check after:10,20,40,80 mins. -def is_device_Available_timeout(request, model): - device_available = is_device_available(request, model) - timerValue = 5 - timerThreshold = 80 - if not device_available: - while(timerValue <= timerThreshold): - print("Last checked at:" + strftime("%Y-%m-%d %H:%M:%S", gmtime())) - print(f"Waiting for: {timerValue} min(s)") - time.sleep(timerValue*60) - print("Checking now at:" + strftime("%Y-%m-%d %H:%M:%S", gmtime())) - device_available = is_device_available(request, model) - if(device_available): - return True - else: - timerValue = timerValue + 5 - - if(timerValue > timerThreshold): - return False - else: - return True - else: - return True - -def get_device_attribuites(request, model, attribute): - try: - responseXml = response_device(request, model) - except: - print("Unable to get response.") - raise Exception("Unable to get response.") - try: - attribute_value = get_attribute_device(responseXml, str(attribute)) - except: - attribute_value = False - return attribute_value +# import datetime +# import sys +# import os +# import time +# import warnings +# from selenium.common.exceptions import NoSuchElementException +# import urllib3 +# from perfecto.model.model import Job, Project +# from perfecto import (PerfectoExecutionContext, PerfectoReportiumClient, TestContext, TestResultFactory) +# import pytest +# import logging +# import re +# import allure +# import requests +# from xml.etree import ElementTree as ET +# from time import gmtime, strftime +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# if "libs" not in sys.path: +# sys.path.append(f'../libs') +# import allure +# from apnos.apnos import APNOS +# from controller.controller_1x.controller import Controller +# from controller.controller_1x.controller import ProfileUtility +# from controller.controller_2x.controller import UProfileUtility +# from controller.controller_1x.controller import FirmwareUtility +# import pytest +# import logging +# from configuration import RADIUS_SERVER_DATA +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# if "tests" not in sys.path: +# sys.path.append(f'../tests') +# +# from configuration import CONFIGURATION +# from configuration import PERFECTO_DETAILS +# +# from urllib3 import exceptions +# +# reporting_client = None +# testCaseNameList = [] +# testCaseStatusList = [] +# testCaseErrorMsg = [] +# testCaseReportURL = [] +# +# +# @pytest.fixture(scope="function") +# def get_PassPointConniOS_data(request, get_device_configuration): +# passPoint_data = { +# "netAnalyzer-inter-Con-Xpath": "//*[@label='Network Connected']/parent::*/XCUIElementTypeButton", +# "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], +# "bundleId-iOS-Ping": get_device_configuration["bundleId-iOS-Ping"] +# } +# yield passPoint_data +# +# +# @pytest.fixture(scope="function") +# def get_APToMobileDevice_data(request, get_device_configuration): +# passPoint_data = { +# "webURL": "https://www.google.com", +# "lblSearch": "//*[@class='gLFyf']", +# "elelSearch": "(//*[@class='sbic sb43'])[1]", +# "BtnRunSpeedTest": "//*[text()='RUN SPEED TEST']", +# "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], +# "bundleId-iOS-Safari": get_device_configuration["bundleId-iOS-Safari"], +# "downloadMbps": "//*[@id='knowledge-verticals-internetspeedtest__download']/P[@class='spiqle']", +# "UploadMbps": "//*[@id='knowledge-verticals-internetspeedtest__upload']/P[@class='spiqle']", +# # Android +# "platformName-android": get_device_configuration["platformName-android"], +# "appPackage-android": get_device_configuration["appPackage-android"] +# } +# yield passPoint_data +# +# +# @pytest.fixture(scope="function") +# def get_AccessPointConn_data(request, get_device_configuration): +# passPoint_data = { +# "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], +# "bundleId-iOS-Ping": get_device_configuration["bundleId-iOS-Ping"] +# } +# yield passPoint_data +# +# +# @pytest.fixture(scope="function") +# def get_ToggleAirplaneMode_data(request, get_device_configuration): +# passPoint_data = { +# "webURL": "https://www.google.com", +# "lblSearch": "//*[@class='gLFyf']", +# "elelSearch": "(//*[@class='sbic sb43'])[1]", +# "BtnRunSpeedTest": "//*[text()='RUN SPEED TEST']", +# "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], +# "bundleId-iOS-Safari": get_device_configuration["bundleId-iOS-Safari"], +# "downloadMbps": "//*[@id='knowledge-verticals-internetspeedtest__download']/P[@class='spiqle']", +# "UploadMbps": "//*[@id='knowledge-verticals-internetspeedtest__upload']/P[@class='spiqle']", +# # Android +# "platformName-android": get_device_configuration["platformName-android"], +# "appPackage-android": get_device_configuration["appPackage-android"] +# } +# yield passPoint_data +# +# +# @pytest.fixture(scope="function") +# def get_ToggleWifiMode_data(request,get_device_configuration): +# passPoint_data = { +# # iOS +# "bundleId-iOS-Settings": get_device_configuration["bundleId-iOS-Settings"], +# # Android +# "platformName-android": get_device_configuration["platformName-android"], +# "appPackage-android": get_device_configuration["appPackage-android"] +# } +# yield passPoint_data +# +# +# @pytest.fixture(scope="function") +# def get_lanforge_data(testbed): +# lanforge_data = {} +# if CONFIGURATION[testbed]['traffic_generator']['name'] == 'lanforge': +# lanforge_data = { +# "lanforge_ip": CONFIGURATION[testbed]['traffic_generator']['details']['ip'], +# "lanforge-port-number": CONFIGURATION[testbed]['traffic_generator']['details']['port'], +# "lanforge_2dot4g": CONFIGURATION[testbed]['traffic_generator']['details']['2.4G-Radio'][0], +# "lanforge_5g": CONFIGURATION[testbed]['traffic_generator']['details']['5G-Radio'][0], +# "lanforge_2dot4g_prefix": CONFIGURATION[testbed]['traffic_generator']['details']['2.4G-Station-Name'], +# "lanforge_5g_prefix": CONFIGURATION[testbed]['traffic_generator']['details']['5G-Station-Name'], +# "lanforge_2dot4g_station": CONFIGURATION[testbed]['traffic_generator']['details']['2.4G-Station-Name'], +# "lanforge_5g_station": CONFIGURATION[testbed]['traffic_generator']['details']['5G-Station-Name'], +# "lanforge_bridge_port": CONFIGURATION[testbed]['traffic_generator']['details']['upstream'], +# "lanforge_vlan_port": CONFIGURATION[testbed]['traffic_generator']['details']['upstream'] + ".100", +# "vlan": 100 +# } +# yield lanforge_data +# +# +# @pytest.fixture(scope="session") +# def instantiate_profile(request): +# if request.config.getoption("1.x"): +# yield ProfileUtility +# else: +# yield UProfileUtility +# +# +# +# @pytest.fixture(scope="session") +# def upload_firmware(should_upload_firmware, instantiate_firmware, get_latest_firmware): +# firmware_id = instantiate_firmware.upload_fw_on_cloud(fw_version=get_latest_firmware, +# force_upload=should_upload_firmware) +# yield firmware_id +# +# +# @pytest.fixture(scope="session") +# def upgrade_firmware(request, instantiate_firmware, get_equipment_ref, check_ap_firmware_cloud, get_latest_firmware, +# should_upgrade_firmware): +# if get_latest_firmware != check_ap_firmware_cloud: +# if request.config.getoption("--skip-upgrade"): +# status = "skip-upgrade" +# else: +# status = instantiate_firmware.upgrade_fw(equipment_id=get_equipment_ref, force_upload=False, +# force_upgrade=should_upgrade_firmware) +# else: +# if should_upgrade_firmware: +# status = instantiate_firmware.upgrade_fw(equipment_id=get_equipment_ref, force_upload=False, +# force_upgrade=should_upgrade_firmware) +# else: +# status = "skip-upgrade" +# yield status +# +# +# @pytest.fixture(scope="session") +# def check_ap_firmware_cloud(setup_controller, get_equipment_ref): +# yield setup_controller.get_ap_firmware_old_method(equipment_id=get_equipment_ref) +# +# +# """ +# +# Profiles Related Fixtures +# +# """ +# +# +# @pytest.fixture(scope="module") +# def get_current_profile_cloud(instantiate_profile): +# ssid_names = [] +# for i in instantiate_profile.profile_creation_ids["ssid"]: +# ssid_names.append(instantiate_profile.get_ssid_name_by_profile_id(profile_id=i)) +# yield ssid_names +# +# +# @pytest.fixture(scope="session") +# def setup_vlan(): +# vlan_id = [100] +# yield vlan_id[0] +# +# +# @pytest.fixture(scope="class") +# def setup_profiles(request, setup_controller, testbed, get_equipment_ref, fixtures_ver, skip_lf, get_openflow, run_lf, +# instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info): +# +# param = dict(request.param) +# if not skip_lf: +# lf_tools.reset_scenario() +# # VLAN Setup +# if request.param["mode"] == "VLAN": +# +# vlan_list = list() +# refactored_vlan_list = list() +# ssid_modes = request.param["ssid_modes"].keys() +# for mode in ssid_modes: +# for ssid in range(len(request.param["ssid_modes"][mode])): +# if "vlan" in request.param["ssid_modes"][mode][ssid]: +# vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) +# else: +# pass +# if vlan_list: +# [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] +# vlan_list = refactored_vlan_list +# for i in range(len(vlan_list)): +# if vlan_list[i] > 4095 or vlan_list[i] < 1: +# vlan_list.pop(i) +# if request.param["mode"] == "VLAN": +# lf_tools.add_vlan(vlan_ids=vlan_list) +# +# # call this, if 1.x +# return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_ref, +# instantiate_profile, +# get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, +# radius_accounting_info, skip_lf=skip_lf, open_flow=get_openflow, run_lf=run_lf) +# print("sleeping for 120 sec.") +# time.sleep(180) +# print("Done sleeping") +# yield return_var +# +# +# @pytest.fixture(scope="function") +# def update_ssid(request, instantiate_profile, setup_profile_data): +# requested_profile = str(request.param).replace(" ", "").split(",") +# profile = setup_profile_data[requested_profile[0]][requested_profile[1]][requested_profile[2]] +# status = instantiate_profile.update_ssid_name(profile_name=profile["profile_name"], +# new_profile_name=requested_profile[3]) +# setup_profile_data[requested_profile[0]][requested_profile[1]][requested_profile[2]]["profile_name"] = \ +# requested_profile[3] +# setup_profile_data[requested_profile[0]][requested_profile[1]][requested_profile[2]]["ssid_name"] = \ +# requested_profile[3] +# time.sleep(90) +# yield status +# +# +# # @pytest.fixture(scope="module", autouse=True) +# def failure_tracking_fixture(request): +# tests_failed_before_module = request.session.testsfailed +# print("\n\ntests_failed_before_module: ") +# print(tests_failed_before_module) +# tests_failed_during_module = request.session.testsfailed - tests_failed_before_module +# print("tests_failed_during_module: ") +# print(tests_failed_during_module) +# yield tests_failed_during_module +# +# +# +# empty_get_vif_state_list = [] +# +# @pytest.fixture(scope="class") +# def get_vif_state(get_apnos, get_configuration, request, lf_tools, skip_lf): +# if not skip_lf: +# if request.config.getoption("1.x"): +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") +# vif_state = list(ap_ssh.get_vif_state_ssids()) +# vif_state.sort() +# yield vif_state +# else: +# yield lf_tools.ssid_list +# else: +# yield empty_get_vif_state_list +# +# @pytest.hookimpl(tryfirst=True, hookwrapper=True) +# def pytest_runtest_makereport(item, call): +# outcome = yield +# result = outcome.get_result() +# # testCaseStatusValue = "" +# testCasePassedStatusValue = "" +# testCaseFailedStatusValue = "" +# testCaseNameList = [] +# testCaseStatusList = [] +# testCaseErrorMsg = [] +# testCaseReportURL = [] +# +# if os.environ.get('PYTEST_CURRENT_TEST') is not None: +# if (str(os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]).strip()).startswith("test_unique"): +# return 0 +# +# # if os.environ.get('PYTEST_CURRENT_TEST') is not None and ((os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0]).strip()).startswith("test_unique_ssid"): +# # return 0; +# +# if result.when == 'call': +# item.session.results[item] = result +# +# # Gets the Current Test Case Name +# TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] +# nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) +# # print("TestCasefullNameTEST: " + TestCaseFullName) +# try: +# # TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') +# TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') +# # print ("\nTestCaseName: " + TestCaseName) +# except Exception as e: +# TestCaseName = nCurrentTestMethodNameSplit +# print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") +# # print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") +# +# # exception = call.excinfo.value +# # exception_class = call.excinfo.type +# # exception_class_name = call.excinfo.typename +# +# # exception_traceback = call.excinfo.traceback +# +# if result.outcome == "failed": +# exception_type_and_message_formatted = call.excinfo.exconly() +# testCaseFailedStatusValue = "FAILED" +# reporting_client.test_stop(TestResultFactory.create_failure(str(testCaseErrorMsg))) +# testCaseNameList.append(TestCaseName) +# testCaseStatusList.append(testCaseFailedStatusValue) +# testCaseErrorMsg.append(exception_type_and_message_formatted) +# testCaseReportURL.append(reporting_client.report_url()) +# +# print("\n TestStatus: " + testCaseFailedStatusValue) +# print(" FailureMsg: " + str(testCaseErrorMsg)) +# reportPerfecto(TestCaseName, testCaseFailedStatusValue, testCaseErrorMsg, +# str(reporting_client.report_url())) +# +# if result.outcome == "passed": +# testCasePassedStatusValue = "PASSED" +# reporting_client.test_stop(TestResultFactory.create_success()) +# testCaseNameList.append(TestCaseName) +# testCaseStatusList.append(testCasePassedStatusValue) +# testCaseReportURL.append(reporting_client.report_url()) +# print("\n TestStatus: " + testCasePassedStatusValue) +# reportPerfecto(TestCaseName, testCasePassedStatusValue, "N/A", str(reporting_client.report_url())) +# +# if result.outcome == "skipped": +# testCaseSkippedStatusValue = "SKIPPED" +# exception_type_Skipped_message_formatted = call.excinfo.exconly() +# reporting_client.test_stop(TestResultFactory.create_failure(str(exception_type_Skipped_message_formatted))) +# testCaseNameList.append(TestCaseName) +# testCaseStatusList.append("SKIPPED") +# testCaseErrorMsg.append(str(exception_type_Skipped_message_formatted)) +# testCaseReportURL.append(reporting_client.report_url()) +# print("\n TestStatus: " + testCaseSkippedStatusValue) +# print(" FailureMsg: " + str(testCaseErrorMsg)) +# reportPerfecto(TestCaseName, testCaseSkippedStatusValue, testCaseErrorMsg, +# str(reporting_client.report_url())) +# +# +# def pytest_sessionfinish(session, exitstatus): +# +# try: +# if reporting_client is not None: +# print() +# skipped_amount = 0 +# # print('Perfecto TestCase Execution Status:', exitstatus) +# passed_amount = sum(1 for result in session.results.values() if result.passed) +# failed_amount = sum(1 for result in session.results.values() if result.failed) +# skipped_amount = sum(1 for result in session.results.values() if result.skipped) +# # print(f'There are {passed_amount} passed and {failed_amount} failed tests') +# TotalExecutedCount = failed_amount + passed_amount + skipped_amount +# +# print('\n------------------------------------') +# print('TestCase Execution Summary') +# print('------------------------------------') +# print('Total TestCase Executed: ' + str(TotalExecutedCount)) +# print('Total Passed: ' + str(passed_amount)) +# print('Total Failed: ' + str(failed_amount)) +# print('Total Skipped: ' + str(skipped_amount) + "\n") +# try: +# for index in range(len(testCaseNameList)): +# print(str(index + 1) + ") " + str(testCaseNameList[index]) + " : " + str(testCaseStatusList[index])) +# print(" ReportURL: " + str(testCaseReportURL[index])) +# print(" FailureMsg: " + str(testCaseErrorMsg[index]) + "\n") +# except Exception as e: +# print('No Interop Test Cases Executed') +# else: +# pass +# +# except Exception as e: +# pass +# print('\n------------------------------------------------------------------\n\n\n\n') +# +# +# @pytest.fixture(scope="function") +# def setup_perfectoMobile_android(request, get_device_configuration): +# from appium import webdriver +# driver = None +# reporting_client = None +# +# warnings.simplefilter("ignore", ResourceWarning) +# urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) +# +# capabilities = { +# 'platformName': get_device_configuration["platformName-android"], +# 'model': get_device_configuration["model-android"], +# 'browserName': 'mobileOS', +# # 'automationName' : 'Appium', +# 'securityToken': PERFECTO_DETAILS["securityToken"], +# 'useAppiumForWeb': 'false', +# 'useAppiumForHybrid': 'false', +# # 'bundleId' : request.config.getini("appPackage-android"), +# } +# +# if not is_device_Available_timeout(request, capabilities['model']): +# print("Unable to get device.") +# pytest.exit("Exiting Pytest") +# +# driver = webdriver.Remote( +# 'https://' + PERFECTO_DETAILS["perfectoURL"] + '.perfectomobile.com/nexperience/perfectomobile/wd/hub', +# capabilities) +# driver.implicitly_wait(2) +# +# TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] +# nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) +# try: +# # TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') +# TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') +# print("\n\nExecuting TestCase: " + TestCaseName) +# except Exception as e: +# TestCaseName = nCurrentTestMethodNameSplit +# print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") +# # print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") +# +# projectname = PERFECTO_DETAILS["projectName"] +# projectversion = PERFECTO_DETAILS["projectVersion"] +# jobname = get_device_configuration["jobName"] +# jobnumber = get_device_configuration["jobNumber"] +# tags = PERFECTO_DETAILS["reportTags"] +# testCaseName = TestCaseName +# +# # print("\nSetting Perfecto ReportClient....") +# perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber), +# Project(projectname, projectversion)) +# reporting_client = PerfectoReportiumClient(perfecto_execution_context) +# reporting_client.test_start(testCaseName, TestContext([], "Perforce")) +# reportClient(reporting_client) +# +# try: +# params = {'property': 'model'} +# deviceModel = driver.execute_script('mobile:handset:info', params) +# except: +# pass +# +# def teardown(): +# try: +# print("\n---------- Tear Down ----------") +# try: +# params = {'property': 'model'} +# deviceModel = driver.execute_script('mobile:handset:info', params) +# allure.dynamic.link( +# str(reporting_client.report_url()), +# name=str(deviceModel)) +# except: +# print("fail to attach video link") +# +# print('Report-Url: ' + reporting_client.report_url()) +# +# print("----------------------------------------------------------\n\n\n\n") +# driver.close() +# except Exception as e: +# print(" -- Exception While Tear Down --") +# driver.close() +# print(e) +# finally: +# try: +# driver.quit() +# except Exception as e: +# print(" -- Exception Not Able To Quit --") +# print(e) +# +# request.addfinalizer(teardown) +# +# if driver is None: +# yield -1 +# else: +# yield driver, reporting_client +# +# +# def reportClient(value): +# global reporting_client # declare a to be a global +# reporting_client = value # this sets the global value of a +# +# +# def reportPerfecto(testCaseName, testCaseStatus, testErrorMsg, reportURL): +# global testCaseNameList # declare a to be a global +# global testCaseStatusList +# global testCaseErrorMsg +# global testCaseReportURL +# +# testCaseNameList.append(testCaseName) +# testCaseStatusList.append(testCaseStatus) +# testCaseErrorMsg.append(str(testErrorMsg)) +# testCaseReportURL.append(reportURL) +# +# +# @pytest.fixture(scope="class") +# def setup_perfectoMobileWeb(request, get_device_configuration): +# from selenium import webdriver +# rdriver = None +# reporting_client = None +# +# warnings.simplefilter("ignore", ResourceWarning) +# urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) +# +# capabilities = { +# 'platformName': get_device_configuration["platformName-iOS"], +# 'model': get_device_configuration["model-iOS"], +# 'browserName': get_device_configuration["browserType-iOS"], +# 'securityToken': get_device_configuration["securityToken"], +# } +# +# if not is_device_Available_timeout(request, capabilities['model']): +# print("Unable to get device.") +# pytest.exit("Exiting Pytest") +# +# rdriver = webdriver.Remote( +# 'https://' + PERFECTO_DETAILS["perfectoURL"] + '.perfectomobile.com/nexperience/perfectomobile/wd/hub', +# capabilities) +# rdriver.implicitly_wait(2) +# +# projectname = PERFECTO_DETAILS["projectName"] +# projectversion = PERFECTO_DETAILS["projectVersion"] +# jobname = get_device_configuration["jobName"] +# jobnumber = get_device_configuration["jobNumber"] +# tags = PERFECTO_DETAILS["reportTags"] +# testCaseName = get_device_configuration["jobName"] +# +# print("Setting Perfecto ReportClient....") +# perfecto_execution_context = PerfectoExecutionContext(rdriver, tags, Job(jobname, jobnumber), +# Project(projectname, projectversion)) +# reporting_client = PerfectoReportiumClient(perfecto_execution_context) +# reporting_client.test_start(testCaseName, TestContext([], "Perforce")) +# +# def teardown(): +# try: +# print(" -- Tear Down --") +# reporting_client.test_stop(TestResultFactory.create_success()) +# print('Report-Url: ' + reporting_client.report_url() + '\n') +# rdriver.close() +# except Exception as e: +# print(" -- Exception Not Able To close --") +# print(e.message) +# finally: +# try: +# rdriver.quit() +# except Exception as e: +# print(" -- Exception Not Able To Quit --") +# print(e.message) +# +# request.addfinalizer(teardown) +# +# if rdriver is None: +# yield -1 +# else: +# yield rdriver, reporting_client +# +# +# @pytest.fixture(scope="function") +# def setup_perfectoMobile_iOS(request, get_device_configuration): +# from appium import webdriver +# driver = None +# reporting_client = None +# +# warnings.simplefilter("ignore", ResourceWarning) +# urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) +# +# capabilities = { +# 'platformName': get_device_configuration["platformName-iOS"], +# 'model': get_device_configuration["model-iOS"], +# 'browserName': 'safari', +# # 'automationName' : 'Appium', +# 'securityToken': PERFECTO_DETAILS["securityToken"], +# 'useAppiumForWeb': 'false', +# 'autoAcceptAlerts': 'true', +# # 'bundleId' : request.config.getini("bundleId-iOS"), +# 'useAppiumForHybrid': 'false', +# } +# +# # Check if the device is available +# if not is_device_Available_timeout(request, capabilities['model']): +# print("Unable to get device.") +# pytest.exit("Exiting Pytest") +# +# driver = webdriver.Remote( +# 'https://' + PERFECTO_DETAILS["perfectoURL"] + '.perfectomobile.com/nexperience/perfectomobile/wd/hub', +# capabilities) +# driver.implicitly_wait(2) +# +# TestCaseFullName = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0] +# nCurrentTestMethodNameSplit = re.sub(r'\[.*?\]\ *', "", TestCaseFullName) +# try: +# # TestCaseName = nCurrentTestMethodNameSplit.removeprefix('test_') +# TestCaseName = nCurrentTestMethodNameSplit.replace('test_', '') +# print("\n\nExecuting TestCase: " + TestCaseName) +# except Exception as e: +# TestCaseName = nCurrentTestMethodNameSplit +# print("\nUpgrade Python to 3.9 to avoid test_ string in your test case name, see below URL") +# # print("https://www.andreagrandi.it/2020/10/11/python39-introduces-removeprefix-removesuffix/") +# +# projectname = PERFECTO_DETAILS["projectName"] +# projectversion = PERFECTO_DETAILS["projectVersion"] +# jobname = get_device_configuration["jobName"] +# jobnumber = get_device_configuration["jobNumber"] +# tags = PERFECTO_DETAILS["reportTags"] +# testCaseName = TestCaseName +# +# print("\nSetting Perfecto ReportClient....") +# perfecto_execution_context = PerfectoExecutionContext(driver, tags, Job(jobname, jobnumber), +# Project(projectname, projectversion)) +# reporting_client = PerfectoReportiumClient(perfecto_execution_context) +# reporting_client.test_start(testCaseName, TestContext([], "Perforce")) +# reportClient(reporting_client) +# try: +# params = {'property': 'model'} +# deviceModel = driver.execute_script('mobile:handset:info', params) +# except: +# pass +# +# def teardown(): +# try: +# print("\n---------- Tear Down ----------") +# print('Report-Url: ' + reporting_client.report_url()) +# try: +# allure.dynamic.link( +# str(reporting_client.report_url()), +# name=str(deviceModel)) +# except: +# print("fail to attach video link") +# print("----------------------------------------------------------\n\n\n\n") +# driver.close() +# except Exception as e: +# print(" -- Exception While Tear Down --") +# driver.close() +# print(e) +# finally: +# try: +# driver.quit() +# except Exception as e: +# print(" -- Exception Not Able To Quit --") +# print(e) +# +# request.addfinalizer(teardown) +# +# if driver is None: +# yield -1 +# else: +# yield driver, reporting_client +# # Does a HTTP GET request to Perfecto cloud and gets response and information related to a headset +# def response_device(request, model): +# securityToken = PERFECTO_DETAILS["securityToken"] +# perfectoURL = PERFECTO_DETAILS["perfectoURL"] +# url = f"https://{perfectoURL}.perfectomobile.com/services/handsets?operation=list&securityToken={securityToken}&model={model}" +# resp = requests.get(url=url) +# return ET.fromstring(resp.content) +# +# # Get an attribute value from the handset response +# def get_attribute_device(responseXml, attribute): +# try: +# return responseXml.find('handset').find(attribute).text +# except: +# print(f"Unable to get value of {attribute} from response") +# return "" +# +# # Checks to see if a particular handset is available +# def is_device_available(request, model): +# try: +# responseXml = response_device(request, model) +# except: +# print("Unable to get response.") +# raise Exception("Unable to get response.") +# device_available = get_attribute_device(responseXml, 'available') +# print("Result:" + device_available) +# if device_available == 'true': +# return True +# else: +# allocated_to = get_attribute_device(responseXml, 'allocatedTo') +# print("The device is currently allocated to:" + allocated_to) +# return False +# +# # Checks whether the device is available or not.If the device is not available rechecks depending upon the +# +# # Checks whether the device is available or not.If the device is not available rechecks depending upon the +# # 'timerValue' and 'timerThreshold' values.With the current parameters it will check after:10,20,40,80 mins. +# def is_device_Available_timeout(request, model): +# device_available = is_device_available(request, model) +# timerValue = 5 +# timerThreshold = 80 +# if not device_available: +# while(timerValue <= timerThreshold): +# print("Last checked at:" + strftime("%Y-%m-%d %H:%M:%S", gmtime())) +# print(f"Waiting for: {timerValue} min(s)") +# time.sleep(timerValue*60) +# print("Checking now at:" + strftime("%Y-%m-%d %H:%M:%S", gmtime())) +# device_available = is_device_available(request, model) +# if(device_available): +# return True +# else: +# timerValue = timerValue + 5 +# +# if(timerValue > timerThreshold): +# return False +# else: +# return True +# else: +# return True +# +# def get_device_attribuites(request, model, attribute): +# try: +# responseXml = response_device(request, model) +# except: +# print("Unable to get response.") +# raise Exception("Unable to get response.") +# try: +# attribute_value = get_attribute_device(responseXml, str(attribute)) +# except: +# attribute_value = False +# return attribute_value diff --git a/tests/e2e/interOp/openroaming_test/android/conftest.py b/tests/e2e/interOp/openroaming_test/android/conftest.py index 14617dc15..bf3bc433d 100644 --- a/tests/e2e/interOp/openroaming_test/android/conftest.py +++ b/tests/e2e/interOp/openroaming_test/android/conftest.py @@ -1,390 +1,390 @@ -import os -import sys - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -if "libs" not in sys.path: - sys.path.append(f"../libs") - -import time -import pytest -import allure -from collections import defaultdict -from lanforge.lf_tests import RunTest -from configuration import PASSPOINT_RADIUS_SERVER_DATA -from configuration import PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA -from configuration import PASSPOINT_PROVIDER_INFO -from configuration import PASSPOINT_OPERATOR_INFO -from configuration import PASSPOINT_VENUE_INFO -from configuration import PASSPOINT_PROFILE_INFO -from controller.controller_1x.controller import ProfileUtility - - -@allure.feature("PASSPOINT CONNECTIVITY SETUP") -@pytest.fixture(scope="class") -def setup_profiles(request, setup_controller, testbed, setup_vlan, get_equipment_ref, - instantiate_profile, get_markers, passpoint_provider_info, passpoint_operator_info, - passpoint_venue_info, passpoint_profile_info, - get_configuration, passpoint_radius_server_info, passpoint_radius_accounting_server_info, get_apnos): - instantiate_profile = instantiate_profile(sdk_client=setup_controller) - vlan_id, mode = 0, 0 - instantiate_profile.cleanup_objects() - parameter = dict(request.param) - test_cases = {} - profile_data = {} - if parameter["mode"] not in ["BRIDGE", "NAT", "VLAN"]: - print("Invalid Mode: ", parameter["mode"]) - yield test_cases - - if parameter["mode"] == "NAT": - mode = "NAT" - vlan_id = 1 - if parameter["mode"] == "BRIDGE": - mode = "BRIDGE" - vlan_id = 1 - if parameter["mode"] == "VLAN": - mode = "BRIDGE" - vlan_id = setup_vlan - - ap_profile = testbed + "-Equipment-AP-Passpoint" - instantiate_profile.delete_profile_by_name(profile_name=ap_profile) - profile_data["equipment_ap"] = {"profile_name": ap_profile} - - profile_data["ssid"] = {} - # Only passpoint SSID need to be applied with passpoint profiles leaving ssid used for - # profile download - passpoint_profile_download - profile_data["allowed_ssids"] = [] - for i in parameter["ssid_modes"]: - profile_data["ssid"][i] = [] - for j in range(len(parameter["ssid_modes"][i])): - profile_name = testbed + "-SSID-" + i + "-" + str(j) + "-" + parameter["mode"] - data = parameter["ssid_modes"][i][j] - data["profile_name"] = profile_name - if "mode" not in dict(data).keys(): - data["mode"] = mode - if "vlan" not in dict(data).keys(): - data["vlan"] = vlan_id - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - profile_data["ssid"][i].append(data) - - instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) - time.sleep(10) - - # RF Profile Creation - rf_profile_data = { - "name": testbed + "-RF-Profile-" + parameter["mode"] + "-" + get_configuration["access_point"][0]["mode"] - } - try: - instantiate_profile.delete_profile_by_name(profile_name=rf_profile_data["name"]) - rf_profile_data = instantiate_profile.set_rf_profile(profile_data=rf_profile_data, - mode=get_configuration["access_point"][0]["mode"]) - allure.attach(body=str(rf_profile_data), - name="RF Profile Created : " + get_configuration["access_point"][0]["mode"]) - except Exception as e: - print(e) - allure.attach(body=str(e), name="Exception ") - - # Radius Profile Creation - passpoint_radius_server_info = passpoint_radius_server_info - passpoint_radius_server_info["name"] = testbed + "-Automation-Radius-Profile" - instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile") - try: - instantiate_profile.create_radius_profile(radius_info=passpoint_radius_server_info, - radius_accounting_info=passpoint_radius_accounting_server_info) - test_cases["radius_profile"] = True - allure.attach(body=str(passpoint_radius_server_info), name="Radius Profile Created") - except Exception as e: - print(e) - test_cases["radius_profile"] = False - - # SSID Profile Creation - for mode in profile_data["ssid"]: - if mode == "open": - for j in profile_data["ssid"][mode]: - try: - if "is2dot4GHz" in list(j["appliedRadios"]): - creates_profile = instantiate_profile.create_open_ssid_profile(profile_data=j) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - if mode == "wpa_eap": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - try: - if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - try: - if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["wpa_eap_5g"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - if mode == "wpa2_eap": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - try: - if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - try: - if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - if mode == "wpa2_only_eap": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - try: - if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( - profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - try: - if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( - profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - - # Passpoint OSU ID provider profile creation - passpoint_provider_info = passpoint_provider_info - test_cases["passpoint_osu_id_provider"] = dict() - profile_name = testbed + "-Automation-Passpoint-OSU-ID-Provider-Profile" - passpoint_provider_info["profile_name"] = profile_name - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_osu_id_provider_profile( - profile_data=passpoint_provider_info) - allure.attach(body=str(creates_profile), name="Passpoint OSU ID provider Profile Created") - test_cases["passpoint_osu_id_provider"] = {"sdk": True} - except Exception as e: - print(e) - test_cases["passpoint_osu_id_provider"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint OSU ID provider Profile Creation Failed") - - # Passpoint operator profile creation - test_cases["passpoint_operator_profile"] = dict() - passpoint_operator_info = passpoint_operator_info - profile_name = testbed + "-Automation-Passpoint-Operator-Profile" - passpoint_operator_info["profile_name"] = profile_name - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_operator_profile(profile_data=passpoint_operator_info) - allure.attach(body=str(creates_profile), name="Passpoint Operator Profile Created") - test_cases["passpoint_operator_profile"] = {"sdk": True} - profile_data["passpoint_operator"] = profile_name - except Exception as e: - print(e) - test_cases["passpoint_operator_profile"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint Operator Profile Creation Failed") - - # Passpoint Venue profile creation - passpoint_venue_info = passpoint_venue_info - test_cases["passpoint_venue_profile"] = dict() - profile_name = testbed + "-Automation-Passpoint-Venue-Profile" - passpoint_venue_info["profile_name"] = profile_name - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_venue_profile(profile_data=passpoint_venue_info) - allure.attach(body=str(creates_profile), name="Passpoint Venue Profile Created") - test_cases["passpoint_venue_profile"] = {"sdk": True} - profile_data["passpoint_venue"] = profile_name - except Exception as e: - print(e) - test_cases["passpoint_venue"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint Venue Profile Creation Failed") - - # Passpoint profile creation - passpoint_profile_info = passpoint_profile_info - profile_name = testbed + "-Automation-Passpoint-Profile" - passpoint_profile_info["profile_name"] = profile_name - passpoint_profile_info["allowed_ssids"] = profile_data["allowed_ssids"] - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_profile(profile_data=passpoint_profile_info) - allure.attach(body=str(creates_profile), name="Passpoint Profile Created") - test_cases["passpoint"] = {"sdk": True} - profile_data["passpoint"] = profile_name - except Exception as e: - print(e) - test_cases["passpoint"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint Profile Creation Failed") - - # Update SSID profile with passpoint config - passpoint_profile_info = passpoint_profile_info - ssid_to_apply = None - for ssid_profile in profile_data["ssid"].keys(): - for ssid in profile_data["ssid"][ssid_profile]: - if ssid["ssid_name"] == "passpoint_profile_download": - ssid_to_apply = ssid["ssid_name"] - continue - if ssid["ssid_name"] in test_cases.keys(): - allure.attach(body=str(ssid), name="Updating SSID profile") - passpoint_profile_info["ssid_profile_name"] = ssid["profile_name"] - instantiate_profile.update_ssid_profile(profile_info=passpoint_profile_info) - - # Equipment AP Profile Creation - ap_profile_info = dict() - ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] - ap_profile_info["ssid_names"] = [ssid_to_apply] - try: - instantiate_profile.set_ap_profile_custom(profile_data=ap_profile_info) - test_cases["equipment_ap"] = {"sdk": True} - allure.attach(body=str(profile_data["equipment_ap"]), name="Equipment AP Profile Created") - except Exception as e: - print(e) - test_cases["equipment_ap"] = {"sdk": False} - allure.attach(body=str(e), name="Equipment AP Profile Creation Failed") - - - def teardown_session(): - print("\nRemoving Profiles") - instantiate_profile.delete_profile_by_name(profile_name=profile_data['equipment_ap']['profile_name']) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["ssid"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["radius"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["rf"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_osu_id_provider"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_operator"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_venue"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint"]) - allure.attach(body=str(profile_data['equipment_ap']['profile_name'] + "\n"), - name="Tear Down in Profiles ") - time.sleep(20) - - request.addfinalizer(teardown_session) - yield test_cases, instantiate_profile, profile_data - - -@pytest.fixture(scope="function") -def push_ap_profile(request, setup_profiles, get_equipment_ref, get_apnos, get_configuration): - parameter = dict(request.param) - test_cases, instantiate_profile, profile_data = setup_profiles - ssid_names = parameter["ssid_names"] - ap_profile_info = dict() - ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] - test_cases = {} - ap_profile_info["ssid_names"] = ssid_names - try: - instantiate_profile.update_ap_profile(profile_data=ap_profile_info) - test_cases["equipment_ap"] = {"sdk": True} - allure.attach(body=str(ap_profile_info["profile_name"]), name="Equipment AP Profile Updated") - except Exception as e: - print(e) - test_cases["equipment_ap"] = {"sdk": False} - allure.attach(body=str(e), name="Equipment AP Profile Update Failed") - - print("Pushing profiles on AP :: ", ap_profile_info) - allure.attach(body=str(ap_profile_info), name="Pushing profiles on AP :: ") - # Push the Equipment AP Profile to AP - try: - for i in get_equipment_ref: - instantiate_profile.push_profile_old_method(equipment_id=i) - except Exception as e: - print(e) - print("failed to push AP Profile") - - # Check the VIF Config and VIF State of SSIDs - time_start = time.time() - ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") - while time.time() - time_start < 240: - if ((time.time() - time_start) / 10) == 15: - ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") - vif_config = list(ap_ssh.get_vif_config_ssids()) - vif_config.sort() - vif_state = list(ap_ssh.get_vif_state_ssids()) - vif_state.sort() - for ssid in ssid_names: - test_cases[ssid] = dict() - test_cases[ssid]["vif_config"] = True if ssid in vif_config else False - test_cases[ssid]["vif_state"] = True if ssid in vif_state else False - ssid_names.sort() - if vif_config == ssid_names == vif_state: - print("Waiting for Radios to apply config ") - time.sleep(200) - break - time.sleep(10) - allure.attach(body=str(vif_config), name="vifC status on AP :: ") - allure.attach(body=str(vif_state), name="vifS status on AP :: ") - - yield test_cases - - -@pytest.fixture(scope="session") -def passpoint_radius_server_info(): - allure.attach(body=str(PASSPOINT_RADIUS_SERVER_DATA), name="Passpoint RADIUS server Info: ") - yield PASSPOINT_RADIUS_SERVER_DATA - - -@pytest.fixture(scope="session") -def passpoint_radius_accounting_server_info(): - allure.attach(body=str(PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA), name="Passpoint RADIUS account server Info: ") - yield PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA - - -@pytest.fixture(scope="session") -def passpoint_provider_info(): - allure.attach(body=str(PASSPOINT_PROVIDER_INFO), name="Passpoint Provider Info: ") - yield PASSPOINT_PROVIDER_INFO - - -@pytest.fixture(scope="session") -def passpoint_operator_info(): - allure.attach(body=str(PASSPOINT_OPERATOR_INFO), name="Passpoint operator Info: ") - yield PASSPOINT_OPERATOR_INFO - - -@pytest.fixture(scope="session") -def passpoint_venue_info(): - allure.attach(body=str(PASSPOINT_VENUE_INFO), name="Passpoint venue Info: ") - yield PASSPOINT_VENUE_INFO - - -@pytest.fixture(scope="session") -def passpoint_profile_info(): - allure.attach(body=str(PASSPOINT_PROFILE_INFO), name="Passpoint profile Info: ") - yield PASSPOINT_PROFILE_INFO +# import os +# import sys +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# if "libs" not in sys.path: +# sys.path.append(f"../libs") +# +# import time +# import pytest +# import allure +# from collections import defaultdict +# from lanforge.lf_tests import RunTest +# from configuration import PASSPOINT_RADIUS_SERVER_DATA +# from configuration import PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA +# from configuration import PASSPOINT_PROVIDER_INFO +# from configuration import PASSPOINT_OPERATOR_INFO +# from configuration import PASSPOINT_VENUE_INFO +# from configuration import PASSPOINT_PROFILE_INFO +# from controller.controller_1x.controller import ProfileUtility +# +# +# @allure.feature("PASSPOINT CONNECTIVITY SETUP") +# @pytest.fixture(scope="class") +# def setup_profiles(request, setup_controller, testbed, setup_vlan, get_equipment_ref, +# instantiate_profile, get_markers, passpoint_provider_info, passpoint_operator_info, +# passpoint_venue_info, passpoint_profile_info, +# get_configuration, passpoint_radius_server_info, passpoint_radius_accounting_server_info, get_apnos): +# instantiate_profile = instantiate_profile(sdk_client=setup_controller) +# vlan_id, mode = 0, 0 +# instantiate_profile.cleanup_objects() +# parameter = dict(request.param) +# test_cases = {} +# profile_data = {} +# if parameter["mode"] not in ["BRIDGE", "NAT", "VLAN"]: +# print("Invalid Mode: ", parameter["mode"]) +# yield test_cases +# +# if parameter["mode"] == "NAT": +# mode = "NAT" +# vlan_id = 1 +# if parameter["mode"] == "BRIDGE": +# mode = "BRIDGE" +# vlan_id = 1 +# if parameter["mode"] == "VLAN": +# mode = "BRIDGE" +# vlan_id = setup_vlan +# +# ap_profile = testbed + "-Equipment-AP-Passpoint" +# instantiate_profile.delete_profile_by_name(profile_name=ap_profile) +# profile_data["equipment_ap"] = {"profile_name": ap_profile} +# +# profile_data["ssid"] = {} +# # Only passpoint SSID need to be applied with passpoint profiles leaving ssid used for +# # profile download - passpoint_profile_download +# profile_data["allowed_ssids"] = [] +# for i in parameter["ssid_modes"]: +# profile_data["ssid"][i] = [] +# for j in range(len(parameter["ssid_modes"][i])): +# profile_name = testbed + "-SSID-" + i + "-" + str(j) + "-" + parameter["mode"] +# data = parameter["ssid_modes"][i][j] +# data["profile_name"] = profile_name +# if "mode" not in dict(data).keys(): +# data["mode"] = mode +# if "vlan" not in dict(data).keys(): +# data["vlan"] = vlan_id +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# profile_data["ssid"][i].append(data) +# +# instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) +# time.sleep(10) +# +# # RF Profile Creation +# rf_profile_data = { +# "name": testbed + "-RF-Profile-" + parameter["mode"] + "-" + get_configuration["access_point"][0]["mode"] +# } +# try: +# instantiate_profile.delete_profile_by_name(profile_name=rf_profile_data["name"]) +# rf_profile_data = instantiate_profile.set_rf_profile(profile_data=rf_profile_data, +# mode=get_configuration["access_point"][0]["mode"]) +# allure.attach(body=str(rf_profile_data), +# name="RF Profile Created : " + get_configuration["access_point"][0]["mode"]) +# except Exception as e: +# print(e) +# allure.attach(body=str(e), name="Exception ") +# +# # Radius Profile Creation +# passpoint_radius_server_info = passpoint_radius_server_info +# passpoint_radius_server_info["name"] = testbed + "-Automation-Radius-Profile" +# instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile") +# try: +# instantiate_profile.create_radius_profile(radius_info=passpoint_radius_server_info, +# radius_accounting_info=passpoint_radius_accounting_server_info) +# test_cases["radius_profile"] = True +# allure.attach(body=str(passpoint_radius_server_info), name="Radius Profile Created") +# except Exception as e: +# print(e) +# test_cases["radius_profile"] = False +# +# # SSID Profile Creation +# for mode in profile_data["ssid"]: +# if mode == "open": +# for j in profile_data["ssid"][mode]: +# try: +# if "is2dot4GHz" in list(j["appliedRadios"]): +# creates_profile = instantiate_profile.create_open_ssid_profile(profile_data=j) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# if mode == "wpa_eap": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# try: +# if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["wpa_eap_5g"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# if mode == "wpa2_eap": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# try: +# if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# if mode == "wpa2_only_eap": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( +# profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# try: +# if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( +# profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# +# # Passpoint OSU ID provider profile creation +# passpoint_provider_info = passpoint_provider_info +# test_cases["passpoint_osu_id_provider"] = dict() +# profile_name = testbed + "-Automation-Passpoint-OSU-ID-Provider-Profile" +# passpoint_provider_info["profile_name"] = profile_name +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_osu_id_provider_profile( +# profile_data=passpoint_provider_info) +# allure.attach(body=str(creates_profile), name="Passpoint OSU ID provider Profile Created") +# test_cases["passpoint_osu_id_provider"] = {"sdk": True} +# except Exception as e: +# print(e) +# test_cases["passpoint_osu_id_provider"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint OSU ID provider Profile Creation Failed") +# +# # Passpoint operator profile creation +# test_cases["passpoint_operator_profile"] = dict() +# passpoint_operator_info = passpoint_operator_info +# profile_name = testbed + "-Automation-Passpoint-Operator-Profile" +# passpoint_operator_info["profile_name"] = profile_name +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_operator_profile(profile_data=passpoint_operator_info) +# allure.attach(body=str(creates_profile), name="Passpoint Operator Profile Created") +# test_cases["passpoint_operator_profile"] = {"sdk": True} +# profile_data["passpoint_operator"] = profile_name +# except Exception as e: +# print(e) +# test_cases["passpoint_operator_profile"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint Operator Profile Creation Failed") +# +# # Passpoint Venue profile creation +# passpoint_venue_info = passpoint_venue_info +# test_cases["passpoint_venue_profile"] = dict() +# profile_name = testbed + "-Automation-Passpoint-Venue-Profile" +# passpoint_venue_info["profile_name"] = profile_name +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_venue_profile(profile_data=passpoint_venue_info) +# allure.attach(body=str(creates_profile), name="Passpoint Venue Profile Created") +# test_cases["passpoint_venue_profile"] = {"sdk": True} +# profile_data["passpoint_venue"] = profile_name +# except Exception as e: +# print(e) +# test_cases["passpoint_venue"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint Venue Profile Creation Failed") +# +# # Passpoint profile creation +# passpoint_profile_info = passpoint_profile_info +# profile_name = testbed + "-Automation-Passpoint-Profile" +# passpoint_profile_info["profile_name"] = profile_name +# passpoint_profile_info["allowed_ssids"] = profile_data["allowed_ssids"] +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_profile(profile_data=passpoint_profile_info) +# allure.attach(body=str(creates_profile), name="Passpoint Profile Created") +# test_cases["passpoint"] = {"sdk": True} +# profile_data["passpoint"] = profile_name +# except Exception as e: +# print(e) +# test_cases["passpoint"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint Profile Creation Failed") +# +# # Update SSID profile with passpoint config +# passpoint_profile_info = passpoint_profile_info +# ssid_to_apply = None +# for ssid_profile in profile_data["ssid"].keys(): +# for ssid in profile_data["ssid"][ssid_profile]: +# if ssid["ssid_name"] == "passpoint_profile_download": +# ssid_to_apply = ssid["ssid_name"] +# continue +# if ssid["ssid_name"] in test_cases.keys(): +# allure.attach(body=str(ssid), name="Updating SSID profile") +# passpoint_profile_info["ssid_profile_name"] = ssid["profile_name"] +# instantiate_profile.update_ssid_profile(profile_info=passpoint_profile_info) +# +# # Equipment AP Profile Creation +# ap_profile_info = dict() +# ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] +# ap_profile_info["ssid_names"] = [ssid_to_apply] +# try: +# instantiate_profile.set_ap_profile_custom(profile_data=ap_profile_info) +# test_cases["equipment_ap"] = {"sdk": True} +# allure.attach(body=str(profile_data["equipment_ap"]), name="Equipment AP Profile Created") +# except Exception as e: +# print(e) +# test_cases["equipment_ap"] = {"sdk": False} +# allure.attach(body=str(e), name="Equipment AP Profile Creation Failed") +# +# +# def teardown_session(): +# print("\nRemoving Profiles") +# instantiate_profile.delete_profile_by_name(profile_name=profile_data['equipment_ap']['profile_name']) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["ssid"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["radius"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["rf"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_osu_id_provider"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_operator"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_venue"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint"]) +# allure.attach(body=str(profile_data['equipment_ap']['profile_name'] + "\n"), +# name="Tear Down in Profiles ") +# time.sleep(20) +# +# request.addfinalizer(teardown_session) +# yield test_cases, instantiate_profile, profile_data +# +# +# @pytest.fixture(scope="function") +# def push_ap_profile(request, setup_profiles, get_equipment_ref, get_apnos, get_configuration): +# parameter = dict(request.param) +# test_cases, instantiate_profile, profile_data = setup_profiles +# ssid_names = parameter["ssid_names"] +# ap_profile_info = dict() +# ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] +# test_cases = {} +# ap_profile_info["ssid_names"] = ssid_names +# try: +# instantiate_profile.update_ap_profile(profile_data=ap_profile_info) +# test_cases["equipment_ap"] = {"sdk": True} +# allure.attach(body=str(ap_profile_info["profile_name"]), name="Equipment AP Profile Updated") +# except Exception as e: +# print(e) +# test_cases["equipment_ap"] = {"sdk": False} +# allure.attach(body=str(e), name="Equipment AP Profile Update Failed") +# +# print("Pushing profiles on AP :: ", ap_profile_info) +# allure.attach(body=str(ap_profile_info), name="Pushing profiles on AP :: ") +# # Push the Equipment AP Profile to AP +# try: +# for i in get_equipment_ref: +# instantiate_profile.push_profile_old_method(equipment_id=i) +# except Exception as e: +# print(e) +# print("failed to push AP Profile") +# +# # Check the VIF Config and VIF State of SSIDs +# time_start = time.time() +# ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") +# while time.time() - time_start < 240: +# if ((time.time() - time_start) / 10) == 15: +# ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") +# vif_config = list(ap_ssh.get_vif_config_ssids()) +# vif_config.sort() +# vif_state = list(ap_ssh.get_vif_state_ssids()) +# vif_state.sort() +# for ssid in ssid_names: +# test_cases[ssid] = dict() +# test_cases[ssid]["vif_config"] = True if ssid in vif_config else False +# test_cases[ssid]["vif_state"] = True if ssid in vif_state else False +# ssid_names.sort() +# if vif_config == ssid_names == vif_state: +# print("Waiting for Radios to apply config ") +# time.sleep(200) +# break +# time.sleep(10) +# allure.attach(body=str(vif_config), name="vifC status on AP :: ") +# allure.attach(body=str(vif_state), name="vifS status on AP :: ") +# +# yield test_cases +# +# +# @pytest.fixture(scope="session") +# def passpoint_radius_server_info(): +# allure.attach(body=str(PASSPOINT_RADIUS_SERVER_DATA), name="Passpoint RADIUS server Info: ") +# yield PASSPOINT_RADIUS_SERVER_DATA +# +# +# @pytest.fixture(scope="session") +# def passpoint_radius_accounting_server_info(): +# allure.attach(body=str(PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA), name="Passpoint RADIUS account server Info: ") +# yield PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA +# +# +# @pytest.fixture(scope="session") +# def passpoint_provider_info(): +# allure.attach(body=str(PASSPOINT_PROVIDER_INFO), name="Passpoint Provider Info: ") +# yield PASSPOINT_PROVIDER_INFO +# +# +# @pytest.fixture(scope="session") +# def passpoint_operator_info(): +# allure.attach(body=str(PASSPOINT_OPERATOR_INFO), name="Passpoint operator Info: ") +# yield PASSPOINT_OPERATOR_INFO +# +# +# @pytest.fixture(scope="session") +# def passpoint_venue_info(): +# allure.attach(body=str(PASSPOINT_VENUE_INFO), name="Passpoint venue Info: ") +# yield PASSPOINT_VENUE_INFO +# +# +# @pytest.fixture(scope="session") +# def passpoint_profile_info(): +# allure.attach(body=str(PASSPOINT_PROFILE_INFO), name="Passpoint profile Info: ") +# yield PASSPOINT_PROFILE_INFO diff --git a/tests/e2e/interOp/openroaming_test/iOS/conftest.py b/tests/e2e/interOp/openroaming_test/iOS/conftest.py index 04a34ccbe..18114fd69 100644 --- a/tests/e2e/interOp/openroaming_test/iOS/conftest.py +++ b/tests/e2e/interOp/openroaming_test/iOS/conftest.py @@ -1,391 +1,391 @@ -import os -import sys - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -if "libs" not in sys.path: - sys.path.append(f"../libs") - -import time -import pytest -import allure -from collections import defaultdict -from lanforge.lf_tests import RunTest -from configuration import PASSPOINT_RADIUS_SERVER_DATA -from configuration import PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA -from configuration import PASSPOINT_PROVIDER_INFO -from configuration import PASSPOINT_OPERATOR_INFO -from configuration import PASSPOINT_VENUE_INFO -from configuration import PASSPOINT_PROFILE_INFO -from controller.controller_1x.controller import ProfileUtility - - -@allure.feature("PASSPOINT CONNECTIVITY SETUP") -@pytest.fixture(scope="class") -def setup_profiles(request, setup_controller, testbed, setup_vlan, get_equipment_ref, - instantiate_profile, get_markers, passpoint_provider_info, passpoint_operator_info, - passpoint_venue_info, passpoint_profile_info, - get_configuration, passpoint_radius_server_info, passpoint_radius_accounting_server_info, get_apnos): - instantiate_profile = instantiate_profile(sdk_client=setup_controller) - vlan_id, mode = 0, 0 - instantiate_profile.cleanup_objects() - parameter = dict(request.param) - test_cases = {} - profile_data = {} - if parameter["mode"] not in ["BRIDGE", "NAT", "VLAN"]: - print("Invalid Mode: ", parameter["mode"]) - allure.attach(body=parameter["mode"], name="Invalid Mode: ") - yield test_cases - - if parameter["mode"] == "NAT": - mode = "NAT" - vlan_id = 1 - if parameter["mode"] == "BRIDGE": - mode = "BRIDGE" - vlan_id = 1 - if parameter["mode"] == "VLAN": - mode = "BRIDGE" - vlan_id = setup_vlan - - ap_profile = testbed + "-Equipment-AP-Passpoint" - instantiate_profile.delete_profile_by_name(profile_name=ap_profile) - profile_data["equipment_ap"] = {"profile_name": ap_profile} - - profile_data["ssid"] = {} - # Only passpoint SSID need to be applied with passpoint profiles leaving ssid used for - # profile download - passpoint_profile_download - profile_data["allowed_ssids"] = [] - for i in parameter["ssid_modes"]: - profile_data["ssid"][i] = [] - for j in range(len(parameter["ssid_modes"][i])): - profile_name = testbed + "-SSID-" + i + "-" + str(j) + "-" + parameter["mode"] - data = parameter["ssid_modes"][i][j] - data["profile_name"] = profile_name - if "mode" not in dict(data).keys(): - data["mode"] = mode - if "vlan" not in dict(data).keys(): - data["vlan"] = vlan_id - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - profile_data["ssid"][i].append(data) - - instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) - time.sleep(10) - - # RF Profile Creation - rf_profile_data = { - "name": testbed + "-RF-Profile-" + parameter["mode"] + "-" + get_configuration["access_point"][0]["mode"] - } - try: - instantiate_profile.delete_profile_by_name(profile_name=rf_profile_data["name"]) - rf_profile_data = instantiate_profile.set_rf_profile(profile_data=rf_profile_data, - mode=get_configuration["access_point"][0]["mode"]) - allure.attach(body=str(rf_profile_data), - name="RF Profile Created : " + get_configuration["access_point"][0]["mode"]) - except Exception as e: - print(e) - allure.attach(body=str(e), name="Exception ") - - # Radius Profile Creation - passpoint_radius_server_info = passpoint_radius_server_info - passpoint_radius_server_info["name"] = testbed + "-Automation-Radius-Profile" - instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile") - try: - instantiate_profile.create_radius_profile(radius_info=passpoint_radius_server_info, - radius_accounting_info=passpoint_radius_accounting_server_info) - test_cases["radius_profile"] = True - allure.attach(body=str(passpoint_radius_server_info), name="Radius Profile Created") - except Exception as e: - print(e) - test_cases["radius_profile"] = False - - # SSID Profile Creation - for mode in profile_data["ssid"]: - if mode == "open": - for j in profile_data["ssid"][mode]: - try: - if "is2dot4GHz" in list(j["appliedRadios"]): - creates_profile = instantiate_profile.create_open_ssid_profile(profile_data=j) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - if mode == "wpa_eap": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - try: - if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - try: - if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["wpa_eap_5g"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - if mode == "wpa2_eap": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - try: - if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - try: - if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - if mode == "wpa2_only_eap": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - try: - if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( - profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - try: - if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( - j["appliedRadios"]): - creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( - profile_data=j) - profile_data["allowed_ssids"].append(creates_profile._id) - test_cases[j["ssid_name"]] = {"sdk": True} - allure.attach(body=str(creates_profile), name="SSID Profile Created") - except Exception as e: - print(e) - test_cases[j["ssid_name"]] = {"sdk": False} - allure.attach(body=str(e), name="SSID Profile Creation Failed") - - # Passpoint OSU ID provider profile creation - passpoint_provider_info = passpoint_provider_info - test_cases["passpoint_osu_id_provider"] = dict() - profile_name = testbed + "-Automation-Passpoint-OSU-ID-Provider-Profile" - passpoint_provider_info["profile_name"] = profile_name - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_osu_id_provider_profile( - profile_data=passpoint_provider_info) - allure.attach(body=str(creates_profile), name="Passpoint OSU ID provider Profile Created") - test_cases["passpoint_osu_id_provider"] = {"sdk": True} - except Exception as e: - print(e) - test_cases["passpoint_osu_id_provider"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint OSU ID provider Profile Creation Failed") - - # Passpoint operator profile creation - test_cases["passpoint_operator_profile"] = dict() - passpoint_operator_info = passpoint_operator_info - profile_name = testbed + "-Automation-Passpoint-Operator-Profile" - passpoint_operator_info["profile_name"] = profile_name - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_operator_profile(profile_data=passpoint_operator_info) - allure.attach(body=str(creates_profile), name="Passpoint Operator Profile Created") - test_cases["passpoint_operator_profile"] = {"sdk": True} - profile_data["passpoint_operator"] = profile_name - except Exception as e: - print(e) - test_cases["passpoint_operator_profile"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint Operator Profile Creation Failed") - - # Passpoint Venue profile creation - passpoint_venue_info = passpoint_venue_info - test_cases["passpoint_venue_profile"] = dict() - profile_name = testbed + "-Automation-Passpoint-Venue-Profile" - passpoint_venue_info["profile_name"] = profile_name - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_venue_profile(profile_data=passpoint_venue_info) - allure.attach(body=str(creates_profile), name="Passpoint Venue Profile Created") - test_cases["passpoint_venue_profile"] = {"sdk": True} - profile_data["passpoint_venue"] = profile_name - except Exception as e: - print(e) - test_cases["passpoint_venue"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint Venue Profile Creation Failed") - - # Passpoint profile creation - passpoint_profile_info = passpoint_profile_info - profile_name = testbed + "-Automation-Passpoint-Profile" - passpoint_profile_info["profile_name"] = profile_name - passpoint_profile_info["allowed_ssids"] = profile_data["allowed_ssids"] - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - try: - creates_profile = instantiate_profile.create_passpoint_profile(profile_data=passpoint_profile_info) - allure.attach(body=str(creates_profile), name="Passpoint Profile Created") - test_cases["passpoint"] = {"sdk": True} - profile_data["passpoint"] = profile_name - except Exception as e: - print(e) - test_cases["passpoint"] = {"sdk": False} - allure.attach(body=str(e), name="Passpoint Profile Creation Failed") - - # Update SSID profile with passpoint config - passpoint_profile_info = passpoint_profile_info - ssid_to_apply = None - for ssid_profile in profile_data["ssid"].keys(): - for ssid in profile_data["ssid"][ssid_profile]: - if ssid["ssid_name"] == "passpoint_profile_download": - ssid_to_apply = ssid["ssid_name"] - continue - if ssid["ssid_name"] in test_cases.keys(): - allure.attach(body=str(ssid), name="Updating SSID profile") - passpoint_profile_info["ssid_profile_name"] = ssid["profile_name"] - instantiate_profile.update_ssid_profile(profile_info=passpoint_profile_info) - - # Equipment AP Profile Creation - ap_profile_info = dict() - ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] - ap_profile_info["ssid_names"] = [ssid_to_apply] - try: - instantiate_profile.set_ap_profile_custom(profile_data=ap_profile_info) - test_cases["equipment_ap"] = {"sdk": True} - allure.attach(body=str(profile_data["equipment_ap"]), name="Equipment AP Profile Created") - except Exception as e: - print(e) - test_cases["equipment_ap"] = {"sdk": False} - allure.attach(body=str(e), name="Equipment AP Profile Creation Failed") - - - def teardown_session(): - print("\nRemoving Profiles") - instantiate_profile.delete_profile_by_name(profile_name=profile_data['equipment_ap']['profile_name']) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["ssid"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["radius"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["rf"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_osu_id_provider"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_operator"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_venue"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint"]) - allure.attach(body=str(profile_data['equipment_ap']['profile_name'] + "\n"), - name="Tear Down in Profiles ") - time.sleep(20) - - request.addfinalizer(teardown_session) - yield test_cases, instantiate_profile, profile_data - - -@pytest.fixture(scope="function") -def push_ap_profile(request, setup_profiles, get_equipment_ref, get_apnos, get_configuration): - parameter = dict(request.param) - test_cases, instantiate_profile, profile_data = setup_profiles - ssid_names = parameter["ssid_names"] - ap_profile_info = dict() - ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] - test_cases = {} - ap_profile_info["ssid_names"] = ssid_names - try: - instantiate_profile.update_ap_profile(profile_data=ap_profile_info) - test_cases["equipment_ap"] = {"sdk": True} - allure.attach(body=str(ap_profile_info["profile_name"]), name="Equipment AP Profile Updated") - except Exception as e: - print(e) - test_cases["equipment_ap"] = {"sdk": False} - allure.attach(body=str(e), name="Equipment AP Profile Update Failed") - - print("Pushing profiles on AP :: ", ap_profile_info) - allure.attach(body=str(ap_profile_info), name="Pushing profiles on AP :: ") - # Push the Equipment AP Profile to AP - try: - for i in get_equipment_ref: - instantiate_profile.push_profile_old_method(equipment_id=i) - except Exception as e: - print(e) - print("failed to push AP Profile") - - # Check the VIF Config and VIF State of SSIDs - time_start = time.time() - ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") - while time.time() - time_start < 240: - if ((time.time() - time_start) / 10) == 15: - ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") - vif_config = list(ap_ssh.get_vif_config_ssids()) - vif_config.sort() - vif_state = list(ap_ssh.get_vif_state_ssids()) - vif_state.sort() - for ssid in ssid_names: - test_cases[ssid] = dict() - test_cases[ssid]["vif_config"] = True if ssid in vif_config else False - test_cases[ssid]["vif_state"] = True if ssid in vif_state else False - ssid_names.sort() - if vif_config == ssid_names == vif_state: - print("Waiting for Radios to apply config ") - time.sleep(200) - break - time.sleep(10) - allure.attach(body=str(vif_config), name="vifC status on AP :: ") - allure.attach(body=str(vif_state), name="vifS status on AP :: ") - - yield test_cases - - -@pytest.fixture(scope="session") -def passpoint_radius_server_info(): - allure.attach(body=str(PASSPOINT_RADIUS_SERVER_DATA), name="Passpoint RADIUS server Info: ") - yield PASSPOINT_RADIUS_SERVER_DATA - - -@pytest.fixture(scope="session") -def passpoint_radius_accounting_server_info(): - allure.attach(body=str(PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA), name="Passpoint RADIUS account server Info: ") - yield PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA - - -@pytest.fixture(scope="session") -def passpoint_provider_info(): - allure.attach(body=str(PASSPOINT_PROVIDER_INFO), name="Passpoint Provider Info: ") - yield PASSPOINT_PROVIDER_INFO - - -@pytest.fixture(scope="session") -def passpoint_operator_info(): - allure.attach(body=str(PASSPOINT_OPERATOR_INFO), name="Passpoint operator Info: ") - yield PASSPOINT_OPERATOR_INFO - - -@pytest.fixture(scope="session") -def passpoint_venue_info(): - allure.attach(body=str(PASSPOINT_VENUE_INFO), name="Passpoint venue Info: ") - yield PASSPOINT_VENUE_INFO - - -@pytest.fixture(scope="session") -def passpoint_profile_info(): - allure.attach(body=str(PASSPOINT_PROFILE_INFO), name="Passpoint profile Info: ") - yield PASSPOINT_PROFILE_INFO +# import os +# import sys +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# if "libs" not in sys.path: +# sys.path.append(f"../libs") +# +# import time +# import pytest +# import allure +# from collections import defaultdict +# from lanforge.lf_tests import RunTest +# from configuration import PASSPOINT_RADIUS_SERVER_DATA +# from configuration import PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA +# from configuration import PASSPOINT_PROVIDER_INFO +# from configuration import PASSPOINT_OPERATOR_INFO +# from configuration import PASSPOINT_VENUE_INFO +# from configuration import PASSPOINT_PROFILE_INFO +# from controller.controller_1x.controller import ProfileUtility +# +# +# @allure.feature("PASSPOINT CONNECTIVITY SETUP") +# @pytest.fixture(scope="class") +# def setup_profiles(request, setup_controller, testbed, setup_vlan, get_equipment_ref, +# instantiate_profile, get_markers, passpoint_provider_info, passpoint_operator_info, +# passpoint_venue_info, passpoint_profile_info, +# get_configuration, passpoint_radius_server_info, passpoint_radius_accounting_server_info, get_apnos): +# instantiate_profile = instantiate_profile(sdk_client=setup_controller) +# vlan_id, mode = 0, 0 +# instantiate_profile.cleanup_objects() +# parameter = dict(request.param) +# test_cases = {} +# profile_data = {} +# if parameter["mode"] not in ["BRIDGE", "NAT", "VLAN"]: +# print("Invalid Mode: ", parameter["mode"]) +# allure.attach(body=parameter["mode"], name="Invalid Mode: ") +# yield test_cases +# +# if parameter["mode"] == "NAT": +# mode = "NAT" +# vlan_id = 1 +# if parameter["mode"] == "BRIDGE": +# mode = "BRIDGE" +# vlan_id = 1 +# if parameter["mode"] == "VLAN": +# mode = "BRIDGE" +# vlan_id = setup_vlan +# +# ap_profile = testbed + "-Equipment-AP-Passpoint" +# instantiate_profile.delete_profile_by_name(profile_name=ap_profile) +# profile_data["equipment_ap"] = {"profile_name": ap_profile} +# +# profile_data["ssid"] = {} +# # Only passpoint SSID need to be applied with passpoint profiles leaving ssid used for +# # profile download - passpoint_profile_download +# profile_data["allowed_ssids"] = [] +# for i in parameter["ssid_modes"]: +# profile_data["ssid"][i] = [] +# for j in range(len(parameter["ssid_modes"][i])): +# profile_name = testbed + "-SSID-" + i + "-" + str(j) + "-" + parameter["mode"] +# data = parameter["ssid_modes"][i][j] +# data["profile_name"] = profile_name +# if "mode" not in dict(data).keys(): +# data["mode"] = mode +# if "vlan" not in dict(data).keys(): +# data["vlan"] = vlan_id +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# profile_data["ssid"][i].append(data) +# +# instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) +# time.sleep(10) +# +# # RF Profile Creation +# rf_profile_data = { +# "name": testbed + "-RF-Profile-" + parameter["mode"] + "-" + get_configuration["access_point"][0]["mode"] +# } +# try: +# instantiate_profile.delete_profile_by_name(profile_name=rf_profile_data["name"]) +# rf_profile_data = instantiate_profile.set_rf_profile(profile_data=rf_profile_data, +# mode=get_configuration["access_point"][0]["mode"]) +# allure.attach(body=str(rf_profile_data), +# name="RF Profile Created : " + get_configuration["access_point"][0]["mode"]) +# except Exception as e: +# print(e) +# allure.attach(body=str(e), name="Exception ") +# +# # Radius Profile Creation +# passpoint_radius_server_info = passpoint_radius_server_info +# passpoint_radius_server_info["name"] = testbed + "-Automation-Radius-Profile" +# instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile") +# try: +# instantiate_profile.create_radius_profile(radius_info=passpoint_radius_server_info, +# radius_accounting_info=passpoint_radius_accounting_server_info) +# test_cases["radius_profile"] = True +# allure.attach(body=str(passpoint_radius_server_info), name="Radius Profile Created") +# except Exception as e: +# print(e) +# test_cases["radius_profile"] = False +# +# # SSID Profile Creation +# for mode in profile_data["ssid"]: +# if mode == "open": +# for j in profile_data["ssid"][mode]: +# try: +# if "is2dot4GHz" in list(j["appliedRadios"]): +# creates_profile = instantiate_profile.create_open_ssid_profile(profile_data=j) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# if mode == "wpa_eap": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# try: +# if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["wpa_eap_5g"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# if mode == "wpa2_eap": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# try: +# if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_eap_passpoint_ssid_profile(profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# if mode == "wpa2_only_eap": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if "twog" in get_markers.keys() and get_markers["twog"] and "is2dot4GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( +# profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# try: +# if "fiveg" in get_markers.keys() and get_markers["fiveg"] and "is5GHz" in list( +# j["appliedRadios"]): +# creates_profile = instantiate_profile.create_wpa2_only_eap_passpoint_ssid_profile( +# profile_data=j) +# profile_data["allowed_ssids"].append(creates_profile._id) +# test_cases[j["ssid_name"]] = {"sdk": True} +# allure.attach(body=str(creates_profile), name="SSID Profile Created") +# except Exception as e: +# print(e) +# test_cases[j["ssid_name"]] = {"sdk": False} +# allure.attach(body=str(e), name="SSID Profile Creation Failed") +# +# # Passpoint OSU ID provider profile creation +# passpoint_provider_info = passpoint_provider_info +# test_cases["passpoint_osu_id_provider"] = dict() +# profile_name = testbed + "-Automation-Passpoint-OSU-ID-Provider-Profile" +# passpoint_provider_info["profile_name"] = profile_name +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_osu_id_provider_profile( +# profile_data=passpoint_provider_info) +# allure.attach(body=str(creates_profile), name="Passpoint OSU ID provider Profile Created") +# test_cases["passpoint_osu_id_provider"] = {"sdk": True} +# except Exception as e: +# print(e) +# test_cases["passpoint_osu_id_provider"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint OSU ID provider Profile Creation Failed") +# +# # Passpoint operator profile creation +# test_cases["passpoint_operator_profile"] = dict() +# passpoint_operator_info = passpoint_operator_info +# profile_name = testbed + "-Automation-Passpoint-Operator-Profile" +# passpoint_operator_info["profile_name"] = profile_name +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_operator_profile(profile_data=passpoint_operator_info) +# allure.attach(body=str(creates_profile), name="Passpoint Operator Profile Created") +# test_cases["passpoint_operator_profile"] = {"sdk": True} +# profile_data["passpoint_operator"] = profile_name +# except Exception as e: +# print(e) +# test_cases["passpoint_operator_profile"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint Operator Profile Creation Failed") +# +# # Passpoint Venue profile creation +# passpoint_venue_info = passpoint_venue_info +# test_cases["passpoint_venue_profile"] = dict() +# profile_name = testbed + "-Automation-Passpoint-Venue-Profile" +# passpoint_venue_info["profile_name"] = profile_name +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_venue_profile(profile_data=passpoint_venue_info) +# allure.attach(body=str(creates_profile), name="Passpoint Venue Profile Created") +# test_cases["passpoint_venue_profile"] = {"sdk": True} +# profile_data["passpoint_venue"] = profile_name +# except Exception as e: +# print(e) +# test_cases["passpoint_venue"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint Venue Profile Creation Failed") +# +# # Passpoint profile creation +# passpoint_profile_info = passpoint_profile_info +# profile_name = testbed + "-Automation-Passpoint-Profile" +# passpoint_profile_info["profile_name"] = profile_name +# passpoint_profile_info["allowed_ssids"] = profile_data["allowed_ssids"] +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# try: +# creates_profile = instantiate_profile.create_passpoint_profile(profile_data=passpoint_profile_info) +# allure.attach(body=str(creates_profile), name="Passpoint Profile Created") +# test_cases["passpoint"] = {"sdk": True} +# profile_data["passpoint"] = profile_name +# except Exception as e: +# print(e) +# test_cases["passpoint"] = {"sdk": False} +# allure.attach(body=str(e), name="Passpoint Profile Creation Failed") +# +# # Update SSID profile with passpoint config +# passpoint_profile_info = passpoint_profile_info +# ssid_to_apply = None +# for ssid_profile in profile_data["ssid"].keys(): +# for ssid in profile_data["ssid"][ssid_profile]: +# if ssid["ssid_name"] == "passpoint_profile_download": +# ssid_to_apply = ssid["ssid_name"] +# continue +# if ssid["ssid_name"] in test_cases.keys(): +# allure.attach(body=str(ssid), name="Updating SSID profile") +# passpoint_profile_info["ssid_profile_name"] = ssid["profile_name"] +# instantiate_profile.update_ssid_profile(profile_info=passpoint_profile_info) +# +# # Equipment AP Profile Creation +# ap_profile_info = dict() +# ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] +# ap_profile_info["ssid_names"] = [ssid_to_apply] +# try: +# instantiate_profile.set_ap_profile_custom(profile_data=ap_profile_info) +# test_cases["equipment_ap"] = {"sdk": True} +# allure.attach(body=str(profile_data["equipment_ap"]), name="Equipment AP Profile Created") +# except Exception as e: +# print(e) +# test_cases["equipment_ap"] = {"sdk": False} +# allure.attach(body=str(e), name="Equipment AP Profile Creation Failed") +# +# +# def teardown_session(): +# print("\nRemoving Profiles") +# instantiate_profile.delete_profile_by_name(profile_name=profile_data['equipment_ap']['profile_name']) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["ssid"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["radius"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["rf"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_osu_id_provider"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_operator"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint_venue"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["passpoint"]) +# allure.attach(body=str(profile_data['equipment_ap']['profile_name'] + "\n"), +# name="Tear Down in Profiles ") +# time.sleep(20) +# +# request.addfinalizer(teardown_session) +# yield test_cases, instantiate_profile, profile_data +# +# +# @pytest.fixture(scope="function") +# def push_ap_profile(request, setup_profiles, get_equipment_ref, get_apnos, get_configuration): +# parameter = dict(request.param) +# test_cases, instantiate_profile, profile_data = setup_profiles +# ssid_names = parameter["ssid_names"] +# ap_profile_info = dict() +# ap_profile_info["profile_name"] = profile_data["equipment_ap"]["profile_name"] +# test_cases = {} +# ap_profile_info["ssid_names"] = ssid_names +# try: +# instantiate_profile.update_ap_profile(profile_data=ap_profile_info) +# test_cases["equipment_ap"] = {"sdk": True} +# allure.attach(body=str(ap_profile_info["profile_name"]), name="Equipment AP Profile Updated") +# except Exception as e: +# print(e) +# test_cases["equipment_ap"] = {"sdk": False} +# allure.attach(body=str(e), name="Equipment AP Profile Update Failed") +# +# print("Pushing profiles on AP :: ", ap_profile_info) +# allure.attach(body=str(ap_profile_info), name="Pushing profiles on AP :: ") +# # Push the Equipment AP Profile to AP +# try: +# for i in get_equipment_ref: +# instantiate_profile.push_profile_old_method(equipment_id=i) +# except Exception as e: +# print(e) +# print("failed to push AP Profile") +# +# # Check the VIF Config and VIF State of SSIDs +# time_start = time.time() +# ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") +# while time.time() - time_start < 240: +# if ((time.time() - time_start) / 10) == 15: +# ap_ssh = get_apnos(get_configuration["access_point"][0], pwd="../libs/apnos/") +# vif_config = list(ap_ssh.get_vif_config_ssids()) +# vif_config.sort() +# vif_state = list(ap_ssh.get_vif_state_ssids()) +# vif_state.sort() +# for ssid in ssid_names: +# test_cases[ssid] = dict() +# test_cases[ssid]["vif_config"] = True if ssid in vif_config else False +# test_cases[ssid]["vif_state"] = True if ssid in vif_state else False +# ssid_names.sort() +# if vif_config == ssid_names == vif_state: +# print("Waiting for Radios to apply config ") +# time.sleep(200) +# break +# time.sleep(10) +# allure.attach(body=str(vif_config), name="vifC status on AP :: ") +# allure.attach(body=str(vif_state), name="vifS status on AP :: ") +# +# yield test_cases +# +# +# @pytest.fixture(scope="session") +# def passpoint_radius_server_info(): +# allure.attach(body=str(PASSPOINT_RADIUS_SERVER_DATA), name="Passpoint RADIUS server Info: ") +# yield PASSPOINT_RADIUS_SERVER_DATA +# +# +# @pytest.fixture(scope="session") +# def passpoint_radius_accounting_server_info(): +# allure.attach(body=str(PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA), name="Passpoint RADIUS account server Info: ") +# yield PASSPOINT_RADIUS_ACCOUNTING_SERVER_DATA +# +# +# @pytest.fixture(scope="session") +# def passpoint_provider_info(): +# allure.attach(body=str(PASSPOINT_PROVIDER_INFO), name="Passpoint Provider Info: ") +# yield PASSPOINT_PROVIDER_INFO +# +# +# @pytest.fixture(scope="session") +# def passpoint_operator_info(): +# allure.attach(body=str(PASSPOINT_OPERATOR_INFO), name="Passpoint operator Info: ") +# yield PASSPOINT_OPERATOR_INFO +# +# +# @pytest.fixture(scope="session") +# def passpoint_venue_info(): +# allure.attach(body=str(PASSPOINT_VENUE_INFO), name="Passpoint venue Info: ") +# yield PASSPOINT_VENUE_INFO +# +# +# @pytest.fixture(scope="session") +# def passpoint_profile_info(): +# allure.attach(body=str(PASSPOINT_PROFILE_INFO), name="Passpoint profile Info: ") +# yield PASSPOINT_PROFILE_INFO diff --git a/tests/e2e/mesh/conftest.py b/tests/e2e/mesh/conftest.py index 7538ec491..5aa9b3922 100644 --- a/tests/e2e/mesh/conftest.py +++ b/tests/e2e/mesh/conftest.py @@ -1,160 +1,160 @@ -import json -import os -import sys - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -if "libs" not in sys.path: - sys.path.append(f'../libs') - -from controller.controller_1x.controller import ProfileUtility -from controller.controller_2x.controller import UProfileUtility -import time -from lanforge.lf_tests import RunTest -from lanforge.lf_tools import ChamberView -import pytest -import allure - - -@pytest.fixture(scope="session") -def instantiate_profile(request): - if request.config.getoption("1.x"): - yield ProfileUtility - else: - yield UProfileUtility - - -@pytest.fixture(scope="session") -def lf_tools(get_configuration, testbed): - lf_tools_obj = ChamberView(lanforge_data=get_configuration['traffic_generator']['details'], - access_point_data=get_configuration['access_point'], - testbed=testbed) - yield lf_tools_obj - - -@pytest.fixture(scope="session") -def create_lanforge_chamberview(lf_tools): - scenario_object, scenario_name = lf_tools.Chamber_View() - return scenario_name - - -@pytest.fixture(scope="session") -def create_lanforge_chamberview_dut(lf_tools): - dut_object, dut_name = lf_tools.Create_Dut() - yield dut_name - -@pytest.fixture(scope="session") -def setup_mesh_scenario(lf_tools): - mesh_obj = lf_tools.create_mesh_scenario() - yield mesh_obj - -@pytest.fixture(scope="session") -def create_lanforge_chamberview_dut(lf_tools, skip_lf): - dut_name = "" - if not skip_lf: - dut_object, dut_name = lf_tools.Create_Dut() - return dut_name - -@pytest.fixture(scope="session") -def create_mesh_dut(lf_tools, skip_lf, ssid_data): - dut_name = "" - if not skip_lf: - mesh_dut_object, dut_name = lf_tools.create_mesh_dut(ssid_data=ssid_data) - yield dut_name - -@pytest.fixture(scope="class") -def setup_mesh_profile_fix(request, fixtures_ver, get_apnos, get_configuration, setup_controller, instantiate_profile,get_markers, get_equipment_ref, - lf_tools, ): - param = dict(request.param) - ret_var = fixtures_ver.setup_mesh_profile(request, param, get_apnos, get_configuration, setup_controller, instantiate_profile, get_markers, get_equipment_ref, - lf_tools, skip_lf=False, open_flow=None - ) - yield ret_var - - -@pytest.fixture(scope="class") -def setup_profiles(request, setup_controller, testbed, get_equipment_id, fixtures_ver, - instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info): - lf_tools.reset_scenario() - param = dict(request.param) - - # VLAN Setup - if request.param["mode"] == "VLAN": - - vlan_list = list() - refactored_vlan_list = list() - ssid_modes = request.param["ssid_modes"].keys() - for mode in ssid_modes: - for ssid in range(len(request.param["ssid_modes"][mode])): - if "vlan" in request.param["ssid_modes"][mode][ssid]: - vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) - else: - pass - if vlan_list: - [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] - vlan_list = refactored_vlan_list - for i in range(len(vlan_list)): - if vlan_list[i] > 4095 or vlan_list[i] < 1: - vlan_list.pop(i) - if request.param["mode"] == "VLAN": - lf_tools.add_vlan(vlan_ids=vlan_list) - - # call this, if 1.x - return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_id, - instantiate_profile, - get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, - radius_accounting_info) - - yield return_var - - -@pytest.fixture(scope="session") -def lf_test(get_configuration, setup_influx): - obj = RunTest(configuration_data=get_configuration, influx_params=setup_influx) - yield obj - - -@pytest.fixture(scope="session") -def station_names_twog(request, get_configuration): - station_names = [] - for i in range(0, int(request.config.getini("num_stations"))): - station_names.append(get_configuration["traffic_generator"]["details"]["2.4G-Station-Name"] + "0" + str(i)) - yield station_names - - -@pytest.fixture(scope="session") -def station_names_fiveg(request, get_configuration): - station_names = [] - for i in range(0, int(request.config.getini("num_stations"))): - station_names.append(get_configuration["traffic_generator"]["details"]["5G-Station-Name"] + "0" + str(i)) - yield station_names - - -@pytest.fixture(scope="session") -def num_stations(request): - num_sta = int(request.config.getini("num_stations")) - yield num_sta - - -@pytest.fixture(scope="class") -def get_vif_state(get_apnos, get_configuration, request, lf_tools): - if request.config.getoption("1.x"): - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") - vif_state = list(ap_ssh.get_vif_state_ssids()) - vif_state.sort() - yield vif_state - else: - yield lf_tools.ssid_list - - -@pytest.fixture(scope="class") -def get_vlan_list(get_apnos, get_configuration): - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") - vlan_list = list(ap_ssh.get_vlan()) - vlan_list.sort() - yield vlan_list +# import json +# import os +# import sys +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# if "libs" not in sys.path: +# sys.path.append(f'../libs') +# +# from controller.controller_1x.controller import ProfileUtility +# from controller.controller_2x.controller import UProfileUtility +# import time +# from lanforge.lf_tests import RunTest +# from lanforge.lf_tools import ChamberView +# import pytest +# import allure +# +# +# @pytest.fixture(scope="session") +# def instantiate_profile(request): +# if request.config.getoption("1.x"): +# yield ProfileUtility +# else: +# yield UProfileUtility +# +# +# @pytest.fixture(scope="session") +# def lf_tools(get_configuration, testbed): +# lf_tools_obj = ChamberView(lanforge_data=get_configuration['traffic_generator']['details'], +# access_point_data=get_configuration['access_point'], +# testbed=testbed) +# yield lf_tools_obj +# +# +# @pytest.fixture(scope="session") +# def create_lanforge_chamberview(lf_tools): +# scenario_object, scenario_name = lf_tools.Chamber_View() +# return scenario_name +# +# +# @pytest.fixture(scope="session") +# def create_lanforge_chamberview_dut(lf_tools): +# dut_object, dut_name = lf_tools.Create_Dut() +# yield dut_name +# +# @pytest.fixture(scope="session") +# def setup_mesh_scenario(lf_tools): +# mesh_obj = lf_tools.create_mesh_scenario() +# yield mesh_obj +# +# @pytest.fixture(scope="session") +# def create_lanforge_chamberview_dut(lf_tools, skip_lf): +# dut_name = "" +# if not skip_lf: +# dut_object, dut_name = lf_tools.Create_Dut() +# return dut_name +# +# @pytest.fixture(scope="session") +# def create_mesh_dut(lf_tools, skip_lf, ssid_data): +# dut_name = "" +# if not skip_lf: +# mesh_dut_object, dut_name = lf_tools.create_mesh_dut(ssid_data=ssid_data) +# yield dut_name +# +# @pytest.fixture(scope="class") +# def setup_mesh_profile_fix(request, fixtures_ver, get_apnos, get_configuration, setup_controller, instantiate_profile,get_markers, get_equipment_ref, +# lf_tools, ): +# param = dict(request.param) +# ret_var = fixtures_ver.setup_mesh_profile(request, param, get_apnos, get_configuration, setup_controller, instantiate_profile, get_markers, get_equipment_ref, +# lf_tools, skip_lf=False, open_flow=None +# ) +# yield ret_var +# +# +# @pytest.fixture(scope="class") +# def setup_profiles(request, setup_controller, testbed, get_equipment_id, fixtures_ver, +# instantiate_profile, get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info): +# lf_tools.reset_scenario() +# param = dict(request.param) +# +# # VLAN Setup +# if request.param["mode"] == "VLAN": +# +# vlan_list = list() +# refactored_vlan_list = list() +# ssid_modes = request.param["ssid_modes"].keys() +# for mode in ssid_modes: +# for ssid in range(len(request.param["ssid_modes"][mode])): +# if "vlan" in request.param["ssid_modes"][mode][ssid]: +# vlan_list.append(request.param["ssid_modes"][mode][ssid]["vlan"]) +# else: +# pass +# if vlan_list: +# [refactored_vlan_list.append(x) for x in vlan_list if x not in refactored_vlan_list] +# vlan_list = refactored_vlan_list +# for i in range(len(vlan_list)): +# if vlan_list[i] > 4095 or vlan_list[i] < 1: +# vlan_list.pop(i) +# if request.param["mode"] == "VLAN": +# lf_tools.add_vlan(vlan_ids=vlan_list) +# +# # call this, if 1.x +# return_var = fixtures_ver.setup_profiles(request, param, setup_controller, testbed, get_equipment_id, +# instantiate_profile, +# get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, +# radius_accounting_info) +# +# yield return_var +# +# +# @pytest.fixture(scope="session") +# def lf_test(get_configuration, setup_influx): +# obj = RunTest(configuration_data=get_configuration, influx_params=setup_influx) +# yield obj +# +# +# @pytest.fixture(scope="session") +# def station_names_twog(request, get_configuration): +# station_names = [] +# for i in range(0, int(request.config.getini("num_stations"))): +# station_names.append(get_configuration["traffic_generator"]["details"]["2.4G-Station-Name"] + "0" + str(i)) +# yield station_names +# +# +# @pytest.fixture(scope="session") +# def station_names_fiveg(request, get_configuration): +# station_names = [] +# for i in range(0, int(request.config.getini("num_stations"))): +# station_names.append(get_configuration["traffic_generator"]["details"]["5G-Station-Name"] + "0" + str(i)) +# yield station_names +# +# +# @pytest.fixture(scope="session") +# def num_stations(request): +# num_sta = int(request.config.getini("num_stations")) +# yield num_sta +# +# +# @pytest.fixture(scope="class") +# def get_vif_state(get_apnos, get_configuration, request, lf_tools): +# if request.config.getoption("1.x"): +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") +# vif_state = list(ap_ssh.get_vif_state_ssids()) +# vif_state.sort() +# yield vif_state +# else: +# yield lf_tools.ssid_list +# +# +# @pytest.fixture(scope="class") +# def get_vlan_list(get_apnos, get_configuration): +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/") +# vlan_list = list(ap_ssh.get_vlan()) +# vlan_list.sort() +# yield vlan_list diff --git a/tests/fixtures_1x.py b/tests/fixtures_1x.py index 8fe12c006..28d04bad7 100644 --- a/tests/fixtures_1x.py +++ b/tests/fixtures_1x.py @@ -1,663 +1,663 @@ -import sys -import os -if "libs" not in sys.path: - sys.path.append(f'../libs') -for folder in 'py-json', 'py-scripts': - if folder not in sys.path: - sys.path.append(f'../lanforge/lanforge-scripts/{folder}') - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -sys.path.append(f"../lanforge/lanforge-scripts/py-scripts/tip-cicd-sanity") - -sys.path.append(f'../libs') -sys.path.append(f'../libs/lanforge/') - -from LANforge.LFUtils import * - -if 'py-json' not in sys.path: - sys.path.append('../py-scripts') -from apnos.apnos import APNOS -from controller.controller_1x.controller import Controller -from controller.controller_1x.controller import FirmwareUtility -import pytest -from cv_test_manager import cv_test -from configuration import CONFIGURATION -from configuration import RADIUS_SERVER_DATA -from configuration import RADIUS_ACCOUNTING_DATA -from testrails.testrail_api import APIClient -from testrails.reporting import Reporting -from lf_tools import ChamberView -from sta_connect2 import StaConnect2 -from os import path -from typing import Any, Callable, Optional - -import time -import allure -import pytest - -class Fixtures_1x: - - def __init__(self, configuration={}): - self.lab_info = configuration - print(self.lab_info) - print("1.X") - try: - self.controller_obj = Controller(controller_data=self.lab_info["controller"]) - except Exception as e: - print(e) - allure.attach(body=str(e), name="Controller Instantiation Failed: ") - sdk_client = False - pytest.exit("unable to communicate to Controller" + str(e)) - - def disconnect(self): - self.controller_obj.disconnect_Controller() - - def setup_firmware(self): - pass - - def get_sdk_version(self): - version = self.controller_obj.get_sdk_version() - return version - - def get_ap_cloud_connectivity_status(self, get_configuration, get_apnos): - mgr_status = [] - for access_point_info in get_configuration['access_point']: - ap_ssh = get_apnos(access_point_info, sdk="1.x") - status = ap_ssh.get_manager_state() - if "ACTIVE" not in status: - time.sleep(30) - ap_ssh = APNOS(access_point_info) - status = ap_ssh.get_manager_state() - mgr_status.append(status) - return mgr_status - - def get_ap_version(self, get_apnos, get_configuration): -# version_list = [] +# import sys +# import os +# if "libs" not in sys.path: +# sys.path.append(f'../libs') +# for folder in 'py-json', 'py-scripts': +# if folder not in sys.path: +# sys.path.append(f'../lanforge/lanforge-scripts/{folder}') +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# sys.path.append(f"../lanforge/lanforge-scripts/py-scripts/tip-cicd-sanity") +# +# sys.path.append(f'../libs') +# sys.path.append(f'../libs/lanforge/') +# +# from LANforge.LFUtils import * +# +# if 'py-json' not in sys.path: +# sys.path.append('../py-scripts') +# from apnos.apnos import APNOS +# from controller.controller_1x.controller import Controller +# from controller.controller_1x.controller import FirmwareUtility +# import pytest +# from cv_test_manager import cv_test +# from configuration import CONFIGURATION +# from configuration import RADIUS_SERVER_DATA +# from configuration import RADIUS_ACCOUNTING_DATA +# from testrails.testrail_api import APIClient +# from testrails.reporting import Reporting +# from lf_tools import ChamberView +# from sta_connect2 import StaConnect2 +# from os import path +# from typing import Any, Callable, Optional +# +# import time +# import allure +# import pytest +# +# class Fixtures_1x: +# +# def __init__(self, configuration={}): +# self.lab_info = configuration +# print(self.lab_info) +# print("1.X") +# try: +# self.controller_obj = Controller(controller_data=self.lab_info["controller"]) +# except Exception as e: +# print(e) +# allure.attach(body=str(e), name="Controller Instantiation Failed: ") +# sdk_client = False +# pytest.exit("unable to communicate to Controller" + str(e)) +# +# def disconnect(self): +# self.controller_obj.disconnect_Controller() +# +# def setup_firmware(self): +# pass +# +# def get_sdk_version(self): +# version = self.controller_obj.get_sdk_version() +# return version +# +# def get_ap_cloud_connectivity_status(self, get_configuration, get_apnos): +# mgr_status = [] # for access_point_info in get_configuration['access_point']: -# ap_ssh = get_apnos(access_point_info) -# version = ap_ssh.get_ap_version_ucentral() -# version_list.append(version) - return ["-\n-"] - - def setup_profiles(self, request, param, setup_controller, testbed, get_equipment_ref, instantiate_profile, - get_markers, create_lanforge_chamberview_dut, lf_tools, - get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info, skip_lf=False): - - instantiate_profile = instantiate_profile(sdk_client=setup_controller) - vlan_id, mode = 0, 0 - instantiate_profile.cleanup_objects() - parameter = dict(param) - print(parameter) - test_cases = {} - profile_data = {} - if parameter['mode'] not in ["BRIDGE", "NAT", "VLAN"]: - print("Invalid Mode: ", parameter['mode']) - allure.attach(body=parameter['mode'], name="Invalid Mode: ") - return test_cases - - if parameter['mode'] == "NAT": - mode = "NAT" - vlan_id = 1 - if parameter['mode'] == "BRIDGE": - mode = "BRIDGE" - vlan_id = 1 - if parameter['mode'] == "VLAN": - mode = "BRIDGE" - - instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Equipment-AP-" + parameter['mode']) - - profile_data["equipment_ap"] = {"profile_name": testbed + "-Equipment-AP-" + parameter['mode']} - profile_data["ssid"] = {} - for i in parameter["ssid_modes"]: - profile_data["ssid"][i] = [] - for j in range(len(parameter["ssid_modes"][i])): - profile_name = testbed + "-SSID-" + i + "-" + str(j) + "-" + parameter['mode'] - data = parameter["ssid_modes"][i][j] - data["profile_name"] = profile_name - if "mode" not in dict(data).keys(): - data["mode"] = mode - if "vlan" not in dict(data).keys(): - data["vlan"] = vlan_id - instantiate_profile.delete_profile_by_name(profile_name=profile_name) - profile_data["ssid"][i].append(data) - # print(profile_name) - # print(profile_data) - - instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) - time.sleep(10) - """ - Setting up rf profile - """ - rf_profile_data = { - "name": "RF-Profile-" + testbed + "-" + parameter['mode'] + "-" + - get_configuration['access_point'][0]['mode'] - } - - for i in parameter["rf"]: - rf_profile_data[i] = parameter['rf'][i] - # print(rf_profile_data) - - try: - instantiate_profile.delete_profile_by_name(profile_name=rf_profile_data['name']) - instantiate_profile.set_rf_profile(profile_data=rf_profile_data, - mode=get_configuration['access_point'][0]['mode']) - allure.attach(body=str(rf_profile_data), - name="RF Profile Created : " + get_configuration['access_point'][0]['mode']) - except Exception as e: - print(e) - allure.attach(body=str(e), name="Exception ") - - # Radius Profile Creation - if parameter["radius"]: - radius_info = radius_info - radius_info["name"] = testbed + "-Automation-Radius-Profile-" + mode - instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) - try: - instantiate_profile.create_radius_profile(radius_info=radius_info) - allure.attach(body=str(radius_info), - name="Radius Profile Created") - test_cases['radius_profile'] = True - except Exception as e: - print(e) - test_cases['radius_profile'] = False - - # SSID Profile Creation - lf_dut_data = [] - for mode in profile_data['ssid']: - if mode == "open": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_open_ssid_profile(profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["open_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["open_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["open_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["open_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - - if mode == "wpa": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa_ssid_profile(profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - - if mode == "wpa2_personal": - for j in profile_data["ssid"][mode]: - # print(j) - - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa2_personal_ssid_profile(profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa2_personal_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa2_personal_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa2_personal_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa2_personal_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - - if mode == "wpa_wpa2_personal_mixed": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - - creates_profile = instantiate_profile.create_wpa_wpa2_personal_mixed_ssid_profile( - profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_wpa2_personal_mixed_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_wpa2_personal_mixed_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_wpa2_personal_mixed_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_wpa2_personal_mixed_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - - if mode == "wpa3_personal": - for j in profile_data["ssid"][mode]: - print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - - creates_profile = instantiate_profile.create_wpa3_personal_ssid_profile(profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_personal_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_personal_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_personal_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_personal_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - if mode == "wpa3_personal_mixed": - for j in profile_data["ssid"][mode]: - print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa3_personal_mixed_ssid_profile( - profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_personal_mixed_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_personal_mixed_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_personal_mixed_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_personal_mixed_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - - if mode == "wpa_enterprise": - for j in profile_data["ssid"][mode]: - - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa_enterprise_ssid_profile(profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_enterprise_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_enterprise_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_enterprise_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_enterprise_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - if mode == "wpa2_enterprise": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa2_enterprise_ssid_profile(profile_data=j) - - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa2_enterprise_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa2_enterprise_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa2_enterprise_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa2_enterprise_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - if mode == "wpa3_enterprise": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa3_enterprise_ssid_profile(profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_enterprise_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_enterprise_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_enterprise_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_enterprise_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - - if mode == "wpa_wpa2_enterprise_mixed": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa_wpa2_enterprise_mixed_ssid_profile( - profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_wpa2_enterprise_mixed_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_wpa2_enterprise_mixed_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa_wpa2_enterprise_mixed_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa_wpa2_enterprise_mixed_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - if mode == "wpa3_enterprise_mixed": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wpa3_enterprise_mixed_ssid_profile( - profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_enterprise_mixed_2g"] = True - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_enterprise_mixed_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wpa3_enterprise_mixed_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wpa3_enterprise_mixed_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - - if mode == "wep": - for j in profile_data["ssid"][mode]: - # print(j) - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - for i in range(len(j["appliedRadios"])): - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") - j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") - creates_profile = instantiate_profile.create_wep_ssid_profile(profile_data=j) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wep_2g"] = True - if j["appliedRadios"].__contains__("is5GHzU"): - test_cases["wep_5g"] = True - allure.attach(body=str(creates_profile), - name="SSID Profile Created") - except Exception as e: - print(e) - if j["appliedRadios"].__contains__("is2dot4GHz"): - test_cases["wep_2g"] = False - if j["appliedRadios"].__contains__("is5GHz"): - test_cases["wep_5g"] = False - allure.attach(body=str(e), - name="SSID Profile Creation Failed") - # Equipment AP Profile Creation - try: - instantiate_profile.set_ap_profile(profile_data=profile_data['equipment_ap']) - test_cases["equipment_ap"] = True - allure.attach(body=str(profile_data['equipment_ap']), - name="Equipment AP Profile Created") - except Exception as e: - print(e) - test_cases["equipment_ap"] = False - allure.attach(body=str(e), - name="Equipment AP Profile Creation Failed") - - # Push the Equipment AP Profile to AP - try: - for i in get_equipment_ref: - instantiate_profile.push_profile_old_method(equipment_id=i) - except Exception as e: - print(e) - print("failed to create AP Profile") - - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") - # ssid_names = [] - # for i in instantiate_profile.profile_creation_ids["ssid"]: - # ssid_names.append(instantiate_profile.get_ssid_name_by_profile_id(profile_id=i)) - # ssid_names.sort() - ssid_names = [] - for i in lf_dut_data: - ssid_names.append(i["ssid_name"]) - ssid_names.sort() - # This loop will check the VIF Config with cloud profile - vif_config = [] - test_cases['vifc'] = False - for i in range(0, 18): - vif_config = list(ap_ssh.get_vif_config_ssids()) - vif_config.sort() - print(vif_config) - print(ssid_names) - if ssid_names == vif_config: - test_cases['vifc'] = True - break - time.sleep(10) - allure.attach( - body=str("VIF Config: " + str(vif_config) + "\n" + "SSID Pushed from Controller: " + str(ssid_names)), - name="SSID Profiles in VIF Config and Controller: ") - ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") - - # This loop will check the VIF Config with VIF State - test_cases['vifs'] = False - for i in range(0, 18): - vif_state = list(ap_ssh.get_vif_state_ssids()) - vif_state.sort() - vif_config = list(ap_ssh.get_vif_config_ssids()) - vif_config.sort() - print(vif_config) - print(vif_state) - if vif_state == vif_config: - test_cases['vifs'] = True - break - time.sleep(10) - allure.attach(body=str("VIF Config: " + str(vif_config) + "\n" + "VIF State: " + str(vif_state)), - name="SSID Profiles in VIF Config and VIF State: ") - - ap_logs = ap_ssh.logread() - allure.attach(body=ap_logs, name="AP LOgs: ") - # ssid_info = ap_ssh.get_ssid_info() - # ssid_data = [] - # print(ssid_info) - # band_mapping = ap_ssh.get_bssid_band_mapping() - # print(band_mapping) - # idx_mapping = {} - # for i in range(0, len(ssid_info)): - # if ssid_info[i][1] == "OPEN": - # ssid_info[i].append("") - # if ssid_info[i][1] == "OPEN": - # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=OPEN" + - # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] - # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], - # ssid_info[i][0]] - # - # if ssid_info[i][1] == "WPA": - # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA" + - # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] - # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], - # ssid_info[i][0]] - # if ssid_info[i][1] == "WPA2": - # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA2" + - # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] - # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], - # ssid_info[i][0]] - # if ssid_info[i][1] == "WPA3_PERSONAL": - # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA3" + - # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] - # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], - # ssid_info[i][0]] - # - # if ssid_info[i][1] == "WPA | WPA2": - # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA|WPA2" + - # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] - # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], - # ssid_info[i][0]] - # - # if ssid_info[i][1] == "EAP-TTLS": - # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=EAP-TTLS" + - # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] - # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], - # ssid_info[i][0]] - # ssid_data.append(ssid) - # lf_tools.dut_idx_mapping = idx_mapping - # # Add bssid password and security from iwinfo data - # # Format SSID Data in the below format - # # ssid_data = [ - # # ['ssid_idx=0 ssid=Default-SSID-2g security=WPA|WEP| password=12345678 bssid=90:3c:b3:94:48:58'], - # # ['ssid_idx=1 ssid=Default-SSID-5gl password=12345678 bssid=90:3c:b3:94:48:59'] - # # ] - # allure.attach(name="SSID DATA IN LF DUT", body=str(ssid_data)) - # lf_tools.update_ssid(ssid_data=ssid_data) - - def teardown_session(): - print("\nRemoving Profiles") - instantiate_profile.delete_profile_by_name(profile_name=profile_data['equipment_ap']['profile_name']) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["ssid"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["radius"]) - instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["rf"]) - allure.attach(body=str(profile_data['equipment_ap']['profile_name'] + "\n"), - name="Tear Down in Profiles ") - time.sleep(20) - - request.addfinalizer(teardown_session) - return test_cases +# ap_ssh = get_apnos(access_point_info, sdk="1.x") +# status = ap_ssh.get_manager_state() +# if "ACTIVE" not in status: +# time.sleep(30) +# ap_ssh = APNOS(access_point_info) +# status = ap_ssh.get_manager_state() +# mgr_status.append(status) +# return mgr_status +# +# def get_ap_version(self, get_apnos, get_configuration): +# # version_list = [] +# # for access_point_info in get_configuration['access_point']: +# # ap_ssh = get_apnos(access_point_info) +# # version = ap_ssh.get_ap_version_ucentral() +# # version_list.append(version) +# return ["-\n-"] +# +# def setup_profiles(self, request, param, setup_controller, testbed, get_equipment_ref, instantiate_profile, +# get_markers, create_lanforge_chamberview_dut, lf_tools, +# get_security_flags, get_configuration, radius_info, get_apnos, radius_accounting_info, skip_lf=False): +# +# instantiate_profile = instantiate_profile(sdk_client=setup_controller) +# vlan_id, mode = 0, 0 +# instantiate_profile.cleanup_objects() +# parameter = dict(param) +# print(parameter) +# test_cases = {} +# profile_data = {} +# if parameter['mode'] not in ["BRIDGE", "NAT", "VLAN"]: +# print("Invalid Mode: ", parameter['mode']) +# allure.attach(body=parameter['mode'], name="Invalid Mode: ") +# return test_cases +# +# if parameter['mode'] == "NAT": +# mode = "NAT" +# vlan_id = 1 +# if parameter['mode'] == "BRIDGE": +# mode = "BRIDGE" +# vlan_id = 1 +# if parameter['mode'] == "VLAN": +# mode = "BRIDGE" +# +# instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Equipment-AP-" + parameter['mode']) +# +# profile_data["equipment_ap"] = {"profile_name": testbed + "-Equipment-AP-" + parameter['mode']} +# profile_data["ssid"] = {} +# for i in parameter["ssid_modes"]: +# profile_data["ssid"][i] = [] +# for j in range(len(parameter["ssid_modes"][i])): +# profile_name = testbed + "-SSID-" + i + "-" + str(j) + "-" + parameter['mode'] +# data = parameter["ssid_modes"][i][j] +# data["profile_name"] = profile_name +# if "mode" not in dict(data).keys(): +# data["mode"] = mode +# if "vlan" not in dict(data).keys(): +# data["vlan"] = vlan_id +# instantiate_profile.delete_profile_by_name(profile_name=profile_name) +# profile_data["ssid"][i].append(data) +# # print(profile_name) +# # print(profile_data) +# +# instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) +# time.sleep(10) +# """ +# Setting up rf profile +# """ +# rf_profile_data = { +# "name": "RF-Profile-" + testbed + "-" + parameter['mode'] + "-" + +# get_configuration['access_point'][0]['mode'] +# } +# +# for i in parameter["rf"]: +# rf_profile_data[i] = parameter['rf'][i] +# # print(rf_profile_data) +# +# try: +# instantiate_profile.delete_profile_by_name(profile_name=rf_profile_data['name']) +# instantiate_profile.set_rf_profile(profile_data=rf_profile_data, +# mode=get_configuration['access_point'][0]['mode']) +# allure.attach(body=str(rf_profile_data), +# name="RF Profile Created : " + get_configuration['access_point'][0]['mode']) +# except Exception as e: +# print(e) +# allure.attach(body=str(e), name="Exception ") +# +# # Radius Profile Creation +# if parameter["radius"]: +# radius_info = radius_info +# radius_info["name"] = testbed + "-Automation-Radius-Profile-" + mode +# instantiate_profile.delete_profile_by_name(profile_name=testbed + "-Automation-Radius-Profile-" + mode) +# try: +# instantiate_profile.create_radius_profile(radius_info=radius_info) +# allure.attach(body=str(radius_info), +# name="Radius Profile Created") +# test_cases['radius_profile'] = True +# except Exception as e: +# print(e) +# test_cases['radius_profile'] = False +# +# # SSID Profile Creation +# lf_dut_data = [] +# for mode in profile_data['ssid']: +# if mode == "open": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_open_ssid_profile(profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["open_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["open_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["open_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["open_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# +# if mode == "wpa": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa_ssid_profile(profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# +# if mode == "wpa2_personal": +# for j in profile_data["ssid"][mode]: +# # print(j) +# +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa2_personal_ssid_profile(profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa2_personal_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa2_personal_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa2_personal_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa2_personal_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# +# if mode == "wpa_wpa2_personal_mixed": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# +# creates_profile = instantiate_profile.create_wpa_wpa2_personal_mixed_ssid_profile( +# profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_wpa2_personal_mixed_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_wpa2_personal_mixed_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_wpa2_personal_mixed_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_wpa2_personal_mixed_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# +# if mode == "wpa3_personal": +# for j in profile_data["ssid"][mode]: +# print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# +# creates_profile = instantiate_profile.create_wpa3_personal_ssid_profile(profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_personal_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_personal_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_personal_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_personal_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# if mode == "wpa3_personal_mixed": +# for j in profile_data["ssid"][mode]: +# print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa3_personal_mixed_ssid_profile( +# profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_personal_mixed_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_personal_mixed_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_personal_mixed_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_personal_mixed_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# +# if mode == "wpa_enterprise": +# for j in profile_data["ssid"][mode]: +# +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa_enterprise_ssid_profile(profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_enterprise_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_enterprise_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_enterprise_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_enterprise_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# if mode == "wpa2_enterprise": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa2_enterprise_ssid_profile(profile_data=j) +# +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa2_enterprise_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa2_enterprise_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa2_enterprise_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa2_enterprise_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# if mode == "wpa3_enterprise": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa3_enterprise_ssid_profile(profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_enterprise_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_enterprise_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_enterprise_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_enterprise_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# +# if mode == "wpa_wpa2_enterprise_mixed": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa_wpa2_enterprise_mixed_ssid_profile( +# profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_wpa2_enterprise_mixed_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_wpa2_enterprise_mixed_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa_wpa2_enterprise_mixed_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa_wpa2_enterprise_mixed_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# if mode == "wpa3_enterprise_mixed": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wpa3_enterprise_mixed_ssid_profile( +# profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_enterprise_mixed_2g"] = True +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_enterprise_mixed_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wpa3_enterprise_mixed_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wpa3_enterprise_mixed_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# +# if mode == "wep": +# for j in profile_data["ssid"][mode]: +# # print(j) +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# for i in range(len(j["appliedRadios"])): +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GU", "is5GHzU") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5GL", "is5GHzL") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("5G", "is5GHz") +# j["appliedRadios"][i] = j["appliedRadios"][i].replace("2G", "is2dot4GHz") +# creates_profile = instantiate_profile.create_wep_ssid_profile(profile_data=j) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wep_2g"] = True +# if j["appliedRadios"].__contains__("is5GHzU"): +# test_cases["wep_5g"] = True +# allure.attach(body=str(creates_profile), +# name="SSID Profile Created") +# except Exception as e: +# print(e) +# if j["appliedRadios"].__contains__("is2dot4GHz"): +# test_cases["wep_2g"] = False +# if j["appliedRadios"].__contains__("is5GHz"): +# test_cases["wep_5g"] = False +# allure.attach(body=str(e), +# name="SSID Profile Creation Failed") +# # Equipment AP Profile Creation +# try: +# instantiate_profile.set_ap_profile(profile_data=profile_data['equipment_ap']) +# test_cases["equipment_ap"] = True +# allure.attach(body=str(profile_data['equipment_ap']), +# name="Equipment AP Profile Created") +# except Exception as e: +# print(e) +# test_cases["equipment_ap"] = False +# allure.attach(body=str(e), +# name="Equipment AP Profile Creation Failed") +# +# # Push the Equipment AP Profile to AP +# try: +# for i in get_equipment_ref: +# instantiate_profile.push_profile_old_method(equipment_id=i) +# except Exception as e: +# print(e) +# print("failed to create AP Profile") +# +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") +# # ssid_names = [] +# # for i in instantiate_profile.profile_creation_ids["ssid"]: +# # ssid_names.append(instantiate_profile.get_ssid_name_by_profile_id(profile_id=i)) +# # ssid_names.sort() +# ssid_names = [] +# for i in lf_dut_data: +# ssid_names.append(i["ssid_name"]) +# ssid_names.sort() +# # This loop will check the VIF Config with cloud profile +# vif_config = [] +# test_cases['vifc'] = False +# for i in range(0, 18): +# vif_config = list(ap_ssh.get_vif_config_ssids()) +# vif_config.sort() +# print(vif_config) +# print(ssid_names) +# if ssid_names == vif_config: +# test_cases['vifc'] = True +# break +# time.sleep(10) +# allure.attach( +# body=str("VIF Config: " + str(vif_config) + "\n" + "SSID Pushed from Controller: " + str(ssid_names)), +# name="SSID Profiles in VIF Config and Controller: ") +# ap_ssh = get_apnos(get_configuration['access_point'][0], pwd="../libs/apnos/", sdk="1.x") +# +# # This loop will check the VIF Config with VIF State +# test_cases['vifs'] = False +# for i in range(0, 18): +# vif_state = list(ap_ssh.get_vif_state_ssids()) +# vif_state.sort() +# vif_config = list(ap_ssh.get_vif_config_ssids()) +# vif_config.sort() +# print(vif_config) +# print(vif_state) +# if vif_state == vif_config: +# test_cases['vifs'] = True +# break +# time.sleep(10) +# allure.attach(body=str("VIF Config: " + str(vif_config) + "\n" + "VIF State: " + str(vif_state)), +# name="SSID Profiles in VIF Config and VIF State: ") +# +# ap_logs = ap_ssh.logread() +# allure.attach(body=ap_logs, name="AP LOgs: ") +# # ssid_info = ap_ssh.get_ssid_info() +# # ssid_data = [] +# # print(ssid_info) +# # band_mapping = ap_ssh.get_bssid_band_mapping() +# # print(band_mapping) +# # idx_mapping = {} +# # for i in range(0, len(ssid_info)): +# # if ssid_info[i][1] == "OPEN": +# # ssid_info[i].append("") +# # if ssid_info[i][1] == "OPEN": +# # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=OPEN" + +# # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] +# # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], +# # ssid_info[i][0]] +# # +# # if ssid_info[i][1] == "WPA": +# # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA" + +# # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] +# # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], +# # ssid_info[i][0]] +# # if ssid_info[i][1] == "WPA2": +# # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA2" + +# # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] +# # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], +# # ssid_info[i][0]] +# # if ssid_info[i][1] == "WPA3_PERSONAL": +# # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA3" + +# # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] +# # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], +# # ssid_info[i][0]] +# # +# # if ssid_info[i][1] == "WPA | WPA2": +# # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=WPA|WPA2" + +# # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] +# # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], +# # ssid_info[i][0]] +# # +# # if ssid_info[i][1] == "EAP-TTLS": +# # ssid = ["ssid_idx=" + str(i) + " ssid=" + ssid_info[i][3] + " security=EAP-TTLS" + +# # " password=" + ssid_info[i][2] + " bssid=" + ssid_info[i][0]] +# # idx_mapping[str(i)] = [ssid_info[i][3], ssid_info[i][2], ssid_info[i][1], band_mapping[ssid_info[i][0]], +# # ssid_info[i][0]] +# # ssid_data.append(ssid) +# # lf_tools.dut_idx_mapping = idx_mapping +# # # Add bssid password and security from iwinfo data +# # # Format SSID Data in the below format +# # # ssid_data = [ +# # # ['ssid_idx=0 ssid=Default-SSID-2g security=WPA|WEP| password=12345678 bssid=90:3c:b3:94:48:58'], +# # # ['ssid_idx=1 ssid=Default-SSID-5gl password=12345678 bssid=90:3c:b3:94:48:59'] +# # # ] +# # allure.attach(name="SSID DATA IN LF DUT", body=str(ssid_data)) +# # lf_tools.update_ssid(ssid_data=ssid_data) +# +# def teardown_session(): +# print("\nRemoving Profiles") +# instantiate_profile.delete_profile_by_name(profile_name=profile_data['equipment_ap']['profile_name']) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["ssid"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["radius"]) +# instantiate_profile.delete_profile(instantiate_profile.profile_creation_ids["rf"]) +# allure.attach(body=str(profile_data['equipment_ap']['profile_name'] + "\n"), +# name="Tear Down in Profiles ") +# time.sleep(20) +# +# request.addfinalizer(teardown_session) +# return test_cases diff --git a/tests/fixtures_3x.py b/tests/fixtures_3x.py index 6b58a9ec8..c4a057805 100644 --- a/tests/fixtures_3x.py +++ b/tests/fixtures_3x.py @@ -1,400 +1,400 @@ -import allure -import pytest -import os -import sys -""" Environment Paths """ -if "libs" not in sys.path: - sys.path.append(f'../libs') -for folder in 'py-json', 'py-scripts': - if folder not in sys.path: - sys.path.append(f'../lanforge/lanforge-scripts/{folder}') - -sys.path.append( - os.path.dirname( - os.path.realpath(__file__) - ) -) -sys.path.append(f"../lanforge/lanforge-scripts/py-scripts/tip-cicd-sanity") - -sys.path.append(f'../libs') -sys.path.append(f'../libs/lanforge/') -sys.path.append(f'../lanforge/lanforge-scripts') - -from LANforge.LFUtils import * - -if 'py-json' not in sys.path: - sys.path.append('../py-scripts') -from controller.controller_3x.controller import CController - - -class Fixtures_3x: - - def __init__(self, configuration={}, run_lf=False, cc_1=False): - self.lab_info = configuration - self.run_lf = run_lf - self.cc_1 = cc_1 - # print(self.lab_info) - print("cc.1") - self.controller_obj = "" - - - def setup_profiles(self, request, param, run_lf, instantiate_profile, get_configuration, get_markers, lf_tools, lf_reports): - table1= [] - instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], - timeout="10", ssid_data=None, - ap_data=self.lab_info['access_point'], type=0) - - instantiate_profile_obj.enable_all_bands() - - - if run_lf: - return 0 - print("check params") - # gives parameter value of setup_params_general - parameter = dict(param) - print("parameter", parameter) - - test_cases = {} - profile_data= {} - var = "" - list_key = list(parameter.keys()) - - if parameter['mode'] not in ["BRIDGE", "NAT", "VLAN"]: - print("Invalid Mode: ", parameter['mode']) - return test_cases - profile_data["ssid"] = {} - lf_dut_data = [] - for i in parameter["ssid_modes"]: - profile_data["ssid"][i] = [] - for j in range(len(parameter["ssid_modes"][i])): - data = parameter["ssid_modes"][i][j] - profile_data["ssid"][i].append(data) - - # profile data will give ssid data like {'ssid': {'wpa2_personal': [{'ssid_name': 'ssid_wpa2_2g', 'appliedRadios': ['2G'], 'security_key': 'something'}, {'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['5G'], 'security_key': 'something'}], 'wpa3_personal': [{'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['6G'], 'security_key': 'something'}]}} - print("profile data", profile_data) - - - # create wlan - for mode in profile_data['ssid']: - if mode == "wpa2_personal": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("6G"): - lf_dut_data.append(j) - j["appliedRadios"] = list(set(j["appliedRadios"])) - j['security'] = 'wpa2' - # print("dut data", lf_dut_data) - test_cases["wpa_2g"] = True - except Exception as e: - print(e) - test_cases["wpa2_personal"] = False - if mode == "wpa3_personal": - for j in profile_data["ssid"][mode]: - if mode in get_markers.keys() and get_markers[mode]: - print( profile_data["ssid"][mode]) - print(j) - try: - if j["appliedRadios"].__contains__("2G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("5G"): - lf_dut_data.append(j) - if j["appliedRadios"].__contains__("6G"): - lf_dut_data.append(j) - print(lf_dut_data) - j["appliedRadios"] = list(set(j["appliedRadios"])) - j['security'] = 'wpa3' - test_cases["wpa_2g"] = True - except Exception as e: - print(e) - test_cases["wpa3_personal"] = False - - # lf dut data [{'ssid_name': 'ssid_wpa2_2g', 'appliedRadios': ['2G'], 'security_key': 'something', 'security': 'wpa2'}, {'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['5G'], 'security_key': 'something', 'security': 'wpa2'}, {'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['6G'], 'security_key': 'something', 'security': 'wpa3'}] - print("lf dut data", lf_dut_data) - allure.attach(name="wlan data passing", body=str(parameter)) - ap = instantiate_profile_obj.show_ap_summary() - print("show ap summ", ap) - allure.attach(name="show ap summary", body=str(ap)) - - print("create 3 wlans on slot1,2 and 3") - for ap_name in range(len(self.lab_info['access_point'])): - print("ap ", ap_name) - # instantiate controller object - - print("set channel and bandwidth") - instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], - timeout="10", ssid_data=lf_dut_data, - ap_data=self.lab_info['access_point'], type=ap_name) - instantiate_profile_obj.set_channel(band="6g", channel=self.lab_info['access_point'][ap_name]["channel_6g"], - slot=self.lab_info['access_point'][ap_name]["6g_slot"]) - allure.attach(name="set 6g channel on " + str(ap_name + 1) + " ap ", body=str(self.lab_info['access_point'][ap_name]["channel_6g"])) - instantiate_profile_obj.set_channel(band="5g", channel=self.lab_info['access_point'][ap_name]["channel_5g"], - slot=self.lab_info['access_point'][ap_name]["5g_slot"]) - allure.attach(name="set 5g channel on " + str(ap_name + 1) + " ap ", body=str(self.lab_info['access_point'][ap_name]["channel_5g"])) - instantiate_profile_obj.set_channel(band="2g", channel=self.lab_info['access_point'][ap_name]["channel_2g"], - slot=self.lab_info['access_point'][ap_name]["2g_slot"]) - allure.attach(name="set 2g channel on " + str(ap_name + 1) + " ap ", body=str(self.lab_info['access_point'][ap_name]["channel_2g"])) - print(self.lab_info['access_point'][ap_name]["ap_name"]) - check_admin = instantiate_profile_obj.check_admin_state_2ghz(ap_name=self.lab_info['access_point'][ap_name]["ap_name"]) - allure.attach(name="2ghz ap admin state for " + str(ap_name + 1) + " ap", body=str(check_admin)) - - check_admin_5 = instantiate_profile_obj.check_admin_state_5ghz(ap_name=self.lab_info['access_point'][ap_name]["ap_name"]) - allure.attach(name="5ghz ap admin state for " + str(ap_name + 1) + " ap", body=str(check_admin_5)) - - check_admin_6 = instantiate_profile_obj.check_admin_state_6ghz(ap_name=self.lab_info['access_point'][ap_name]["ap_name"]) - allure.attach(name="6ghz ap admin state for " + str(ap_name + 1) + " ap", body=str(check_admin_6)) - - # table1.append(tab) - - - if ap_name == 0: - for band in range(len(lf_dut_data)): - if lf_dut_data[band]["appliedRadios"] == ["2G"]: - instantiate_profile_obj.no_logging_console() - instantiate_profile_obj.line_console() - id_slot = instantiate_profile_obj.get_slot_id_wlan() - ssid_name = instantiate_profile_obj.get_ssid_name_on_id() - if id_slot[0] == "1": - instantiate_profile_obj.show_shutdown_2ghz_ap() - instantiate_profile_obj.disable_wlan(wlan=ssid_name[0]) - instantiate_profile_obj.ap_2ghz_shutdown() - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.delete_wlan(ssid=ssid_name[0]) - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.create_wlan_wpa2(id="1", wlan=lf_dut_data[0]['ssid_name'], - wlanssid=lf_dut_data[0]['ssid_name'], - key=lf_dut_data[0]['security_key']) - else: - print(lf_dut_data[0]['ssid_name']) - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.show_shutdown_2ghz_ap() - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.create_wlan_wpa2(id="1", wlan=lf_dut_data[0]['ssid_name'], - wlanssid=lf_dut_data[0]['ssid_name'], - key=lf_dut_data[0]['security_key']) - instantiate_profile_obj.get_ssids() - - if "roam_type" not in list_key: - # add wlan to single ap - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[0]['ssid_name']) - instantiate_profile_obj.enable_wlan( wlan=lf_dut_data[0]['ssid_name']) - instantiate_profile_obj.enable_2ghz_netwrk(id="1", wlan=lf_dut_data[0]['ssid_name'], - wlanssid=lf_dut_data[0]['ssid_name'], - key=lf_dut_data[0]['security_key']) - instantiate_profile_obj.enable_ap_2ghz() - if parameter["ft+psk"] == True: - instantiate_profile_obj.enable_ft_psk(ssid=lf_dut_data[0]['ssid_name'], - key=lf_dut_data[0]['security_key']) - if parameter["ft-otd"] == True: - instantiate_profile_obj.enable_ftotd_psk(ssid=lf_dut_data[0]['ssid_name'], - key=lf_dut_data[0]['security_key']) - - if 'dtim' in list_key: - instantiate_profile_obj.set_dtim_2ghz(wlan=lf_dut_data[0]['ssid_name'], value=parameter["dtim"]) - instantiate_profile_obj.get_ssids() - - if lf_dut_data[band]["appliedRadios"] == ["5G"]: - instantiate_profile_obj.no_logging_console() - instantiate_profile_obj.line_console() - id_slot = instantiate_profile_obj.get_slot_id_wlan() - print(id_slot) - ssid_name = instantiate_profile_obj.get_ssid_name_on_id() - print(ssid_name) - if id_slot[1] == "2": - # if ssid present on slot 2 delete it and create new - instantiate_profile_obj.show_shutdown_5ghz_ap() - instantiate_profile_obj.disable_wlan(wlan=ssid_name[1]) - instantiate_profile_obj.ap_5ghz_shutdown() - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.delete_wlan(ssid=ssid_name[1]) - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.create_wlan_wpa2(id="2", wlan=lf_dut_data[1]['ssid_name'], - wlanssid=lf_dut_data[1]['ssid_name'], - key=lf_dut_data[1]['security_key']) - else: - print(lf_dut_data[1]['ssid_name']) - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.show_shutdown_5ghz_ap() - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.create_wlan_wpa2(id="2", wlan=lf_dut_data[1]['ssid_name'], - wlanssid=lf_dut_data[1]['ssid_name'], - key=lf_dut_data[1]['security_key']) - instantiate_profile_obj.get_ssids() - - if "roam_type" not in list_key: - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[1]['ssid_name']) - instantiate_profile_obj.enable_wlan(wlan=lf_dut_data[1]['ssid_name']) - instantiate_profile_obj.enable_5ghz_netwrk(id="2", wlan=lf_dut_data[1]['ssid_name'], - wlanssid=lf_dut_data[1]['ssid_name'], - key=lf_dut_data[1]['security_key']) - instantiate_profile_obj.enable_ap_5ghz() - if parameter["ft+psk"] == True: - instantiate_profile_obj.enable_ft_psk(ssid=lf_dut_data[1]['ssid_name'], - key=lf_dut_data[1]['security_key']) - if parameter["ft-otd"] == True: - instantiate_profile_obj.enable_ftotd_psk(ssid=lf_dut_data[1]['ssid_name'], - key=lf_dut_data[1]['security_key']) - if 'dtim' in list_key: - instantiate_profile_obj.set_dtim_5ghz(wlan=lf_dut_data[1]['ssid_name'], value=parameter["dtim"]) - - instantiate_profile_obj.get_ssids() - if lf_dut_data[band]["appliedRadios"] == ["6G"]: - instantiate_profile_obj.no_logging_console() - instantiate_profile_obj.line_console() - id_slot = instantiate_profile_obj.get_slot_id_wlan() - print(id_slot) - ssid_name = instantiate_profile_obj.get_ssid_name_on_id() - print(ssid_name) - if id_slot[2] == "3": - instantiate_profile_obj.show_shutdown_6ghz_ap() - # instantiate_profile_obj.show_shutdown_5ghz_ap() - # instantiate_profile_obj.show_shutdown_2ghz_ap() - instantiate_profile_obj.disable_wlan(wlan=ssid_name[2]) - instantiate_profile_obj.ap_6ghz_shutdown() - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.delete_wlan(ssid=ssid_name[2]) - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.create_wlan_wpa3(id="3", wlan=lf_dut_data[2]['ssid_name'], - wlanssid=lf_dut_data[2]['ssid_name'], - key=lf_dut_data[2]['security_key']) - else: - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.show_shutdown_6ghz_ap() - instantiate_profile_obj.get_ssids() - instantiate_profile_obj.create_wlan_wpa3(id="3", wlan=lf_dut_data[2]['ssid_name'], - wlanssid=lf_dut_data[2]['ssid_name'], - key=lf_dut_data[2]['security_key']) - instantiate_profile_obj.get_ssids() - - if "roam_type" not in list_key: - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( - wlan=lf_dut_data[2]['ssid_name']) - instantiate_profile_obj.enable_wlan( wlan=lf_dut_data[2]['ssid_name']) - instantiate_profile_obj.enable_6ghz_netwrk(id="3", wlan=lf_dut_data[2]['ssid_name'], - wlanssid=lf_dut_data[2]['ssid_name'], - key=lf_dut_data[2]['security_key']) - instantiate_profile_obj.enable_ap_6ghz() - # if parameter["ft+psk"] == True: - # instantiate_profile_obj.enable_ft_sae(ssid=lf_dut_data[2]['ssid_name'], key=lf_dut_data[2]['security_key']) - if parameter["ft-dot1x"] == True: - instantiate_profile_obj.enable_ft_dot1x_wpa3(ssid=lf_dut_data[2]['ssid_name']) - if parameter["ft-dot1x_sha256"] == True: - instantiate_profile_obj.enable_ft_dot1x_sha256_wpa3(ssid=lf_dut_data[2]['ssid_name'], - radius=get_configuration['controller']["radius"]) - instantiate_profile_obj.get_ssids() - - twog_sum = instantiate_profile_obj.show_2ghz_summary() - fiveg_sum = instantiate_profile_obj.show_5ghz_summary() - sixg_sum = instantiate_profile_obj.show_6ghz_summary() - allure.attach(name="ap admin state 2ghz ", body=str(twog_sum)) - allure.attach(name="ap admin state 5ghz ", body=str(fiveg_sum)) - allure.attach(name="ap admin state 6ghz", body=str(sixg_sum)) - sumy = instantiate_profile_obj.get_ssids() - allure.attach(name="wlan summary after creating test wlan", body=str(sumy)) - if "roam_type" in list_key: - print("after creating wlan's assign wlan to respective tag policy") - for ap_name in range(len(self.lab_info['access_point'])): - print("ap ", ap_name) - instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], timeout="10", - ssid_data=lf_dut_data, ap_data=self.lab_info['access_point'], - type=ap_name) - if parameter["roam_type"] == "fiveg_to_fiveg": - # add 5g wlan to both ap's - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[1]['ssid_name']) - if parameter["roam_type"] == "fiveg_to_sixg": - if ap_name == 0: - # add 5g ssid to 5g ap - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[1]['ssid_name']) - if ap_name == 1: - # add 6g ssid to 6g ap - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[2]['ssid_name']) - - else: - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( - wlan=lf_dut_data[0]['ssid_name']) - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( - wlan=lf_dut_data[1]['ssid_name']) - instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( - wlan=lf_dut_data[2]['ssid_name']) - - - - - bssid_list_2g = [] - bssid_list_5g = [] - ssid_data_list = [] - - for ap_name in range(len(self.lab_info['access_point'])): - print("ap ", ap_name) - # instantiate controller object - instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], timeout="10", - ssid_data=lf_dut_data, ap_data=self.lab_info['access_point'], type=ap_name) - bss2_info = instantiate_profile_obj.get_ap_bssid_2g() - allure.attach(name="wlan 2g bssid info", body=str(bss2_info)) - bss5_info = instantiate_profile_obj.get_ap_bssid_5g() - allure.attach(name="wlan 5g bssid info", body=str(bss5_info)) - bss6_info = instantiate_profile_obj.get_ap_bssid_6g() - allure.attach(name="wlan 6g bssid info", body=str(bss6_info)) - - bssid_2g = instantiate_profile_obj.cal_bssid_2g() - print("bssid 2g", bssid_2g) - lst_2g = bssid_list_2g.append(bssid_2g) - - bssid_5g = instantiate_profile_obj.cal_bssid_5g() - print("bssid 5g ", bssid_5g) - lst_5g = bssid_list_5g.append(bssid_5g) - # print(bssid_5g) - # print(bssid_list_2g) - # print(bssid_list_5g) - ssid_data = [] - try: - idx_mapping = {} - bssid = "" - for interface in range(len(lf_dut_data)): - if interface == 0: - bssid = bssid_2g - if interface == 1: - bssid = bssid_5g - if lf_dut_data[interface]['security'] == "psk2": - lf_dut_data[interface]['security'] = "WPA2" - ssid = ["ssid_idx=" + str(interface) + - " ssid=" + lf_dut_data[interface]['ssid_name'] + - " security=" + lf_dut_data[interface]['security'] + - " password=" + lf_dut_data[interface]['security_key'] + - " bssid=" + bssid - ] - ssid_data.append(ssid) - - except Exception as e: - print(e) - pass - # print("nikita",ssid_data) - ssid_data_list.append(ssid_data) - print("final ssid data", ssid_data_list) - # ssid_data = [[['ssid_idx=0 ssid=ssid_wpa2_2g security=WPA2 password=something bssid=68:7d:b4:5f:5c:30'], - # ['ssid_idx=1 ssid=ssid_wpa2_5g security=WPA2 password=something bssid=68:7d:b4:5f:5c:3e']], - # [['ssid_idx=0 ssid=ssid_wpa2_2g security=WPA2 password=something bssid=14:16:9d:53:58:c0'], - # ['ssid_idx=1 ssid=ssid_wpa2_5g security=WPA2 password=something bssid=14:16:9d:53:58:ce']]] - lf_tools.create_non_meh_dut(ssid_data=ssid_data_list) - table1 = [["show ap summary", "done"], ["Configure wlan", "done"], ["configure channel/width", "done"], - ["ap admin state up", "done"], ["checking admin state of ap", "done"], - ["sniffer capture", "done"], - ["client connect", "don"], ["roam", "done"], ["sniffer verification", "done"], - ["iteration", "done"], - ["table display", "done"], ["check in controller client connected", "done"], - ["Bring down unused band before start of testcase", "done"]] - tab1 = lf_reports.table2(table=table1) - allure.attach(name="skeleton of code", body=str(tab1)) - - - - - - - - - +# import allure +# import pytest +# import os +# import sys +# """ Environment Paths """ +# if "libs" not in sys.path: +# sys.path.append(f'../libs') +# for folder in 'py-json', 'py-scripts': +# if folder not in sys.path: +# sys.path.append(f'../lanforge/lanforge-scripts/{folder}') +# +# sys.path.append( +# os.path.dirname( +# os.path.realpath(__file__) +# ) +# ) +# sys.path.append(f"../lanforge/lanforge-scripts/py-scripts/tip-cicd-sanity") +# +# sys.path.append(f'../libs') +# sys.path.append(f'../libs/lanforge/') +# sys.path.append(f'../lanforge/lanforge-scripts') +# +# from LANforge.LFUtils import * +# +# if 'py-json' not in sys.path: +# sys.path.append('../py-scripts') +# from controller.controller_3x.controller import CController +# +# +# class Fixtures_3x: +# +# def __init__(self, configuration={}, run_lf=False, cc_1=False): +# self.lab_info = configuration +# self.run_lf = run_lf +# self.cc_1 = cc_1 +# # print(self.lab_info) +# print("cc.1") +# self.controller_obj = "" +# +# +# def setup_profiles(self, request, param, run_lf, instantiate_profile, get_configuration, get_markers, lf_tools, lf_reports): +# table1= [] +# instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], +# timeout="10", ssid_data=None, +# ap_data=self.lab_info['access_point'], type=0) +# +# instantiate_profile_obj.enable_all_bands() +# +# +# if run_lf: +# return 0 +# print("check params") +# # gives parameter value of setup_params_general +# parameter = dict(param) +# print("parameter", parameter) +# +# test_cases = {} +# profile_data= {} +# var = "" +# list_key = list(parameter.keys()) +# +# if parameter['mode'] not in ["BRIDGE", "NAT", "VLAN"]: +# print("Invalid Mode: ", parameter['mode']) +# return test_cases +# profile_data["ssid"] = {} +# lf_dut_data = [] +# for i in parameter["ssid_modes"]: +# profile_data["ssid"][i] = [] +# for j in range(len(parameter["ssid_modes"][i])): +# data = parameter["ssid_modes"][i][j] +# profile_data["ssid"][i].append(data) +# +# # profile data will give ssid data like {'ssid': {'wpa2_personal': [{'ssid_name': 'ssid_wpa2_2g', 'appliedRadios': ['2G'], 'security_key': 'something'}, {'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['5G'], 'security_key': 'something'}], 'wpa3_personal': [{'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['6G'], 'security_key': 'something'}]}} +# print("profile data", profile_data) +# +# +# # create wlan +# for mode in profile_data['ssid']: +# if mode == "wpa2_personal": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("6G"): +# lf_dut_data.append(j) +# j["appliedRadios"] = list(set(j["appliedRadios"])) +# j['security'] = 'wpa2' +# # print("dut data", lf_dut_data) +# test_cases["wpa_2g"] = True +# except Exception as e: +# print(e) +# test_cases["wpa2_personal"] = False +# if mode == "wpa3_personal": +# for j in profile_data["ssid"][mode]: +# if mode in get_markers.keys() and get_markers[mode]: +# print( profile_data["ssid"][mode]) +# print(j) +# try: +# if j["appliedRadios"].__contains__("2G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("5G"): +# lf_dut_data.append(j) +# if j["appliedRadios"].__contains__("6G"): +# lf_dut_data.append(j) +# print(lf_dut_data) +# j["appliedRadios"] = list(set(j["appliedRadios"])) +# j['security'] = 'wpa3' +# test_cases["wpa_2g"] = True +# except Exception as e: +# print(e) +# test_cases["wpa3_personal"] = False +# +# # lf dut data [{'ssid_name': 'ssid_wpa2_2g', 'appliedRadios': ['2G'], 'security_key': 'something', 'security': 'wpa2'}, {'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['5G'], 'security_key': 'something', 'security': 'wpa2'}, {'ssid_name': 'ssid_wpa2_5g', 'appliedRadios': ['6G'], 'security_key': 'something', 'security': 'wpa3'}] +# print("lf dut data", lf_dut_data) +# allure.attach(name="wlan data passing", body=str(parameter)) +# ap = instantiate_profile_obj.show_ap_summary() +# print("show ap summ", ap) +# allure.attach(name="show ap summary", body=str(ap)) +# +# print("create 3 wlans on slot1,2 and 3") +# for ap_name in range(len(self.lab_info['access_point'])): +# print("ap ", ap_name) +# # instantiate controller object +# +# print("set channel and bandwidth") +# instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], +# timeout="10", ssid_data=lf_dut_data, +# ap_data=self.lab_info['access_point'], type=ap_name) +# instantiate_profile_obj.set_channel(band="6g", channel=self.lab_info['access_point'][ap_name]["channel_6g"], +# slot=self.lab_info['access_point'][ap_name]["6g_slot"]) +# allure.attach(name="set 6g channel on " + str(ap_name + 1) + " ap ", body=str(self.lab_info['access_point'][ap_name]["channel_6g"])) +# instantiate_profile_obj.set_channel(band="5g", channel=self.lab_info['access_point'][ap_name]["channel_5g"], +# slot=self.lab_info['access_point'][ap_name]["5g_slot"]) +# allure.attach(name="set 5g channel on " + str(ap_name + 1) + " ap ", body=str(self.lab_info['access_point'][ap_name]["channel_5g"])) +# instantiate_profile_obj.set_channel(band="2g", channel=self.lab_info['access_point'][ap_name]["channel_2g"], +# slot=self.lab_info['access_point'][ap_name]["2g_slot"]) +# allure.attach(name="set 2g channel on " + str(ap_name + 1) + " ap ", body=str(self.lab_info['access_point'][ap_name]["channel_2g"])) +# print(self.lab_info['access_point'][ap_name]["ap_name"]) +# check_admin = instantiate_profile_obj.check_admin_state_2ghz(ap_name=self.lab_info['access_point'][ap_name]["ap_name"]) +# allure.attach(name="2ghz ap admin state for " + str(ap_name + 1) + " ap", body=str(check_admin)) +# +# check_admin_5 = instantiate_profile_obj.check_admin_state_5ghz(ap_name=self.lab_info['access_point'][ap_name]["ap_name"]) +# allure.attach(name="5ghz ap admin state for " + str(ap_name + 1) + " ap", body=str(check_admin_5)) +# +# check_admin_6 = instantiate_profile_obj.check_admin_state_6ghz(ap_name=self.lab_info['access_point'][ap_name]["ap_name"]) +# allure.attach(name="6ghz ap admin state for " + str(ap_name + 1) + " ap", body=str(check_admin_6)) +# +# # table1.append(tab) +# +# +# if ap_name == 0: +# for band in range(len(lf_dut_data)): +# if lf_dut_data[band]["appliedRadios"] == ["2G"]: +# instantiate_profile_obj.no_logging_console() +# instantiate_profile_obj.line_console() +# id_slot = instantiate_profile_obj.get_slot_id_wlan() +# ssid_name = instantiate_profile_obj.get_ssid_name_on_id() +# if id_slot[0] == "1": +# instantiate_profile_obj.show_shutdown_2ghz_ap() +# instantiate_profile_obj.disable_wlan(wlan=ssid_name[0]) +# instantiate_profile_obj.ap_2ghz_shutdown() +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.delete_wlan(ssid=ssid_name[0]) +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.create_wlan_wpa2(id="1", wlan=lf_dut_data[0]['ssid_name'], +# wlanssid=lf_dut_data[0]['ssid_name'], +# key=lf_dut_data[0]['security_key']) +# else: +# print(lf_dut_data[0]['ssid_name']) +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.show_shutdown_2ghz_ap() +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.create_wlan_wpa2(id="1", wlan=lf_dut_data[0]['ssid_name'], +# wlanssid=lf_dut_data[0]['ssid_name'], +# key=lf_dut_data[0]['security_key']) +# instantiate_profile_obj.get_ssids() +# +# if "roam_type" not in list_key: +# # add wlan to single ap +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[0]['ssid_name']) +# instantiate_profile_obj.enable_wlan( wlan=lf_dut_data[0]['ssid_name']) +# instantiate_profile_obj.enable_2ghz_netwrk(id="1", wlan=lf_dut_data[0]['ssid_name'], +# wlanssid=lf_dut_data[0]['ssid_name'], +# key=lf_dut_data[0]['security_key']) +# instantiate_profile_obj.enable_ap_2ghz() +# if parameter["ft+psk"] == True: +# instantiate_profile_obj.enable_ft_psk(ssid=lf_dut_data[0]['ssid_name'], +# key=lf_dut_data[0]['security_key']) +# if parameter["ft-otd"] == True: +# instantiate_profile_obj.enable_ftotd_psk(ssid=lf_dut_data[0]['ssid_name'], +# key=lf_dut_data[0]['security_key']) +# +# if 'dtim' in list_key: +# instantiate_profile_obj.set_dtim_2ghz(wlan=lf_dut_data[0]['ssid_name'], value=parameter["dtim"]) +# instantiate_profile_obj.get_ssids() +# +# if lf_dut_data[band]["appliedRadios"] == ["5G"]: +# instantiate_profile_obj.no_logging_console() +# instantiate_profile_obj.line_console() +# id_slot = instantiate_profile_obj.get_slot_id_wlan() +# print(id_slot) +# ssid_name = instantiate_profile_obj.get_ssid_name_on_id() +# print(ssid_name) +# if id_slot[1] == "2": +# # if ssid present on slot 2 delete it and create new +# instantiate_profile_obj.show_shutdown_5ghz_ap() +# instantiate_profile_obj.disable_wlan(wlan=ssid_name[1]) +# instantiate_profile_obj.ap_5ghz_shutdown() +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.delete_wlan(ssid=ssid_name[1]) +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.create_wlan_wpa2(id="2", wlan=lf_dut_data[1]['ssid_name'], +# wlanssid=lf_dut_data[1]['ssid_name'], +# key=lf_dut_data[1]['security_key']) +# else: +# print(lf_dut_data[1]['ssid_name']) +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.show_shutdown_5ghz_ap() +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.create_wlan_wpa2(id="2", wlan=lf_dut_data[1]['ssid_name'], +# wlanssid=lf_dut_data[1]['ssid_name'], +# key=lf_dut_data[1]['security_key']) +# instantiate_profile_obj.get_ssids() +# +# if "roam_type" not in list_key: +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[1]['ssid_name']) +# instantiate_profile_obj.enable_wlan(wlan=lf_dut_data[1]['ssid_name']) +# instantiate_profile_obj.enable_5ghz_netwrk(id="2", wlan=lf_dut_data[1]['ssid_name'], +# wlanssid=lf_dut_data[1]['ssid_name'], +# key=lf_dut_data[1]['security_key']) +# instantiate_profile_obj.enable_ap_5ghz() +# if parameter["ft+psk"] == True: +# instantiate_profile_obj.enable_ft_psk(ssid=lf_dut_data[1]['ssid_name'], +# key=lf_dut_data[1]['security_key']) +# if parameter["ft-otd"] == True: +# instantiate_profile_obj.enable_ftotd_psk(ssid=lf_dut_data[1]['ssid_name'], +# key=lf_dut_data[1]['security_key']) +# if 'dtim' in list_key: +# instantiate_profile_obj.set_dtim_5ghz(wlan=lf_dut_data[1]['ssid_name'], value=parameter["dtim"]) +# +# instantiate_profile_obj.get_ssids() +# if lf_dut_data[band]["appliedRadios"] == ["6G"]: +# instantiate_profile_obj.no_logging_console() +# instantiate_profile_obj.line_console() +# id_slot = instantiate_profile_obj.get_slot_id_wlan() +# print(id_slot) +# ssid_name = instantiate_profile_obj.get_ssid_name_on_id() +# print(ssid_name) +# if id_slot[2] == "3": +# instantiate_profile_obj.show_shutdown_6ghz_ap() +# # instantiate_profile_obj.show_shutdown_5ghz_ap() +# # instantiate_profile_obj.show_shutdown_2ghz_ap() +# instantiate_profile_obj.disable_wlan(wlan=ssid_name[2]) +# instantiate_profile_obj.ap_6ghz_shutdown() +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.delete_wlan(ssid=ssid_name[2]) +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.create_wlan_wpa3(id="3", wlan=lf_dut_data[2]['ssid_name'], +# wlanssid=lf_dut_data[2]['ssid_name'], +# key=lf_dut_data[2]['security_key']) +# else: +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.show_shutdown_6ghz_ap() +# instantiate_profile_obj.get_ssids() +# instantiate_profile_obj.create_wlan_wpa3(id="3", wlan=lf_dut_data[2]['ssid_name'], +# wlanssid=lf_dut_data[2]['ssid_name'], +# key=lf_dut_data[2]['security_key']) +# instantiate_profile_obj.get_ssids() +# +# if "roam_type" not in list_key: +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( +# wlan=lf_dut_data[2]['ssid_name']) +# instantiate_profile_obj.enable_wlan( wlan=lf_dut_data[2]['ssid_name']) +# instantiate_profile_obj.enable_6ghz_netwrk(id="3", wlan=lf_dut_data[2]['ssid_name'], +# wlanssid=lf_dut_data[2]['ssid_name'], +# key=lf_dut_data[2]['security_key']) +# instantiate_profile_obj.enable_ap_6ghz() +# # if parameter["ft+psk"] == True: +# # instantiate_profile_obj.enable_ft_sae(ssid=lf_dut_data[2]['ssid_name'], key=lf_dut_data[2]['security_key']) +# if parameter["ft-dot1x"] == True: +# instantiate_profile_obj.enable_ft_dot1x_wpa3(ssid=lf_dut_data[2]['ssid_name']) +# if parameter["ft-dot1x_sha256"] == True: +# instantiate_profile_obj.enable_ft_dot1x_sha256_wpa3(ssid=lf_dut_data[2]['ssid_name'], +# radius=get_configuration['controller']["radius"]) +# instantiate_profile_obj.get_ssids() +# +# twog_sum = instantiate_profile_obj.show_2ghz_summary() +# fiveg_sum = instantiate_profile_obj.show_5ghz_summary() +# sixg_sum = instantiate_profile_obj.show_6ghz_summary() +# allure.attach(name="ap admin state 2ghz ", body=str(twog_sum)) +# allure.attach(name="ap admin state 5ghz ", body=str(fiveg_sum)) +# allure.attach(name="ap admin state 6ghz", body=str(sixg_sum)) +# sumy = instantiate_profile_obj.get_ssids() +# allure.attach(name="wlan summary after creating test wlan", body=str(sumy)) +# if "roam_type" in list_key: +# print("after creating wlan's assign wlan to respective tag policy") +# for ap_name in range(len(self.lab_info['access_point'])): +# print("ap ", ap_name) +# instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], timeout="10", +# ssid_data=lf_dut_data, ap_data=self.lab_info['access_point'], +# type=ap_name) +# if parameter["roam_type"] == "fiveg_to_fiveg": +# # add 5g wlan to both ap's +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[1]['ssid_name']) +# if parameter["roam_type"] == "fiveg_to_sixg": +# if ap_name == 0: +# # add 5g ssid to 5g ap +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[1]['ssid_name']) +# if ap_name == 1: +# # add 6g ssid to 6g ap +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile(wlan=lf_dut_data[2]['ssid_name']) +# +# else: +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( +# wlan=lf_dut_data[0]['ssid_name']) +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( +# wlan=lf_dut_data[1]['ssid_name']) +# instantiate_profile_obj.config_wireless_tag_policy_and_policy_profile( +# wlan=lf_dut_data[2]['ssid_name']) +# +# +# +# +# bssid_list_2g = [] +# bssid_list_5g = [] +# ssid_data_list = [] +# +# for ap_name in range(len(self.lab_info['access_point'])): +# print("ap ", ap_name) +# # instantiate controller object +# instantiate_profile_obj = instantiate_profile(controller_data=get_configuration['controller'], timeout="10", +# ssid_data=lf_dut_data, ap_data=self.lab_info['access_point'], type=ap_name) +# bss2_info = instantiate_profile_obj.get_ap_bssid_2g() +# allure.attach(name="wlan 2g bssid info", body=str(bss2_info)) +# bss5_info = instantiate_profile_obj.get_ap_bssid_5g() +# allure.attach(name="wlan 5g bssid info", body=str(bss5_info)) +# bss6_info = instantiate_profile_obj.get_ap_bssid_6g() +# allure.attach(name="wlan 6g bssid info", body=str(bss6_info)) +# +# bssid_2g = instantiate_profile_obj.cal_bssid_2g() +# print("bssid 2g", bssid_2g) +# lst_2g = bssid_list_2g.append(bssid_2g) +# +# bssid_5g = instantiate_profile_obj.cal_bssid_5g() +# print("bssid 5g ", bssid_5g) +# lst_5g = bssid_list_5g.append(bssid_5g) +# # print(bssid_5g) +# # print(bssid_list_2g) +# # print(bssid_list_5g) +# ssid_data = [] +# try: +# idx_mapping = {} +# bssid = "" +# for interface in range(len(lf_dut_data)): +# if interface == 0: +# bssid = bssid_2g +# if interface == 1: +# bssid = bssid_5g +# if lf_dut_data[interface]['security'] == "psk2": +# lf_dut_data[interface]['security'] = "WPA2" +# ssid = ["ssid_idx=" + str(interface) + +# " ssid=" + lf_dut_data[interface]['ssid_name'] + +# " security=" + lf_dut_data[interface]['security'] + +# " password=" + lf_dut_data[interface]['security_key'] + +# " bssid=" + bssid +# ] +# ssid_data.append(ssid) +# +# except Exception as e: +# print(e) +# pass +# # print("nikita",ssid_data) +# ssid_data_list.append(ssid_data) +# print("final ssid data", ssid_data_list) +# # ssid_data = [[['ssid_idx=0 ssid=ssid_wpa2_2g security=WPA2 password=something bssid=68:7d:b4:5f:5c:30'], +# # ['ssid_idx=1 ssid=ssid_wpa2_5g security=WPA2 password=something bssid=68:7d:b4:5f:5c:3e']], +# # [['ssid_idx=0 ssid=ssid_wpa2_2g security=WPA2 password=something bssid=14:16:9d:53:58:c0'], +# # ['ssid_idx=1 ssid=ssid_wpa2_5g security=WPA2 password=something bssid=14:16:9d:53:58:ce']]] +# lf_tools.create_non_meh_dut(ssid_data=ssid_data_list) +# table1 = [["show ap summary", "done"], ["Configure wlan", "done"], ["configure channel/width", "done"], +# ["ap admin state up", "done"], ["checking admin state of ap", "done"], +# ["sniffer capture", "done"], +# ["client connect", "don"], ["roam", "done"], ["sniffer verification", "done"], +# ["iteration", "done"], +# ["table display", "done"], ["check in controller client connected", "done"], +# ["Bring down unused band before start of testcase", "done"]] +# tab1 = lf_reports.table2(table=table1) +# allure.attach(name="skeleton of code", body=str(tab1)) +# +# +# +# +# +# +# +# +# diff --git a/tests/imports.py b/tests/imports.py new file mode 100644 index 000000000..55b634640 --- /dev/null +++ b/tests/imports.py @@ -0,0 +1,41 @@ +""" + Registered Target Imports + +""" +import sys +import importlib +sys.path.append('/usr/local/bin') +######################################################################################################################## +""" + Target Name:tip_2x + Target Module:tip-2x-0.1 + Author Name:Shivam Thakur + Organization:Telecom Infra Project + Register ID:1 + Email:shivam.thakur@candelatech.com + description:TIP OpenWIFI 2.X Library +""" +try: + target = importlib.import_module("tip_2x") + target = target.tip_2x +except ImportError as e: + print(e) + sys.exit("Python Import Error: " + str(e)) +######################################################################################################################## +# ###################################################################################################################### +# """ +# Target Name: +# Target Module: +# Author Name: +# Organization: +# Register ID:2 +# Email:shivam.thakur@candelatech.com +# description: +# """ +# try: +# target = importlib.import_module("tip_2x") +# target = target.tip_2x +# except ImportError as e: +# print(e) +# sys.exit("Python Import Error: " + str(e)) +# ###################################################################################################################### diff --git a/tests/lab_info.json b/tests/lab_info.json index 006626fc4..354e01adf 100644 --- a/tests/lab_info.json +++ b/tests/lab_info.json @@ -2,12 +2,13 @@ "CONFIGURATION" : { "basic-01": { + "target": "tip_2x", "controller": { "url": "https://sec-qa01.cicd.lab.wlan.tip.build:16001", "username": "tip@ucentral.com", "password": "OpenWifi%123" }, - "access_point": [ + "device_under_tests": [ { "model": "wallys_dr40x9", "mode": "wifi5", diff --git a/tests/pytest.ini b/tests/pytest.ini index 3fe5d4606..801d71574 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -32,6 +32,6 @@ milestone=29 filterwarnings=ignore::UserWarning -markers=sanity: Run the sanity for Client Connectivity test +markers=ow_sanity_lf: Run the sanity for Client Connectivity test diff --git a/tests/scan_ssid.csv b/tests/scan_ssid.csv new file mode 100644 index 000000000..7a8cbc781 --- /dev/null +++ b/tests/scan_ssid.csv @@ -0,0 +1,6 @@ +,age,auth,beacon,bss,channel,entity id,frequency,info,signal,ssid +0,37900464,WPA2,100,00:06:ae:6f:6f:e6,1,1.1.4,2412,2x2 MCS 0-11 AX,-41.0,ssid_wpa2_dual_band +1,4918,Open,100,90:3c:b3:9d:69:1b,1,1.1.4,2412,2x2 MCS 0-11 AX,-39.0,ssid_open_2g_vlan +2,21029543,WPA,100,92:3c:b3:9d:69:1b,1,1.1.4,2412,2x2 MCS 0-11 AX,-38.0,ssid_wpa_2g +3,21029518,WPA2,100,96:3c:b3:9d:69:1b,1,1.1.4,2412,2x2 MCS 0-11 AX,-39.0,ssid_wpa2_2g +4,21029083,WPA WPA2,100,9a:3c:b3:9d:69:1b,1,1.1.4,2412,2x2 MCS 0-11 AX,-39.0,ssid_wpa_wpa2_p_m_2g diff --git a/tests/test_connectivity.py b/tests/test_connectivity.py index 2cdf5803a..d7b694d8b 100644 --- a/tests/test_connectivity.py +++ b/tests/test_connectivity.py @@ -324,3 +324,8 @@ class TestFMS(object): allure.attach(name=str(data['firmware']) + str(current_version_ap), body="") status.append(current_version_ap == data['firmware'].split()) assert False not in status + + +@pytest.mark.shivam +def test_abc(get_target_object): + assert True \ No newline at end of file