Skip to content

Commit 5f4652d

Browse files
bhargavi-ctbhargavi-ct
andauthored
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>
1 parent 4ebf5c0 commit 5f4652d

3 files changed

Lines changed: 177 additions & 25 deletions

File tree

libs/tip_2x/ap_lib.py

Lines changed: 163 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -617,13 +617,85 @@ def factory_reset(self, idx=0, print_log=True, attach_allure=False):
617617
# Please wait 1min after doing factory reset
618618
return output
619619

620-
def remove_restrictions(self):
621-
self.run_generic_command(cmd="rm /certificates/restrictions.json",
622-
idx=0, print_log=True,
623-
attach_allure=False)
624-
self.run_generic_command(cmd="rm /etc/ucentral/restrictions.json",
625-
idx=0, print_log=True,
626-
attach_allure=False)
620+
def remove_restrictions(self, ap_model):
621+
if "sonicfi_rap" in ap_model:
622+
logging.info(f"Yes it is cybertan AP:")
623+
output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 0",
624+
idx=0, print_log=True,
625+
attach_allure=False)
626+
logging.info(f"output of fw_setenv cert_part 0: {output}")
627+
output = self.run_generic_command(cmd="rm -f /certificates/restrictions.json",
628+
idx=0, print_log=True,
629+
attach_allure=False)
630+
logging.info(f"output of removing restrictions: {output}")
631+
output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
632+
idx=0, print_log=True,
633+
attach_allure=False)
634+
logging.info(f"output of fw_setenv store_certs_disabled 0: {output}")
635+
output = self.run_generic_command(cmd="cd /certificates && store_certs",
636+
idx=0, print_log=True,
637+
attach_allure=False)
638+
logging.info(f"output of store_certs: {output}")
639+
640+
output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 1",
641+
idx=0, print_log=True,
642+
attach_allure=False)
643+
logging.info(f"output of fw_setenv cert_part 0: {output}")
644+
output = self.run_generic_command(cmd="rm -f /certificates/restrictions.json",
645+
idx=0, print_log=True,
646+
attach_allure=False)
647+
logging.info(f"output of removing restrictions: {output}")
648+
output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
649+
idx=0, print_log=True,
650+
attach_allure=False)
651+
logging.info(f"output of fw_setenv store_certs_disabled 0: {output}")
652+
output = self.run_generic_command(cmd="cd /certificates && store_certs",
653+
idx=0, print_log=True,
654+
attach_allure=False)
655+
logging.info(f"output of store_certs: {output}")
656+
657+
# Verify the restriction file is removed from both partitions
658+
output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 0",
659+
idx=0, print_log=True,
660+
attach_allure=False)
661+
logging.info(f"output of fw_setenv cert_part 0: {output}")
662+
output = self.run_generic_command(
663+
cmd='[ -f /certificates/restrictions.json ] && echo "True" || echo "False"',
664+
idx=0,
665+
print_log=True,
666+
attach_allure=False,
667+
expected_attachment_type=allure.attachment_type.TEXT)
668+
logging.info(f"Check for restrictions file in partition 0: {output}")
669+
result = output.strip().splitlines()[-1]
670+
if result == "True":
671+
logging.info("Unable to remove restrictions file from partition 0")
672+
#pytest.fail("Unable to remove restrictions file from partition 0")
673+
674+
output = self.run_generic_command(cmd="cd /certificates && fw_setenv cert_part 1",
675+
idx=0, print_log=True,
676+
attach_allure=False)
677+
logging.info(f"output of fw_setenv cert_part 0: {output}")
678+
output = self.run_generic_command(
679+
cmd='[ -f /certificates/restrictions.json ] && echo "True" || echo "False"',
680+
idx=0,
681+
print_log=True,
682+
attach_allure=False,
683+
expected_attachment_type=allure.attachment_type.TEXT)
684+
logging.info(f"Check for restrictions file in partition 1: {output}")
685+
result = output.strip().splitlines()[-1]
686+
if result == "True" :
687+
logging.info("Unable to remove restrictions file from partition 1")
688+
#pytest.fail("Unable to remove restrictions file from partition 1")
689+
690+
else:
691+
self.run_generic_command(cmd="rm /certificates/restrictions.json",
692+
idx=0, print_log=True,
693+
attach_allure=False)
694+
self.run_generic_command(cmd="rm /etc/ucentral/restrictions.json",
695+
idx=0, print_log=True,
696+
attach_allure=False)
697+
698+
627699
self.factory_reset(print_log=False)
628700
time.sleep(120)
629701
output = self.run_generic_command(cmd='[ -f /etc/ucentral/restrictions.json ] && echo "True" || echo "False"',
@@ -633,20 +705,92 @@ def remove_restrictions(self):
633705
expected_attachment_type=allure.attachment_type.TEXT)
634706
return output
635707

636-
def add_restrictions(self, restrictions_file, developer_mode):
708+
def add_restrictions(self, restrictions_file, developer_mode, ap_model):
637709
self.factory_reset(print_log=False)
638710
time.sleep(200)
639-
output = self.run_generic_command(cmd=developer_mode,
640-
idx=0,
641-
print_log=True,
642-
attach_allure=False,
643-
expected_attachment_type=allure.attachment_type.TEXT)
644-
output = self.run_generic_command(cmd=restrictions_file,
645-
idx=0,
646-
print_log=True,
647-
attach_allure=False,
648-
expected_attachment_type=allure.attachment_type.TEXT,
649-
restrictions=True)
711+
712+
if "sonicfi_rap" in ap_model:
713+
logging.info(f"Yes it is cybertan AP:")
714+
restrictions_file = 'echo \"{\\"country\\":[\\"US\\", \\"CA\\"],\\"dfs\\": true,\\"rtty\\": true,\\"tty\\": ' \
715+
'true,\\"developer\\": true,\\"sysupgrade\\": true,\\"commands\\": true,\\"key_info\\": {' \
716+
'\\"vendor\\": \\"dummy\\",\\"algo\\": \\"static\\"}}\" > /certificates/restrictions.json ' \
717+
'&& echo "Partition 0 done"'
718+
restrictions_file1 = 'echo \"{\\"country\\":[\\"US\\", \\"CA\\"],\\"dfs\\": true,\\"rtty\\": true,\\"tty\\": ' \
719+
'true,\\"developer\\": true,\\"sysupgrade\\": true,\\"commands\\": true,\\"key_info\\": {' \
720+
'\\"vendor\\": \\"dummy\\",\\"algo\\": \\"static\\"}}\" > /certificates/restrictions.json ' \
721+
'&& echo "Partition 1 done"'
722+
output = self.run_generic_command(cmd=developer_mode,
723+
idx=0,
724+
print_log=True,
725+
attach_allure=False,
726+
expected_attachment_type=allure.attachment_type.TEXT)
727+
logging.info(f"output of developer_mode::{output}")
728+
output = self.run_generic_command(cmd="fw_setenv cert_part 0",
729+
idx=0,
730+
print_log=True,
731+
attach_allure=False,
732+
expected_attachment_type=allure.attachment_type.TEXT)
733+
logging.info(f"output of fw_setenv cert_part 0::{output}")
734+
output = self.run_generic_command(cmd=restrictions_file,
735+
idx=0,
736+
print_log=True,
737+
attach_allure=False,
738+
expected_attachment_type=allure.attachment_type.TEXT,
739+
restrictions=True)
740+
logging.info(f"output of adding restrictions_file::{output}")
741+
output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
742+
idx=0,
743+
print_log=True,
744+
attach_allure=False,
745+
expected_attachment_type=allure.attachment_type.TEXT)
746+
logging.info(f"output of fw_setenv store_certs_disabled 0::{output}")
747+
cmd_output = self.run_generic_command(cmd="cd /certificates && store_certs",
748+
idx=0,
749+
print_log=True,
750+
attach_allure=False,
751+
expected_attachment_type=allure.attachment_type.TEXT,
752+
restrictions=True)
753+
logging.info(f"output of store_certs::{cmd_output}")
754+
output = self.run_generic_command(cmd="fw_setenv cert_part 1",
755+
idx=0,
756+
print_log=True,
757+
attach_allure=False,
758+
expected_attachment_type=allure.attachment_type.TEXT)
759+
logging.info(f"output of fw_setenv cert_part 1::{output}")
760+
output = self.run_generic_command(cmd=restrictions_file1,
761+
idx=0,
762+
print_log=True,
763+
attach_allure=False,
764+
expected_attachment_type=allure.attachment_type.TEXT,
765+
restrictions=True)
766+
logging.info(f"output of adding restrictions_file1::{output}")
767+
cmd_output = self.run_generic_command(cmd="fw_setenv store_certs_disabled 0",
768+
idx=0,
769+
print_log=True,
770+
attach_allure=False,
771+
expected_attachment_type=allure.attachment_type.TEXT)
772+
logging.info(f"output of fw_setenv store_certs_disabled 0::{cmd_output}")
773+
cmd_output = self.run_generic_command(cmd="cd /certificates && store_certs",
774+
idx=0,
775+
print_log=True,
776+
attach_allure=False,
777+
expected_attachment_type=allure.attachment_type.TEXT,
778+
restrictions=True)
779+
logging.info(f"output of store_certs::{cmd_output}")
780+
781+
else:
782+
output = self.run_generic_command(cmd=developer_mode,
783+
idx=0,
784+
print_log=True,
785+
attach_allure=False,
786+
expected_attachment_type=allure.attachment_type.TEXT)
787+
output = self.run_generic_command(cmd=restrictions_file,
788+
idx=0,
789+
print_log=True,
790+
attach_allure=False,
791+
expected_attachment_type=allure.attachment_type.TEXT,
792+
restrictions=True)
793+
650794
self.factory_reset(print_log=False)
651795
time.sleep(300)
652796
return output

tests/controller_tests/ucentral_gateway/test_gatewayservice.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ def test_gw_service_get_rtty(self, get_target_object, get_testbed_details):
10411041
@pytest.mark.asb_tests
10421042
def test_asb_on_non_restricted_ap(self, get_target_object, get_testbed_details):
10431043
device_name = get_testbed_details['device_under_tests'][0]['identifier']
1044+
ap_model = get_testbed_details['device_under_tests'][0]['model']
10441045
payload = {
10451046
"serialNumber": device_name,
10461047
"timeout": 30,
@@ -1060,7 +1061,7 @@ def test_asb_on_non_restricted_ap(self, get_target_object, get_testbed_details):
10601061
assert resp.status_code == 200
10611062
else:
10621063
logging.info("AP is restricted, Removing Restrictions")
1063-
output = get_target_object.get_dut_library_object().remove_restrictions()
1064+
output = get_target_object.get_dut_library_object().remove_restrictions(ap_model=ap_model)
10641065
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
10651066
if not resp:
10661067
logging.info("Removed Restrictions")
@@ -1078,6 +1079,7 @@ def test_asb_on_non_restricted_ap(self, get_target_object, get_testbed_details):
10781079
@pytest.mark.asb_tests
10791080
def test_asb_on_restricted_ap(self, get_target_object, get_testbed_details):
10801081
device_name = get_testbed_details['device_under_tests'][0]['identifier']
1082+
ap_model = get_testbed_details['device_under_tests'][0]['model']
10811083
payload = {
10821084
"serialNumber": device_name,
10831085
"timeout": 30,
@@ -1094,18 +1096,23 @@ def test_asb_on_restricted_ap(self, get_target_object, get_testbed_details):
10941096
'\\"vendor\\": \\"dummy\\",\\"algo\\": \\"static\\"}}\" > /certificates/restrictions.json ' \
10951097
'&& echo \"True\"'
10961098
developer_mode = "fw_setenv developer 0"
1099+
1100+
10971101
output = get_target_object.get_dut_library_object().add_restrictions(restrictions_file=restrictions_file,
1098-
developer_mode=developer_mode)
1099-
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
1102+
developer_mode=developer_mode, ap_model=ap_model)
1103+
logging.info(f"output of adding restrictions:{output}")
1104+
resp = get_target_object.controller_library_object.check_restrictions(device_name)
1105+
logging.info(f"response of check_restrictions:{resp} ")
11001106
if resp:
11011107
logging.info("From GW it's confirmed that AP is restricted now")
11021108
uuid = get_target_object.controller_library_object.asb_script(device_name, payload)
11031109
resp = get_target_object.controller_library_object.get_file(device_name, uuid)
11041110
assert resp.status_code == 200
11051111
else:
1112+
logging.info("Unable to add restrictions to the AP")
11061113
assert False
1107-
output = get_target_object.get_dut_library_object().remove_restrictions()
1108-
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
1114+
output = get_target_object.get_dut_library_object().remove_restrictions(ap_model=ap_model)
1115+
resp = get_target_object.controller_library_object.check_restrictions(device_name)
11091116
if resp:
11101117
logging.info("Unable to remove restrictions in the AP")
11111118
assert False

tests/test_connectivity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,14 @@ def test_access_points_connectivity(self, get_target_object, get_testbed_details
275275
@allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-12318", name="12318")
276276
def test_check_restrictions(self, get_target_object, get_testbed_details):
277277
device_name = get_testbed_details['device_under_tests'][0]['identifier']
278+
ap_model = get_testbed_details['device_under_tests'][0]['model']
278279
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
279280
if not resp:
280281
logging.info("AP is not restricted")
281282
assert True, "AP is not in restricted mode we can continue testing"
282283
else:
283284
logging.info("AP is restricted, Removing Restrictions")
284-
output = get_target_object.get_dut_library_object().remove_restrictions()
285+
output = get_target_object.get_dut_library_object().remove_restrictions(ap_model=ap_model)
285286
resp = resp = get_target_object.controller_library_object.check_restrictions(device_name)
286287
if not resp:
287288
logging.info("Removed Restrictions")

0 commit comments

Comments
 (0)