blob: 56e9dbe40ca218e7b3c8420553e6209ab7de38ec [file] [log] [blame]
# Copyright (c) 2013 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.
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib.cros import session_manager
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros import cros_ui, cryptohome
class login_SameSessionTwice(test.test):
"""Ensure that the session_manager won't start the same session twice.
version = 1
def initialize(self):
super(login_SameSessionTwice, self).initialize()
def run_once(self):
bus_loop = DBusGMainLoop(set_as_default=True)
sm = session_manager.connect(bus_loop)
user = ''
if not sm.StartSession(user, ''):
raise error.TestFail('Could not start session for ' + user)
if sm.StartSession(user, ''):
raise error.TestFail('Started second session for ' + user)
except dbus.DBusException as d:
# If I knew how to get our custom dbus errors mapped into real
# exceptions in PyDBus, I'd use that here :-/
if 'already started a session' not in d.message:
raise error.TestFail(d)
def cleanup(self):
# Bounce UI, without waiting for the browser to come back. Best effort.
cros_ui.start(allow_fail=True, wait_for_login_prompt=False)