[telepathy-gabble/master] tubetestutil: add connect_to_cm_socket() helper
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Tue May 12 09:55:02 PDT 2009
This function connects to CM's socket and do the needed bits to auth the
process according the acces_control mechanism.
---
tests/twisted/tubes/tubetestutil.py | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index 7781c5c..8d56557 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -8,10 +8,11 @@ import os
import dbus
from servicetest import unwrap, assertContains, EventProtocolClientFactory,\
- EventProtocolFactory, assertEquals, EventProtocol
+ EventProtocolFactory, assertEquals, EventProtocol, EventPattern
from gabbletest import exec_test
import constants as cs
import bytestream
+import ns
from twisted.internet import reactor
from twisted.internet.protocol import Factory, Protocol
@@ -289,6 +290,29 @@ def check_new_connection_access(q, access_control, access_control_param, protoco
else:
assert False
+
+def connect_to_cm_socket(q, to, address_type, address, access_control,
+ access_control_param):
+
+ connect_socket(q, address_type, address)
+
+ if access_control == cs.SOCKET_ACCESS_CONTROL_CREDENTIALS:
+ socket_event = q.expect('socket-connected')
+
+ # socket is connected. Let's send our credentials
+ socket_event.protocol.sendData(str(access_control_param))
+
+ # once credentials have been sent, Gabble sends SI request
+ si_event = q.expect('stream-iq', to=to, query_ns=ns.SI, query_name='si')
+
+ else:
+ socket_event, si_event = q.expect_many(
+ EventPattern('socket-connected'),
+ # expect SI request
+ EventPattern('stream-iq', to=to, query_ns=ns.SI, query_name='si'))
+
+ return socket_event, si_event
+
def exec_tube_test(test, *args):
for bytestream_cls in [
bytestream.BytestreamIBBMsg,
--
1.5.6.5
More information about the telepathy-commits
mailing list