summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-06-16 12:01:40 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-06-16 12:01:40 +0100
commit4719e9a639e53f96699ccbd475f08b1d9d7c5e38 (patch)
tree6a38c878accc7f6c45233a1dfcc87fee1ae4ba99
parentd398ad3a7468d8e9950374735411ac9e7f49c532 (diff)
downloadtelepathy-mission-control-4719e9a639e53f96699ccbd475f08b1d9d7c5e38.tar.gz
Add code to a couple of existing tests to verify that serialization in key files is as intended
(Backported from master to not expect account storage to be diverted)
-rw-r--r--test/twisted/account-manager/auto-connect.py10
-rw-r--r--test/twisted/account-manager/update-parameters.py39
-rw-r--r--test/twisted/servicetest.py5
3 files changed, 45 insertions, 9 deletions
diff --git a/test/twisted/account-manager/auto-connect.py b/test/twisted/account-manager/auto-connect.py
index f0cb62c0..7be4be3c 100644
--- a/test/twisted/account-manager/auto-connect.py
+++ b/test/twisted/account-manager/auto-connect.py
@@ -41,14 +41,18 @@ def preseed():
accounts_dir = os.environ['MC_ACCOUNT_DIR']
accounts_cfg = open(accounts_dir + '/accounts.cfg', 'w')
- accounts_cfg.write("""# Telepathy accounts
+
+ # As a regression test for part of fd.o #28557, the password starts and
+ # ends with a double backslash, which is represented in the file as a
+ # quadruple backslash.
+ accounts_cfg.write(r"""# Telepathy accounts
[%s]
manager=fakecm
protocol=fakeprotocol
DisplayName=Work account
NormalizedName=jc.denton@unatco.int
param-account=jc.denton@unatco.int
-param-password=ionstorm
+param-password=\\\\ionstorm\\\\
Enabled=1
ConnectAutomatically=1
AutomaticPresenceType=2
@@ -72,7 +76,7 @@ def test(q, bus, unused):
expected_params = {
'account': 'jc.denton@unatco.int',
- 'password': 'ionstorm',
+ 'password': r'\\ionstorm\\',
}
mc = make_mc(bus, q.append)
diff --git a/test/twisted/account-manager/update-parameters.py b/test/twisted/account-manager/update-parameters.py
index 21f5fc46..6a70f10b 100644
--- a/test/twisted/account-manager/update-parameters.py
+++ b/test/twisted/account-manager/update-parameters.py
@@ -16,12 +16,14 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
-import dbus
+import os
+import time
+
import dbus
import dbus.service
from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
- call_async
+ call_async, assertEquals
from mctest import exec_test, SimulatedConnection, create_fakecm_account,\
SimulatedChannel
import constants as cs
@@ -96,9 +98,11 @@ def test(q, bus, mc):
assert properties.get('RequestedPresence') == requested_presence, \
properties.get('RequestedPresence')
- # Set some parameters
+ # Set some parameters. They include setting account to \\, as a regression
+ # test for part of fd.o #28557.
call_async(q, account, 'UpdateParameters',
{
+ 'account': r'\\',
'secret-mushroom': '/Amanita muscaria/',
'snakes': dbus.UInt32(42),
'com.example.Badgerable.Badgered': True,
@@ -118,7 +122,7 @@ def test(q, bus, mc):
path=account.object_path,
interface=cs.ACCOUNT, signal='AccountPropertyChanged',
args=[{'Parameters': {
- 'account': 'someguy@example.com',
+ 'account': r'\\',
'com.example.Badgerable.Badgered': True,
'password': 'secrecy',
'nickname': 'albinoblacksheep',
@@ -131,7 +135,7 @@ def test(q, bus, mc):
# on reconnection
not_yet = ret.value[0]
not_yet.sort()
- assert not_yet == ['secret-mushroom', 'snakes'], not_yet
+ assert not_yet == ['account', 'secret-mushroom', 'snakes'], not_yet
# Unset some parameters
call_async(q, account, 'UpdateParameters',
@@ -146,7 +150,7 @@ def test(q, bus, mc):
path=account.object_path,
interface=cs.ACCOUNT, signal='AccountPropertyChanged',
args=[{'Parameters': {
- 'account': 'someguy@example.com',
+ 'account': r'\\',
'password': 'secrecy',
'secret-mushroom': '/Amanita muscaria/',
'snakes': 42,
@@ -162,5 +166,28 @@ def test(q, bus, mc):
not_yet.sort()
assert not_yet == ['com.example.Badgerable.Badgered', 'nickname'], not_yet
+ accounts_dir = os.environ['MC_ACCOUNT_DIR']
+
+ # fd.o #28557: when the file has been updated, the account parameter
+ # has its two backslashes doubled to 4 (because of the .desktop encoding),
+ # but they are not doubled again.
+ i = 0
+ updated = False
+ while i < 500:
+
+ for line in open(accounts_dir + '/accounts.cfg', 'r'):
+ if line.startswith('param-account=') and '\\' in line:
+ assertEquals(r'param-account=\\\\' + '\n', line)
+ updated = True
+
+ if updated:
+ break
+
+ # just to not busy-wait
+ time.sleep(0.1)
+ i += 1
+
+ assert updated
+
if __name__ == '__main__':
exec_test(test, {})
diff --git a/test/twisted/servicetest.py b/test/twisted/servicetest.py
index ee32efcc..61259c07 100644
--- a/test/twisted/servicetest.py
+++ b/test/twisted/servicetest.py
@@ -476,6 +476,11 @@ class EventProtocolFactory(Factory):
class EventProtocolClientFactory(EventProtocolFactory, ClientFactory):
pass
+def assertEquals(expected, value):
+ if expected != value:
+ raise AssertionError(
+ "expected:\n%s\ngot:\n%s" % (pretty(expected), pretty(value)))
+
if __name__ == '__main__':
unittest.main()