Home | History | Annotate | Download | only in platform_CryptohomeGetEnrollmentId
      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 
      5 import re
      6 
      7 from autotest_lib.client.bin import test, utils
      8 from autotest_lib.client.common_lib import error
      9 
     10 class platform_CryptohomeGetEnrollmentId(test.test):
     11     version = 1
     12 
     13     def has_device_secret(self):
     14         # Using the same way of getting the device secret as we use in
     15         # cryptohomed.conf.
     16         exit_code = utils.system(
     17             'vpd_get_value stable_device_secret_DO_NOT_SHARE',
     18             ignore_status=True)
     19         return exit_code == 0
     20 
     21     def check_enrollment_id(self):
     22         eid = utils.system_output('cryptohome --action=get_enrollment_id')
     23         return len(eid) == 64
     24 
     25     def run_once(self):
     26         if (self.has_device_secret()):
     27             if (not self.check_enrollment_id()):
     28                 raise error.TestFail('Invalid enrollment ID value.')
     29