1# Copyright 2018 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from autotest_lib.client.common_lib import error 6from autotest_lib.server.cros.faft.cr50_test import Cr50Test 7 8 9class firmware_Cr50Password(Cr50Test): 10 """Verify cr50 set password.""" 11 version = 1 12 PASSWORD = 'Password' 13 NEW_PASSWORD = 'robot' 14 15 16 def run_once(self): 17 """Check we can set the cr50 password.""" 18 # Make sure to enable testlab mode, so we can guarantee the password 19 # can be cleared. 20 self.fast_open(enable_testlab=True) 21 self.cr50.send_command('ccd reset') 22 23 # Set the password 24 self.set_ccd_password(self.PASSWORD) 25 if self.cr50.get_ccd_info()['Password'] != 'set': 26 raise error.TestFail('Failed to set password') 27 28 # Test 'ccd reset' clears the password 29 self.cr50.send_command('ccd reset') 30 if self.cr50.get_ccd_info()['Password'] != 'none': 31 raise error.TestFail('ccd reset did not clear the password') 32 33 # Set the password again while cr50 is open 34 self.set_ccd_password(self.PASSWORD) 35 if self.cr50.get_ccd_info()['Password'] != 'set': 36 raise error.TestFail('Failed to set password') 37 38 # Make sure we can't overwrite the password 39 self.set_ccd_password(self.NEW_PASSWORD, expect_error=True) 40 41 self.cr50.set_ccd_level('lock') 42 # Make sure you can't clear the password while the console is locked 43 self.set_ccd_password('clear:' + self.PASSWORD, expect_error=True) 44 45 self.cr50.send_command('ccd unlock ' + self.PASSWORD) 46 # Make sure you can't clear the password while the console is unlocked 47 self.set_ccd_password('clear:' + self.PASSWORD, expect_error=True) 48 49 self.cr50.send_command('ccd testlab open') 50 51 # Make sure you can't clear the password with the wrong password 52 self.set_ccd_password('clear:' + self.PASSWORD.lower(), 53 expect_error=True) 54 # Make sure you can clear the password when the console is open 55 self.set_ccd_password('clear:' + self.PASSWORD) 56 if self.cr50.get_ccd_info()['Password'] != 'none': 57 raise error.TestFail('Failed to clear password') 58 59 # Make sure you can set some other password after it is cleared 60 self.set_ccd_password(self.NEW_PASSWORD) 61 if self.cr50.get_ccd_info()['Password'] != 'set': 62 raise error.TestFail('Failed to clear password') 63 64 65 self.cr50.send_command('ccd testlab open') 66 self.cr50.send_command('ccd reset') 67 self.host.run('gsctool -a -U') 68 69 # Set the password when the console is unlocked 70 self.set_ccd_password(self.PASSWORD) 71 72 self.cr50.set_ccd_level('lock') 73 # Make sure you can't clear the password while the console is locked 74 self.set_ccd_password('clear:' + self.PASSWORD, expect_error=True) 75 76 # unlock the console 77 self.ccd_unlock_from_ap(self.PASSWORD) 78 # Make sure you can clear the password when the console is unlocked 79 self.set_ccd_password('clear:' + self.PASSWORD) 80 # Set the password again when the console is unlocked 81 self.set_ccd_password(self.PASSWORD) 82 83 self.cr50.send_command('ccd testlab open') 84 # Make sure you can clear the password when the console is open 85 self.set_ccd_password('clear:' + self.PASSWORD) 86