diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2014-04-10 09:11:12 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-04-15 11:24:43 +0200 |
commit | 42c28b9424b6ef8a0021b124773e171dd5defadd (patch) | |
tree | 4bb8c5fd4d6aef0dfe8087e2de3fd18917f7b637 /src/tests/sbus_tests.c | |
parent | 9123c2abff5780f485764261eb4b180e9ceadf20 (diff) | |
download | sssd-42c28b9424b6ef8a0021b124773e171dd5defadd.tar.gz sssd-42c28b9424b6ef8a0021b124773e171dd5defadd.tar.xz sssd-42c28b9424b6ef8a0021b124773e171dd5defadd.zip |
SBUS: Generate introspection from the interface meta structure
https://fedorahosted.org/sssd/ticket/2234
This patch generates the introspection data from the sbus interface meta
structure. The generated XML conforms to
http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format
The XML description of the interface also always includes the
org.freedesktop.DBus.Introspectable interface, which this patch also allows
in the policy settings.
Diffstat (limited to 'src/tests/sbus_tests.c')
-rw-r--r-- | src/tests/sbus_tests.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/tests/sbus_tests.c b/src/tests/sbus_tests.c index e4cab454d..194ba60ef 100644 --- a/src/tests/sbus_tests.c +++ b/src/tests/sbus_tests.c @@ -44,6 +44,23 @@ #define PILOT_BLINK "Blink" #define PILOT_EAT "Eat" +#define PILOT_IFACE_INTROSPECT \ + "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \ + "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n" \ + "<node>\n" \ + " <interface name=\"test.Pilot\">\n" \ + " <method name=\"Blink\">\n" \ + " </method>\n" \ + " <method name=\"Eat\">\n" \ + " </method>\n" \ + " </interface>\n" \ + " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \ + " <method name=\"Introspect\">\n" \ + " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \ + " </method>\n" \ + " </interface>\n" \ + "</node>\n" + /* our vtable */ struct pilot_vtable { struct sbus_vtable vtable; @@ -276,6 +293,37 @@ START_TEST(test_request_parse_bad_args) } END_TEST +START_TEST(test_introspection) +{ + TALLOC_CTX *ctx; + DBusConnection *client; + DBusError error = DBUS_ERROR_INIT; + DBusMessage *reply; + char *xml; + + ctx = talloc_new(NULL); + client = test_dbus_setup_mock(ctx, NULL, pilot_test_server_init, NULL); + + reply = test_dbus_call_sync(client, + "/test/leela", + DBUS_INTROSPECT_INTERFACE, + DBUS_INTROSPECT_METHOD, + &error, + DBUS_TYPE_INVALID); /* bad agruments */ + + ck_assert(reply != NULL); + ck_assert(!dbus_error_is_set(&error)); + ck_assert(dbus_message_get_args(reply, NULL, + DBUS_TYPE_STRING, &xml, + DBUS_TYPE_INVALID)); + ck_assert_str_eq(PILOT_IFACE_INTROSPECT, xml); + + dbus_message_unref(reply); + + talloc_free(ctx); +} +END_TEST + TCase *create_sbus_tests(void) { TCase *tc = tcase_create("tests"); @@ -283,6 +331,7 @@ TCase *create_sbus_tests(void) tcase_add_test(tc, test_raw_handler); tcase_add_test(tc, test_request_parse_ok); tcase_add_test(tc, test_request_parse_bad_args); + tcase_add_test(tc, test_introspection); return tc; } |