[Telepathy-commits] [telepathy-idle/master] Add test for invalid nicknames
Jonathon Jongsma
jonathon.jongsma at collabora.co.uk
Tue Feb 17 13:26:20 PST 2009
telepathy-idle should not blindly accept invalid nicknames -- it should do a
validity check on them and reject them if they're not valid IRC nicks. This
test does that. Fix will come soon.
---
tests/twisted/Makefile.am | 1 +
tests/twisted/connect/invalid-nick.py | 58 +++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/connect/invalid-nick.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 7b1d3b0..0c9bb05 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -3,6 +3,7 @@ TWISTED_TESTS = \
connect/connect-success-ssl.py \
connect/connect-fail.py \
connect/connect-fail-ssl.py \
+ connect/invalid-nick.py \
channels/join-muc-channel.py \
messages/message-order.py \
messages/leading-space.py \
diff --git a/tests/twisted/connect/invalid-nick.py b/tests/twisted/connect/invalid-nick.py
new file mode 100644
index 0000000..e79227a
--- /dev/null
+++ b/tests/twisted/connect/invalid-nick.py
@@ -0,0 +1,58 @@
+# coding: utf-8
+"""
+Test that we get an error when attempting to use an invalid nick
+"""
+
+import dbus
+
+def make_connection(nick):
+ bus = dbus.SessionBus()
+ params = {
+ 'account': nick,
+ 'server': 'localhost',
+ 'password': '',
+ 'fullname': 'Test User',
+ 'charset': 'UTF-8',
+ 'quit-message': 'happy testing...',
+ 'use-ssl': dbus.Boolean(False),
+ 'port': dbus.UInt32(6900),
+ }
+
+ cm = bus.get_object(
+ 'org.freedesktop.Telepathy.ConnectionManager.idle',
+ '/org/freedesktop/Telepathy/ConnectionManager/idle')
+ cm_iface = dbus.Interface(cm, 'org.freedesktop.Telepathy.ConnectionManager')
+
+ connection_name, connection_path = cm_iface.RequestConnection(
+ 'irc', params)
+
+def test():
+ try:
+ make_connection('nick with spaces')
+ raise RuntimeError('Invalid nick not rejected')
+ except dbus.DBusException, e:
+ pass # nick rejected properly with an error
+
+ try:
+ make_connection('') # empty nick
+ raise RuntimeError('Invalid nick not rejected')
+ except dbus.DBusException, e:
+ pass # nick rejected properly with an error
+
+ try:
+ make_connection('#foo') # invalid chars
+ raise RuntimeError('Invalid nick not rejected')
+ except dbus.DBusException, e:
+ pass # nick rejected properly with an error
+
+ try:
+ make_connection(u'ê¹ì ì') # unicode
+ raise RuntimeError('Invalid nick not rejected')
+ except dbus.DBusException, e:
+ pass # nick rejected properly with an error
+
+ # should pass succeed without an exception
+ make_connection('good_nick')
+
+if __name__ == '__main__':
+ test()
--
1.5.6.5
More information about the telepathy-commits
mailing list