[Telepathy-commits] [telepathy-gabble/master] Extract invalid tube request tests to a separate file
Will Thompson
will.thompson at collabora.co.uk
Tue Feb 3 03:36:29 PST 2009
---
tests/twisted/Makefile.am | 1 +
.../twisted/tubes/create-invalid-tube-channels.py | 59 ++++++++++++++++++++
...offer-accept-private-dbus-stream-tube-socks5.py | 30 ----------
3 files changed, 60 insertions(+), 30 deletions(-)
create mode 100644 tests/twisted/tubes/create-invalid-tube-channels.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index ad65846..b04fded 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -42,6 +42,7 @@ TWISTED_TESTS = \
tubes/muc-presence.py \
tubes/close-muc-with-closed-tube.py \
tubes/crash-on-list-channels.py \
+ tubes/create-invalid-tube-channels.py \
tubes/test-get-available-tubes.py \
tubes/accept-muc-stream-tube-ibb.py \
tubes/accept-private-stream-tube.py \
diff --git a/tests/twisted/tubes/create-invalid-tube-channels.py b/tests/twisted/tubes/create-invalid-tube-channels.py
new file mode 100644
index 0000000..ebb79db
--- /dev/null
+++ b/tests/twisted/tubes/create-invalid-tube-channels.py
@@ -0,0 +1,59 @@
+"""
+Check that Gabble rejects invalid requests for tubes channels.
+"""
+
+import dbus
+from dbus import PROPERTIES_IFACE
+
+from servicetest import call_async
+from gabbletest import exec_test
+from constants import *
+from tubetestutil import *
+
+def is_tube(path, props):
+ ct = props[CHANNEL_TYPE]
+ return ct in [CHANNEL_TYPE_STREAM_TUBE, CHANNEL_TYPE_DBUS_TUBE]
+
+def check_no_tubes(conn_props):
+ channels = conn_props.Get(CONN_IFACE_REQUESTS, 'Channels')
+ tube_channels = filter(is_tube, channels)
+ assert len(tube_channels) == 0, tube_channels
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]),
+
+ conn_props = dbus.Interface(conn, PROPERTIES_IFACE)
+ requestotron = dbus.Interface(conn, CONN_IFACE_REQUESTS)
+
+ # Try to CreateChannel with unknown properties
+ # Gabble must return an error
+ call_async(q, requestotron, 'CreateChannel',
+ {CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
+ TARGET_HANDLE_TYPE: HT_CONTACT,
+ TARGET_ID: "foo at example.com",
+ 'this.property.does.not.exist':
+ 'this.value.should.not.exist'
+ });
+ ret = q.expect('dbus-error', method='CreateChannel')
+
+ check_no_tubes(conn_props)
+
+ # Try to CreateChannel with missing properties ("Service")
+ # Gabble must return an error
+ call_async(q, requestotron, 'CreateChannel',
+ {CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
+ TARGET_HANDLE_TYPE: HT_CONTACT,
+ TARGET_ID: "foo at example.com",
+ });
+ ret = q.expect('dbus-error', method='CreateChannel')
+
+ check_no_tubes(conn_props)
+
+ conn.Disconnect()
+
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+if __name__ == '__main__':
+ exec_test(test)
diff --git a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
index a2265dc..342b675 100644
--- a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
+++ b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
@@ -313,36 +313,6 @@ def test(q, bus, conn, stream):
check_conn_properties(q, conn, [old_tubes_channel_properties])
- # Try to CreateChannel with unknown properties
- # Gabble must return an error
- call_async(q, requestotron, 'CreateChannel',
- {'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube.DRAFT',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType':
- 1,
- 'org.freedesktop.Telepathy.Channel.TargetHandle':
- bob_handle,
- 'this.property.does.not.exist':
- 'this.value.should.not.exist'
- });
- ret = q.expect_many(EventPattern('dbus-error', method='CreateChannel'))
- # CreateChannel failed, we expect no new channel
- check_conn_properties(q, conn, [old_tubes_channel_properties])
-
- # Try to CreateChannel with missing properties ("Service")
- # Gabble must return an error
- call_async(q, requestotron, 'CreateChannel',
- {'org.freedesktop.Telepathy.Channel.ChannelType':
- 'org.freedesktop.Telepathy.Channel.Type.StreamTube.DRAFT',
- 'org.freedesktop.Telepathy.Channel.TargetHandleType':
- 1,
- 'org.freedesktop.Telepathy.Channel.TargetHandle':
- bob_handle
- });
- ret = q.expect_many(EventPattern('dbus-error', method='CreateChannel'))
- # CreateChannel failed, we expect no new channel
- check_conn_properties(q, conn, [old_tubes_channel_properties])
-
# Try to create a DBusTube.DRAFT channel. This is not implemented yet, so
# it will fail. But it should not assert.
call_async(q, requestotron, 'CreateChannel',
--
1.5.6.5
More information about the telepathy-commits
mailing list