scripts: deploy_chrome: add --unlock-password option
If provided the unlock password will be entered into the unlock screen
after deployment and restart, once the unlock screen is displayed.
BUG=none
TEST=./run_tests scripts/deploy_chrome_unittest.py
TEST=manual
Change-Id: Icddba9567f5a11ea58d64fd5176828568cb127a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4338996
Tested-by: Joel Hockey <joelhockey@chromium.org>
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Auto-Submit: Joel Hockey <joelhockey@chromium.org>
diff --git a/scripts/deploy_chrome_unittest.py b/scripts/deploy_chrome_unittest.py
index 6ec7a23..ad9ffa1 100644
--- a/scripts/deploy_chrome_unittest.py
+++ b/scripts/deploy_chrome_unittest.py
@@ -197,6 +197,18 @@
options = _ParseCommandLine(argv)
self.assertEqual(options.private_key, "/foo/bar/key")
+ def testUnlockPassword(self):
+ argv = list(_REGULAR_TO) + [
+ "--board",
+ _TARGET_BOARD,
+ "--unlock-password",
+ "letmein",
+ "--build-dir",
+ "/path/to/nowhere",
+ ]
+ options = _ParseCommandLine(argv)
+ self.assertEqual(options.unlock_password, "letmein")
+
class DeployChromeMock(partial_mock.PartialMock):
"""Deploy Chrome Mock Class."""
@@ -453,6 +465,39 @@
self.assertTrue(self.deploy._CheckUiJobStarted())
+class TestUnlockPassword(DeployTest):
+ """Test that unlock password is sent."""
+
+ def _GetDeployChrome(self, args):
+ args.append("--unlock-password=letmein")
+ return super(TestUnlockPassword, self)._GetDeployChrome(args)
+
+ def testUnlock(self):
+ """Test that unlock password is sent."""
+ self.deploy._stopped_ui = True
+
+ # Update LAST_LOGIN_COMMAND to return a different value.
+ def SideEffect(*args, **kwargs):
+ # pylint: disable=unused-argument
+ self.deploy_mock.rsh_mock.AddCmdResult(
+ deploy_chrome.LAST_LOGIN_COMMAND, stdout="2.0"
+ )
+
+ # LAST_LOGIN_COMMAND returns 1.0 the first time it is called, then 2.0.
+ self.deploy_mock.rsh_mock.AddCmdResult(
+ deploy_chrome.LAST_LOGIN_COMMAND,
+ stdout="1.0",
+ side_effect=SideEffect,
+ )
+ with mock.patch.object(remote_access.ChromiumOSDevice, "CopyToDevice"):
+ with mock.patch.object(time, "sleep"):
+ self.deploy._Deploy()
+ # Ensure unlock command was called.
+ self.deploy_mock.rsh_mock.assertCommandContains(
+ deploy_chrome.UNLOCK_PASSWORD_COMMAND % "letmein"
+ )
+
+
class StagingTest(cros_test_lib.MockTempDirTestCase):
"""Test user-mode and ebuild-mode staging functionality."""