@@ -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
0 commit comments