class AdbConnectionAndKey(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(AdbConnectionAndKey, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(AdbConnectionAndKey, self).tearDown() def test_check_adb_connection_and_key_userdebug_image(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") g_common_obj.adb_cmd_common("devices") self.securityImpl.root() cmd = "ls -la /adb_keys" msg = g_common_obj.adb_cmd_capture_msg(cmd) print msg assert "adb_keys" in msg cat_cmd = "cat /adb_keys" cat_adb_keys = g_common_obj.adb_cmd_capture_msg(cat_cmd) if cat_adb_keys == None: assert False, "adb_keys is null"
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.flashImage = FlashImage() self.securityImpl.check_pre_build_test_or_ebimage() print print "[Setup]: %s" % self._test_name super(NegativeTipcTest, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print self.def_passwd = "qwer123" self.def_pin = 1234 self.def_pattern = 14789 print "[Setup]: %s" % self._test_name super(ScreenLockPasswdPinPatternUpdateNoChanges, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print self.def_passwd = "qwer123" self.def_pin = 1234 self.def_pattern = 14789 print "[Setup]: %s" % self._test_name super(GatekeeperdKilledWithScreenLock, self).setUp()
def start_RPCServer(self): """ Start RPC server """ self.adb_root() # self.func.push_uiautomator_jar() from testlib.security.security_impl import SecurityImpl self.securityImpl = SecurityImpl() self.securityImpl.start_RPCServer()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print self.def_passwd = "qwer123" self.def_pin = 1234 self.def_pattern = 14789 print "[Setup]: %s" % self._test_name super(ScreenLockToNoPassword, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print self.def_passwd = "qwer123" self.def_pin = 1234 self.def_pattern = 14789 print "[Setup]: %s" % self._test_name super(LockProtectedOptionsPasswdPinPattern, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print self.def_passwd = "qwer123" self.def_pin = 1234 self.def_pattern = 14789 print "[Setup]: %s" % self._test_name self.securityImpl.run_check_disk_encryption_type() super(DiskEncryptionVoldDecryptStatus, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.flashImage = FlashImage() self.securityImpl.check_pre_build_test_or_ebimage() self.tar_dut_path = "/data/local/tmp/" self.push_file = "alsr_exists" print print "[Setup]: %s" % self._test_name super(ALSRAddressCheck, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.flashImage = FlashImage() self.securityImpl.check_pre_build_test_or_ebimage() self.tar_dut_path = "/data/local/tmp/" self.push_file = "tipc-test32" print print "[Setup]: %s" % self._test_name super(TipcTest, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.incorrect_passwd = "qwer" self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.incorrect_pin = 1111 self.incorrect_pin_long = 1234567890 print print "[Setup]: %s" % self._test_name super(ScreenLockUpdateWrongPasswd, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.def_pin = 1234 self.def_pattern = 14789 self.update_passwd = "qwer123456" self.update_pin = 123456 self.update_pattern = 4789 print print "[Setup]: %s" % self._test_name self.securityImpl.run_check_disk_encryption_type() super(DiskEncryptionKeyUpdateLockType, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.incorrect_passwd = "qwer" self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.incorrect_pin = 1111 self.incorrect_pin_long = 1234567890 self.securityImpl.start_RPCServer() print print "[Setup]: %s" % self._test_name self.securityImpl.run_check_disk_encryption_type() super(ScreenLockTypeAtBootTime, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.incorrect_passwd = "qwer" self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.incorrect_pin = 1111 self.incorrect_pin_long = 1234567890 self.init_dut = InitFlashDevices() self.securityImpl.start_RPCServer() print print "[Setup]: %s" % self._test_name self.securityImpl.run_check_disk_encryption_type() super(DataPartitionAccess, self).setUp()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.min_passwd = ["1", "q", "q1", "qw1"] self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.min_pin = [0, 1, 12, 123] self.incorrect_pin_long = 1234567890 # (draw_point_top, draw_point_left), (5, 5)==1 ,(3, 5)==2, (1,5)==3 self.min_pattern = [5, 3, 1] print self.securityImpl.choose_screen_lock("None") print "[Setup]: %s" % self._test_name super(MinimiumRequirementCheckScreenLock, self).setUp()
class VMXFlagForTrustyOs(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(VMXFlagForTrustyOs, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(VMXFlagForTrustyOs, self).tearDown() def test_vmx_flag_for_trusty_os(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.vmx_flag_for_trusty_os()
class CACredentialsCheck(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(CACredentialsCheck, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(CACredentialsCheck, self).tearDown() def test_ca_credentials_check(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.check_CA_credentials_comm()
class SelinuxModeCheck(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(SelinuxModeCheck, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(SelinuxModeCheck, self).tearDown() def test_selinux_mode_check(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.selinux_mode_check()
class SystemMountAreReadOnly(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(SystemMountAreReadOnly, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(SystemMountAreReadOnly, self).tearDown() def test_system_mount_are_read_only(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.system_mount_are_read_only()
def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.incorrect_passwd = "qwer" self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.incorrect_pin = 1111 self.incorrect_pin_long = 1234567890 if 1 == 1: raise Exception( "Debug case on going, skip it, next time run this case") print print "[Setup]: %s" % self._test_name self.securityImpl.start_RPCServer() super(LockTypeUnlockMoreThan30times, self).setUp()
class KeymasterVersionCheck(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(KeymasterVersionCheck, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(KeymasterVersionCheck, self).tearDown() def test_keymaster_version_check(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.keymaster_version_check()
class DiskEncryptionFlagCheck(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(DiskEncryptionFlagCheck, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(DiskEncryptionFlagCheck, self).tearDown() def test_disk_encryption_flag_check(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.disk_encryption_flag_check()
class GatekeeperdRunning(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(GatekeeperdRunning, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(GatekeeperdRunning, self).tearDown() def test_gatekeeperd_running_in_background(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.check_gatekeeperd_running()
class SelinuxModeSwitch(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(SelinuxModeSwitch, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(SelinuxModeSwitch, self).tearDown() def test_selinux_mode_switch(self): # HP desc: need use userdebug image print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.selinux_mode_switch()
class ALSRAddressCheck(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.flashImage = FlashImage() self.securityImpl.check_pre_build_test_or_ebimage() self.tar_dut_path = "/data/local/tmp/" self.push_file = "alsr_exists" print print "[Setup]: %s" % self._test_name super(ALSRAddressCheck, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(ALSRAddressCheck, self).tearDown() def auto_flash_eb_image(self): product = self.securityImpl.check_product() if "gordon_peak" in product: mem_size = self.securityImpl.check_memery_2G_4G_8G_board() if "2G" == mem_size: option_file = "alsr_omr1_2g" else: option_file = "alsr_omr1" elif "bxt" in product: option_file = "alsr_m" else: print "Other product: {}".format(product) raise EnvironmentError, "pls setup DUT..." self.securityImpl.logger.info(option_file) res_eb_image = self.flashImage.get_download_file_res( option_file, "ALSR_address-flashfiles") eb_image = self.flashImage.download_image_file(option_file, res_eb_image) self.flashImage.auto_flash_image(eb_image) self.securityImpl.push_to_dut_file_add_permission( self.push_file, self.tar_dut_path) def whether_flash_eb_image(self): if self.securityImpl.check_eb_image_file_exists( self.tar_dut_path, self.push_file) is False: print "[info]---res file %s already not existed, Need to flash image..." % self.push_file self.auto_flash_eb_image() def test_eb_image_alsr_variable_function_address_check(self): # HP desc: need use userdebug image print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.whether_flash_eb_image() self.securityImpl.check_ALSR_variable_address()
class MinimiumRequirementCheckScreenLock(UIATestBase): # HP desc: need use user image def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.min_passwd = ["1", "q", "q1", "qw1"] self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.min_pin = [0, 1, 12, 123] self.incorrect_pin_long = 1234567890 # (draw_point_top, draw_point_left), (5, 5)==1 ,(3, 5)==2, (1,5)==3 self.min_pattern = [5, 3, 1] print self.securityImpl.choose_screen_lock("None") print "[Setup]: %s" % self._test_name super(MinimiumRequirementCheckScreenLock, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(MinimiumRequirementCheckScreenLock, self).tearDown() def test_minimium_requirement_check_screen_lock_password(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") loop_input_times = len(self.min_passwd) for i in range(loop_input_times): self.securityImpl.logger.info("Loop input min Password %d/%d " % (i + 1, loop_input_times)) self.securityImpl.minimium_requirement_set_screen_lock_type( "Password", self.min_passwd[i]) def test_minimium_requirement_check_screen_lock_pin(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") loop_input_times = len(self.min_pin) for i in range(loop_input_times): self.securityImpl.logger.info("Loop input min PIN %d/%d " % ((i + 1), loop_input_times)) self.securityImpl.minimium_requirement_set_screen_lock_type( "PIN", self.def_passwd, self.min_pin[i]) def test_minimium_requirement_check_screen_lock_pattern(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") loop_input_times = len(self.min_pattern) for i in range(loop_input_times): self.securityImpl.logger.info("Loop input min Pattern %d/%d " % ((i + 1), loop_input_times)) self.securityImpl.minimium_requirement_set_screen_lock_type( "Pattern", self.min_pattern[i])
class HardwareBackedKeystore(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() print print "[Setup]: %s" % self._test_name super(HardwareBackedKeystore, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(HardwareBackedKeystore, self).tearDown() def test_hardware_backed_keystore(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.hardware_backed_keystore() def test_hardware_backed_keystore_libary_check(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.hardware_backed_keystore_libary_check()
class NegativeTipcTest(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.flashImage = FlashImage() self.securityImpl.check_pre_build_test_or_ebimage() print print "[Setup]: %s" % self._test_name super(NegativeTipcTest, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(NegativeTipcTest, self).tearDown() def test_eb_image_negative_tipc_test(self): # HP desc: need use userdebug image print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") option_file = None tar_dut_path = "/data/local/tmp/" product = self.securityImpl.check_product() if "gordon_peak" in product: mem_size = self.securityImpl.check_memery_2G_4G_8G_board() if "2G" == mem_size: option_file = "negative_omr1_2g" else: option_file = "negative_omr1" elif "bxt" in product: option_file = "negative_m" else: print "Other product: {}".format(product) raise EnvironmentError, "pls setup DUT..." self.securityImpl.logger.info(option_file) res_eb_image = self.flashImage.get_download_file_res( option_file, "negative-flashfiles") eb_image = self.flashImage.download_image_file(option_file, res_eb_image) self.flashImage.auto_flash_image(eb_image) file_path = self.securityImpl.push_to_dut_file_add_permission( "negative_test", tar_dut_path) self.securityImpl.run_negative_test(file_path)
class LockTypeUnlockMoreThan30times(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.incorrect_passwd = "qwer" self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.incorrect_pin = 1111 self.incorrect_pin_long = 1234567890 if 1 == 1: raise Exception( "Debug case on going, skip it, next time run this case") print print "[Setup]: %s" % self._test_name self.securityImpl.start_RPCServer() super(LockTypeUnlockMoreThan30times, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(LockTypeUnlockMoreThan30times, self).tearDown() def test_brute_force_password_more_than_30times(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") # 1. Password print "[Test_type]------Test lock type with <Password> lock type------" self.securityImpl.set_screen_lock_type_all("Password", self.def_passwd) self.securityImpl.action_screen_lock_security("Unlock") try: self.securityImpl.resume_unlock_screen_lock_type_all( "Password", 32, self.def_passwd, self.incorrect_passwd_long, self.def_pin, self.incorrect_pin_long) self.securityImpl.remove_resume_screen_lock_type_all( "Password", self.def_passwd) except Exception, e: print e if "RPC server not started" in e: self.securityImpl.check_RPC_server_not_start(self.def_passwd) self.securityImpl.remove_resume_screen_lock_type_all( "Password", self.def_passwd) raise Exception(e)
class ScreenLockTypeAtBootTime(UIATestBase): def setUp(self): self._test_name = __name__ self.securityImpl = SecurityImpl() self.def_passwd = "qwer123" self.incorrect_passwd = "qwer" self.incorrect_passwd_long = "abcdefg123456" self.def_pin = 1234 self.incorrect_pin = 1111 self.incorrect_pin_long = 1234567890 self.securityImpl.start_RPCServer() print print "[Setup]: %s" % self._test_name self.securityImpl.run_check_disk_encryption_type() super(ScreenLockTypeAtBootTime, self).setUp() def tearDown(self): print "[Teardown]: %s" % self._test_name super(ScreenLockTypeAtBootTime, self).tearDown() def test_boot_with_screen_lock_password(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.set_screen_lock_type_all("Password", self.def_passwd) self.securityImpl.action_screen_lock_security("Reboot") self.securityImpl.unlock_screen_lock_type_all("Password", 10, self.def_passwd, self.incorrect_passwd_long, self.def_pin, self.incorrect_pin_long) self.securityImpl.remove_screen_lock_type_all("Password", self.def_passwd) def test_boot_with_screen_lock_pin(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.set_screen_lock_type_all("PIN", self.def_passwd, self.def_pin) self.securityImpl.action_screen_lock_security("Reboot") self.securityImpl.unlock_screen_lock_type_all("PIN", 10, self.def_passwd, self.incorrect_passwd_long, self.def_pin, self.incorrect_pin_long) self.securityImpl.remove_screen_lock_type_all("PIN", self.def_passwd, self.def_pin) def test_boot_with_screen_lock_pattern(self): print "[RunTest]: %s" % self.__str__() self.securityImpl.logger.info("") self.securityImpl.set_screen_lock_type_all("Pattern") self.securityImpl.action_screen_lock_security("Reboot") self.securityImpl.unlock_screen_lock_type_all("Pattern", 10, "incorrect_pattern") self.securityImpl.remove_screen_lock_type_all("Pattern")