1# Copyright 2015 The Chromium 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
5import dbus
6
7from autotest_lib.client.bin import test
8from autotest_lib.client.common_lib import error
9
10
11SERVICE_NAME = 'org.chromium.WebServer'
12MANAGER_INTERFACE = 'org.chromium.WebServer.Manager'
13MANAGER_OBJECT_PATH = '/org/chromium/WebServer/Manager'
14
15EXPECTED_PING_RESPONSE = 'Web Server is running'
16
17class webservd_BasicDBusAPI(test.test):
18    """Check that basic webservd daemon DBus APIs are functional."""
19    version = 1
20
21    def run_once(self):
22        """Test entry point."""
23        bus = dbus.SystemBus()
24        manager_proxy = dbus.Interface(
25                bus.get_object(SERVICE_NAME, MANAGER_OBJECT_PATH),
26                dbus_interface=MANAGER_INTERFACE)
27        ping_response = manager_proxy.Ping()
28        if EXPECTED_PING_RESPONSE != ping_response:
29            raise error.TestFail(
30                    'Expected Manager.Ping to return %s but got %s instead.' %
31                    (EXPECTED_PING_RESPONSE, ping_response))
32