def test_change_password(config_dir, alice): old_password = "******" new_password = "******" save_device_with_password_in_config(config_dir, alice, old_password) key_file = get_key_file(config_dir, alice) change_device_password(key_file, old_password, new_password) alice_reloaded = load_device_with_password(key_file, new_password) assert alice == alice_reloaded with pytest.raises(LocalDeviceCryptoError): load_device_with_password(key_file, old_password)
def change_password(self): if self.line_edit_password.text() != self.line_edit_password_check.text(): show_error(self, _("TEXT_CHANGE_PASSWORD_PASSWORD_MISMATCH")) else: key_file = get_key_file(self.core.config.config_dir, self.core.device) try: change_device_password( key_file, self.line_edit_old_password.text(), self.line_edit_password.text() ) show_info(self, _("TEXT_CHANGE_PASSWORD_SUCCESS")) if self.dialog: self.dialog.accept() elif QApplication.activeModalWidget(): QApplication.activeModalWidget().accept() else: logger.warning("Cannot close dialog when changing password info") except LocalDeviceCryptoError as exc: show_error(self, _("TEXT_CHANGE_PASSWORD_INVALID_PASSWORD"), exception=exc)