blob: a568ddb716cfec30df556e530d6d5cc4b3294886 [file] [log] [blame]
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from dbus.mainloop.glib import DBusGMainLoop
from autotest_lib.client.common_lib.cros import session_manager
from autotest_lib.client.common_lib import error
from autotest_lib.client.bin import test, utils
from autotest_lib.client.cros import cros_ui
class platform_SessionManagerStateKeyGeneration(test.test):
'''Verifies that session_manager's GetServerBackedStateKeys DBus method
returns valid state keys.'''
version = 1
def initialize(self):
super(platform_SessionManagerStateKeyGeneration, self).initialize()
self._bus_loop = DBusGMainLoop(set_as_default=True)
def run_once(self):
if utils.system_output('crossystem mainfw_type') == 'nonchrome':
raise error.TestNAError(
'State key generation only works on Chrome OS hardware')
except error.CmdError, e:
raise error.TestError('Failed to run crossystem: %s' % e)
# Retrieve state keys.
session_manager_proxy = session_manager.connect(self._bus_loop)
state_keys = session_manager_proxy.GetServerBackedStateKeys(
# Sanity-check the state keys.
if len(state_keys) < 3:
raise error.TestFail("Not enough state keys")
if len(state_keys) != len(set(state_keys)):
raise error.TestFail("Duplicate state keys")
for state_key in state_keys:
if len(state_key) != 32:
raise error.TestFail("Bad state key size")