Wifi 15117 (#1072)

* Modify ASB Test Cases for Cybertan AP Models

Signed-off-by: bhargavi-ct <bhargavimamidipaka@candelatech.com>

* Update script to handle output after remove restrictions

Signed-off-by: bhargavi-ct <bhargavimamidipaka@candelatech.com>

---------

Signed-off-by: bhargavi-ct <bhargavimamidipaka@candelatech.com>
Co-authored-by: bhargavi-ct <bhargavimamidipaka@candelatech.com>
This commit is contained in:
bhargavi-ct
2025-10-01 13:15:34 +05:30
committed by GitHub
parent 4ebf5c0d83
commit 5f4652d76b
3 changed files with 177 additions and 25 deletions

View File

@@ -617,13 +617,85 @@ class APLIBS:
# Please wait 1min after doing factory reset # Please wait 1min after doing factory reset
return output return output
def remove_restrictions(self): def remove_restrictions(self, ap_model):
self.run_generic_command(cmd="rm /certificates/restrictions.json", if "sonicfi_rap" in ap_model:
idx=0, print_log=True, logging.info(f"Yes it is cybertan AP:")
attach_allure=False) output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 0",
self.run_generic_command(cmd="rm /etc/ucentral/restrictions.json", idx=0, print_log=True,
idx=0, print_log=True, attach_allure=False)
attach_allure=False) logging.info(f"output of fw_setenv cert_part 0: {output}")
output = self.run_generic_command(cmd="rm -f /certificates/restrictions.json",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of removing restrictions: {output}")
output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of fw_setenv store_certs_disabled 0: {output}")
output = self.run_generic_command(cmd="cd /certificates && store_certs",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of store_certs: {output}")
output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 1",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of fw_setenv cert_part 0: {output}")
output = self.run_generic_command(cmd="rm -f /certificates/restrictions.json",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of removing restrictions: {output}")
output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of fw_setenv store_certs_disabled 0: {output}")
output = self.run_generic_command(cmd="cd /certificates && store_certs",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of store_certs: {output}")
# Verify the restriction file is removed from both partitions
output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 0",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of fw_setenv cert_part 0: {output}")
output = self.run_generic_command(
cmd='[ -f /certificates/restrictions.json ] && echo "True" || echo "False"',
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
logging.info(f"Check for restrictions file in partition 0: {output}")
result = output.strip().splitlines()[-1]
if result == "True":
logging.info("Unable to remove restrictions file from partition 0")
#pytest.fail("Unable to remove restrictions file from partition 0")
output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 1",
idx=0, print_log=True,
attach_allure=False)
logging.info(f"output of fw_setenv cert_part 0: {output}")
output = self.run_generic_command(
cmd='[ -f /certificates/restrictions.json ] && echo "True" || echo "False"',
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
logging.info(f"Check for restrictions file in partition 1: {output}")
result = output.strip().splitlines()[-1]
if result == "True" :
logging.info("Unable to remove restrictions file from partition 1")
#pytest.fail("Unable to remove restrictions file from partition 1")
else:
self.run_generic_command(cmd="rm /certificates/restrictions.json",
idx=0, print_log=True,
attach_allure=False)
self.run_generic_command(cmd="rm /etc/ucentral/restrictions.json",
idx=0, print_log=True,
attach_allure=False)
self.factory_reset(print_log=False) self.factory_reset(print_log=False)
time.sleep(120) time.sleep(120)
output = self.run_generic_command(cmd='[ -f /etc/ucentral/restrictions.json ] && echo "True" || echo "False"', output = self.run_generic_command(cmd='[ -f /etc/ucentral/restrictions.json ] && echo "True" || echo "False"',
@@ -633,20 +705,92 @@ class APLIBS:
expected_attachment_type=allure.attachment_type.TEXT) expected_attachment_type=allure.attachment_type.TEXT)
return output return output
def add_restrictions(self, restrictions_file, developer_mode): def add_restrictions(self, restrictions_file, developer_mode, ap_model):
self.factory_reset(print_log=False) self.factory_reset(print_log=False)
time.sleep(200) time.sleep(200)
output = self.run_generic_command(cmd=developer_mode,
idx=0, if "sonicfi_rap" in ap_model:
print_log=True, logging.info(f"Yes it is cybertan AP:")
attach_allure=False, restrictions_file = 'echo \"{\\"country\\":[\\"US\\", \\"CA\\"],\\"dfs\\": true,\\"rtty\\": true,\\"tty\\": ' \
expected_attachment_type=allure.attachment_type.TEXT) 'true,\\"developer\\": true,\\"sysupgrade\\": true,\\"commands\\": true,\\"key_info\\": {' \
output = self.run_generic_command(cmd=restrictions_file, '\\"vendor\\": \\"dummy\\",\\"algo\\": \\"static\\"}}\" > /certificates/restrictions.json ' \
idx=0, '&& echo "Partition 0 done"'
print_log=True, restrictions_file1 = 'echo \"{\\"country\\":[\\"US\\", \\"CA\\"],\\"dfs\\": true,\\"rtty\\": true,\\"tty\\": ' \
attach_allure=False, 'true,\\"developer\\": true,\\"sysupgrade\\": true,\\"commands\\": true,\\"key_info\\": {' \
expected_attachment_type=allure.attachment_type.TEXT, '\\"vendor\\": \\"dummy\\",\\"algo\\": \\"static\\"}}\" > /certificates/restrictions.json ' \
restrictions=True) '&& echo "Partition 1 done"'
output = self.run_generic_command(cmd=developer_mode,
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
logging.info(f"output of developer_mode::{output}")
output = self.run_generic_command(cmd="fw_setenv cert_part 0",
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
logging.info(f"output of fw_setenv cert_part 0::{output}")
output = self.run_generic_command(cmd=restrictions_file,
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT,
restrictions=True)
logging.info(f"output of adding restrictions_file::{output}")
output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
logging.info(f"output of fw_setenv store_certs_disabled 0::{output}")
cmd_output = self.run_generic_command(cmd="cd /certificates && store_certs",
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT,
restrictions=True)
logging.info(f"output of store_certs::{cmd_output}")
output = self.run_generic_command(cmd="fw_setenv cert_part 1",
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
logging.info(f"output of fw_setenv cert_part 1::{output}")
output = self.run_generic_command(cmd=restrictions_file1,
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT,
restrictions=True)
logging.info(f"output of adding restrictions_file1::{output}")
cmd_output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
logging.info(f"output of fw_setenv store_certs_disabled 0::{cmd_output}")
cmd_output = self.run_generic_command(cmd="cd /certificates && store_certs",
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT,
restrictions=True)
logging.info(f"output of store_certs::{cmd_output}")
else:
output = self.run_generic_command(cmd=developer_mode,
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
output = self.run_generic_command(cmd=restrictions_file,
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT,
restrictions=True)
self.factory_reset(print_log=False) self.factory_reset(print_log=False)
time.sleep(300) time.sleep(300)
return output return output

View File

@@ -1041,6 +1041,7 @@ class TestUcentralGatewayService(object):
@pytest.mark.asb_tests @pytest.mark.asb_tests
def test_asb_on_non_restricted_ap(self, get_target_object, get_testbed_details): def test_asb_on_non_restricted_ap(self, get_target_object, get_testbed_details):
device_name = get_testbed_details['device_under_tests'][0]['identifier'] device_name = get_testbed_details['device_under_tests'][0]['identifier']
ap_model = get_testbed_details['device_under_tests'][0]['model']
payload = { payload = {
"serialNumber": device_name, "serialNumber": device_name,
"timeout": 30, "timeout": 30,
@@ -1060,7 +1061,7 @@ class TestUcentralGatewayService(object):
assert resp.status_code == 200 assert resp.status_code == 200
else: else:
logging.info("AP is restricted, Removing Restrictions") logging.info("AP is restricted, Removing Restrictions")
output = get_target_object.get_dut_library_object().remove_restrictions() output = get_target_object.get_dut_library_object().remove_restrictions(ap_model=ap_model)
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name) resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
if not resp: if not resp:
logging.info("Removed Restrictions") logging.info("Removed Restrictions")
@@ -1078,6 +1079,7 @@ class TestUcentralGatewayService(object):
@pytest.mark.asb_tests @pytest.mark.asb_tests
def test_asb_on_restricted_ap(self, get_target_object, get_testbed_details): def test_asb_on_restricted_ap(self, get_target_object, get_testbed_details):
device_name = get_testbed_details['device_under_tests'][0]['identifier'] device_name = get_testbed_details['device_under_tests'][0]['identifier']
ap_model = get_testbed_details['device_under_tests'][0]['model']
payload = { payload = {
"serialNumber": device_name, "serialNumber": device_name,
"timeout": 30, "timeout": 30,
@@ -1094,18 +1096,23 @@ class TestUcentralGatewayService(object):
'\\"vendor\\": \\"dummy\\",\\"algo\\": \\"static\\"}}\" > /certificates/restrictions.json ' \ '\\"vendor\\": \\"dummy\\",\\"algo\\": \\"static\\"}}\" > /certificates/restrictions.json ' \
'&& echo \"True\"' '&& echo \"True\"'
developer_mode = "fw_setenv developer 0" developer_mode = "fw_setenv developer 0"
output = get_target_object.get_dut_library_object().add_restrictions(restrictions_file=restrictions_file, output = get_target_object.get_dut_library_object().add_restrictions(restrictions_file=restrictions_file,
developer_mode=developer_mode) developer_mode=developer_mode, ap_model=ap_model)
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name) logging.info(f"output of adding restrictions:{output}")
resp = get_target_object.controller_library_object.check_restrictions(device_name)
logging.info(f"response of check_restrictions:{resp} ")
if resp: if resp:
logging.info("From GW it's confirmed that AP is restricted now") logging.info("From GW it's confirmed that AP is restricted now")
uuid = get_target_object.controller_library_object.asb_script(device_name, payload) uuid = get_target_object.controller_library_object.asb_script(device_name, payload)
resp = get_target_object.controller_library_object.get_file(device_name, uuid) resp = get_target_object.controller_library_object.get_file(device_name, uuid)
assert resp.status_code == 200 assert resp.status_code == 200
else: else:
logging.info("Unable to add restrictions to the AP")
assert False assert False
output = get_target_object.get_dut_library_object().remove_restrictions() output = get_target_object.get_dut_library_object().remove_restrictions(ap_model=ap_model)
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name) resp = get_target_object.controller_library_object.check_restrictions(device_name)
if resp: if resp:
logging.info("Unable to remove restrictions in the AP") logging.info("Unable to remove restrictions in the AP")
assert False assert False

View File

@@ -275,13 +275,14 @@ class TestResources(object):
@allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-12318", name="12318") @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-12318", name="12318")
def test_check_restrictions(self, get_target_object, get_testbed_details): def test_check_restrictions(self, get_target_object, get_testbed_details):
device_name = get_testbed_details['device_under_tests'][0]['identifier'] device_name = get_testbed_details['device_under_tests'][0]['identifier']
ap_model = get_testbed_details['device_under_tests'][0]['model']
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name) resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
if not resp: if not resp:
logging.info("AP is not restricted") logging.info("AP is not restricted")
assert True, "AP is not in restricted mode we can continue testing" assert True, "AP is not in restricted mode we can continue testing"
else: else:
logging.info("AP is restricted, Removing Restrictions") logging.info("AP is restricted, Removing Restrictions")
output = get_target_object.get_dut_library_object().remove_restrictions() output = get_target_object.get_dut_library_object().remove_restrictions(ap_model=ap_model)
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name) resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
if not resp: if not resp:
logging.info("Removed Restrictions") logging.info("Removed Restrictions")