[telepathy-mission-control/master] fd.o#21034: add a regression test for invalid Client bus names

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Apr 7 05:07:53 PDT 2009


---
 test/twisted/Makefile.am             |    1 +
 test/twisted/dispatcher/fdo-21034.py |   75 ++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 test/twisted/dispatcher/fdo-21034.py

diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index 621fbe3..293f537 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -8,6 +8,7 @@ TWISTED_BASIC_TESTS = \
 	dispatcher/already-has-channel.py \
 	dispatcher/cancel.py \
 	dispatcher/create-text.py \
+	dispatcher/fdo-21034.py \
 	dispatcher/dispatch-text.py \
 	do-nothing.py \
 	test-account.py \
diff --git a/test/twisted/dispatcher/fdo-21034.py b/test/twisted/dispatcher/fdo-21034.py
new file mode 100644
index 0000000..474ad6a
--- /dev/null
+++ b/test/twisted/dispatcher/fdo-21034.py
@@ -0,0 +1,75 @@
+"""Regression test for https://bugs.freedesktop.org/show_bug.cgi?id=21034
+"""
+
+import dbus
+import dbus.service
+
+from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
+        call_async
+from mctest import exec_test, SimulatedConnection, SimulatedClient, \
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+import constants as cs
+
+def test(q, bus, mc):
+    params = dbus.Dictionary({"account": "someguy at example.com",
+        "password": "secrecy"}, signature='sv')
+    cm_name_ref, account = create_fakecm_account(q, bus, mc, params)
+    conn = enable_fakecm_account(q, bus, mc, account, params)
+
+    text_fixed_properties = dbus.Dictionary({
+        cs.CHANNEL + '.TargetHandleType': cs.HT_CONTACT,
+        cs.CHANNEL + '.ChannelType': cs.CHANNEL_TYPE_TEXT,
+        }, signature='sv')
+
+    client = SimulatedClient(q, bus, 'Empathy',
+            observe=[text_fixed_properties], approve=[text_fixed_properties],
+            handle=[text_fixed_properties], bypass_approval=False)
+
+    # wait for MC to download the properties
+    q.expect_many(
+            EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE, method='Get',
+                args=[cs.CLIENT, 'Interfaces'],
+                path=client.object_path),
+            EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE, method='Get',
+                args=[cs.APPROVER, 'ApproverChannelFilter'],
+                path=client.object_path),
+            EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE, method='Get',
+                args=[cs.HANDLER, 'HandlerChannelFilter'],
+                path=client.object_path),
+            EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE, method='Get',
+                args=[cs.OBSERVER, 'ObserverChannelFilter'],
+                path=client.object_path),
+            )
+
+    cd = bus.get_object(cs.CD_BUS_NAME, cs.CD_PATH)
+    cd_props = dbus.Interface(cd, cs.PROPERTIES_IFACE)
+
+    # chat UI calls ChannelDispatcher.EnsureChannel or CreateChannel
+    request = dbus.Dictionary({
+            cs.CHANNEL + '.ChannelType': cs.CHANNEL_TYPE_TEXT,
+            cs.CHANNEL + '.TargetHandleType': cs.HT_CONTACT,
+            cs.CHANNEL + '.TargetID': 'juliet',
+            }, signature='sv')
+    account_requests = dbus.Interface(account,
+            cs.ACCOUNT_IFACE_NOKIA_REQUESTS)
+
+    call_async(q, cd, 'CreateChannel',
+            account.object_path, request, dbus.Int64(1234),
+            'grr.arg',      # a valid bus name, but the wrong prefix
+            dbus_interface=cs.CD)
+    ret = q.expect('dbus-error', method='CreateChannel')
+    assert ret.error.get_dbus_name() == cs.INVALID_ARGUMENT
+
+    call_async(q, cd, 'CreateChannel',
+            account.object_path, request, dbus.Int64(1234),
+            'can has cheeseburger?',      # a totally invalid bus name
+            dbus_interface=cs.CD)
+    ret = q.expect('dbus-error', method='CreateChannel')
+    assert ret.error.get_dbus_name() == cs.INVALID_ARGUMENT
+
+if __name__ == '__main__':
+    exec_test(test, {})
-- 
1.5.6.5




More information about the telepathy-commits mailing list