summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-06-28 17:02:04 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-08-03 10:44:54 +0100
commit41689eb5bbdbaa33e88e891031f9e0baabed3e30 (patch)
treee1f1ad2b7c7fcc7e1686f552830b148e214ec628
parent2f9fc8b75d107137402db85ff9cd61b3d7506a45 (diff)
tests: stop using accounts.cfg and move to the gvariant account storage
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--tests/twisted/account-manager/avatar-persist.py41
-rw-r--r--tests/twisted/account-manager/avatar-refresh.py41
-rw-r--r--tests/twisted/account-manager/gvariant-accounts.py9
-rw-r--r--tests/twisted/account-manager/make-valid.py73
-rw-r--r--tests/twisted/accounts/README5
-rw-r--r--tests/twisted/crash-recovery/crash-recovery.py38
-rw-r--r--tests/twisted/dispatcher/create-at-startup.py37
7 files changed, 137 insertions, 107 deletions
diff --git a/tests/twisted/account-manager/avatar-persist.py b/tests/twisted/account-manager/avatar-persist.py
index 06ad65d8..e3496335 100644
--- a/tests/twisted/account-manager/avatar-persist.py
+++ b/tests/twisted/account-manager/avatar-persist.py
@@ -40,25 +40,28 @@ def preseed():
accounts_dir = os.environ['MC_ACCOUNT_DIR']
- accounts_cfg = open(accounts_dir + '/accounts.cfg', 'w')
- accounts_cfg.write("""# Telepathy accounts
-[%s]
-manager=fakecm
-protocol=fakeprotocol
-DisplayName=Work account
-NormalizedName=jc.denton@unatco.int
-param-account=jc.denton@unatco.int
-param-password=ionstorm
-Enabled=1
-ConnectAutomatically=1
-AutomaticPresenceType=2
-AutomaticPresenceStatus=available
-AutomaticPresenceMessage=My vision is augmented
-Nickname=JC
-AvatarMime=image/jpeg
-avatar_token=Deus Ex
-""" % account_id)
- accounts_cfg.close()
+ escaped = account_id.replace('/', '_')
+ filename = accounts_dir + '/' + escaped
+ account = open(filename, 'w')
+
+ account.write("""{
+'id': <'%s'>,
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Work account'>,
+'NormalizedName': <'jc.denton@unatco.int'>,
+'param-account': <'jc.denton@unatco.int'>,
+'param-password': <'ionstorm'>,
+'Enabled': <true>,
+'ConnectAutomatically': <true>,
+'AutomaticPresenceType': <2>,
+'AutomaticPresenceStatus': <'available'>,
+'AutomaticPresenceMessage': <'My vision is augmented'>,
+'Nickname': <'JC'>,
+'AvatarMime': <'image/jpeg'>,
+'avatar_token': <'Deus Ex'>
+}""" % account_id)
+ account.close()
os.makedirs(accounts_dir + '/' + account_id)
avatar_bin = open(accounts_dir + '/' + account_id + '/avatar.bin', 'w')
diff --git a/tests/twisted/account-manager/avatar-refresh.py b/tests/twisted/account-manager/avatar-refresh.py
index a93912eb..6792c4fa 100644
--- a/tests/twisted/account-manager/avatar-refresh.py
+++ b/tests/twisted/account-manager/avatar-refresh.py
@@ -40,25 +40,28 @@ def preseed():
accounts_dir = os.environ['MC_ACCOUNT_DIR']
- accounts_cfg = open(accounts_dir + '/accounts.cfg', 'w')
- accounts_cfg.write("""# Telepathy accounts
-[%s]
-manager=fakecm
-protocol=fakeprotocol
-DisplayName=Work account
-NormalizedName=jc.denton@unatco.int
-param-account=jc.denton@unatco.int
-param-password=ionstorm
-Enabled=1
-ConnectAutomatically=1
-AutomaticPresenceType=2
-AutomaticPresenceStatus=available
-AutomaticPresenceMessage=My vision is augmented
-Nickname=JC
-AvatarMime=image/jpeg
-avatar_token=Deus Ex
-""" % account_id)
- accounts_cfg.close()
+ escaped = account_id.replace('/', '_')
+ filename = accounts_dir + '/' + escaped
+ account = open(filename, 'w')
+
+ account.write("""{
+'id': <'%s'>,
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Work account'>,
+'NormalizedName': <'jc.denton@unatco.int'>,
+'param-account': <'jc.denton@unatco.int'>,
+'param-password': <'ionstorm'>,
+'Enabled': <true>,
+'ConnectAutomatically': <true>,
+'AutomaticPresenceType': <2>,
+'AutomaticPresenceStatus': <'available'>,
+'AutomaticPresenceMessage': <'My vision is augmented'>,
+'Nickname': <'JC'>,
+'AvatarMime': <'image/jpeg'>,
+'avatar_token': <'Deux Ex'>
+}""" % account_id)
+ account.close()
os.makedirs(accounts_dir + '/' + account_id)
avatar_bin = open(accounts_dir + '/' + account_id + '/avatar.bin', 'w')
diff --git a/tests/twisted/account-manager/gvariant-accounts.py b/tests/twisted/account-manager/gvariant-accounts.py
index 3f271be6..50c05cf7 100644
--- a/tests/twisted/account-manager/gvariant-accounts.py
+++ b/tests/twisted/account-manager/gvariant-accounts.py
@@ -44,9 +44,10 @@ def preseed():
'NormalizedName': <'jc.denton@unatco.int'>,
'param-account': <'jc.denton@unatco.int'>,
'param-password': <'ionstorm'>,
-'Enabled': <'true'>,
-'ConnectAutomatically': <'true'>,
-'AutomaticPresenceType': <'2'>,
+'Enabled': <true>,
+'ConnectAutomatically': <true>,
+'AutomaticPresenceType': <2>,
+'AutomaticPresenceStatus': <'available'>,
'AutomaticPresenceMessage': <'My vision is augmented'>,
'Nickname': <'JC'>,
'AvatarMime': <'image/jpeg'>,
@@ -84,7 +85,7 @@ def test(q, bus, unused):
assertEquals(expected_params, props['Parameters'])
assertEquals(True, props['Enabled'])
assertEquals(True, props['ConnectAutomatically'])
- assertEquals((cs.PRESENCE_TYPE_AVAILABLE, '', 'My vision is augmented'),
+ assertEquals((cs.PRESENCE_TYPE_AVAILABLE, 'available', 'My vision is augmented'),
props['AutomaticPresence'])
assertEquals('JC', props['Nickname'])
diff --git a/tests/twisted/account-manager/make-valid.py b/tests/twisted/account-manager/make-valid.py
index ee3ee98f..6023749d 100644
--- a/tests/twisted/account-manager/make-valid.py
+++ b/tests/twisted/account-manager/make-valid.py
@@ -41,37 +41,48 @@ def preseed():
accounts_dir = os.environ['MC_ACCOUNT_DIR']
# The passwords are missing, so the accounts can't connect yet.
- accounts_cfg = open(accounts_dir + '/accounts.cfg', 'w')
- accounts_cfg.write("""# Telepathy accounts
-[%s]
-manager=fakecm
-protocol=fakeprotocol
-DisplayName=Work account
-NormalizedName=jc.denton@unatco.int
-param-account=jc.denton@unatco.int
-Enabled=1
-ConnectAutomatically=1
-AutomaticPresenceType=2
-AutomaticPresenceStatus=available
-AutomaticPresenceMessage=My vision is augmented
-Nickname=JC
-AvatarMime=image/jpeg
-
-[%s]
-manager=fakecm
-protocol=fakeprotocol
-DisplayName=Personal account
-NormalizedName=jc.denton@example.com
-param-account=jc.denton@example.com
-Enabled=1
-ConnectAutomatically=0
-AutomaticPresenceType=2
-AutomaticPresenceStatus=available
-AutomaticPresenceMessage=My vision is augmented
-Nickname=JC
-AvatarMime=image/jpeg
-""" % (account1_id, account2_id))
- accounts_cfg.close()
+
+ escaped = account1_id.replace('/', '_')
+ filename = accounts_dir + '/' + escaped
+ account = open(filename, 'w')
+
+ account.write("""{
+'id': <'%s'>,
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Work account'>,
+'NormalizedName': <'jc.denton@unatco.int'>,
+'param-account': <'jc.denton@unatco.int'>,
+'Enabled': <true>,
+'ConnectAutomatically': <true>,
+'AutomaticPresenceType': <2>,
+'AutomaticPresenceStatus': <'available'>,
+'AutomaticPresenceMessage': <'My vision is augmented'>,
+'Nickname': <'JC'>,
+'AvatarMime': <'image/jpeg'>
+}""" % account1_id)
+ account.close()
+
+ escaped = account2_id.replace('/', '_')
+ filename = accounts_dir + '/' + escaped
+ account = open(filename, 'w')
+
+ account.write("""{
+'id': <'%s'>,
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Personal account'>,
+'NormalizedName': <'jc.denton@example.com'>,
+'param-account': <'jc.denton@example.com'>,
+'Enabled': <true>,
+'ConnectAutomatically': <false>,
+'AutomaticPresenceType': <2>,
+'AutomaticPresenceStatus': <'available'>,
+'AutomaticPresenceMessage': <'My vision is augmented'>,
+'Nickname': <'JC'>,
+'AvatarMime': <'image/jpeg'>
+}""" % account2_id)
+ account.close()
os.makedirs(accounts_dir + '/' + account1_id)
avatar_bin = open(accounts_dir + '/' + account1_id + '/avatar.bin', 'w')
diff --git a/tests/twisted/accounts/README b/tests/twisted/accounts/README
index 27bd48fd..c735ff05 100644
--- a/tests/twisted/accounts/README
+++ b/tests/twisted/accounts/README
@@ -1,3 +1,4 @@
-Directory for twisted test to write the accounts.cfg file. $MC_ACCOUNT_DIR is
-set to this directory in the twisted environment. accounts.cfg is deleted before running any test.
+Directory for twisted test to write account files to. $MC_ACCOUNT_DIR
+is set to this directory in the twisted environment. all accounts are
+deleted before running any test.
diff --git a/tests/twisted/crash-recovery/crash-recovery.py b/tests/twisted/crash-recovery/crash-recovery.py
index e189b850..0f831d4d 100644
--- a/tests/twisted/crash-recovery/crash-recovery.py
+++ b/tests/twisted/crash-recovery/crash-recovery.py
@@ -34,27 +34,33 @@ import constants as cs
def preseed():
accounts_dir = os.environ['MC_ACCOUNT_DIR']
- accounts_cfg = open(accounts_dir + '/accounts.cfg', 'w')
-
- accounts_cfg.write("""# Telepathy accounts
-[fakecm/fakeprotocol/jc_2edenton_40unatco_2eint]
-manager=fakecm
-protocol=fakeprotocol
-DisplayName=Work account
-NormalizedName=jc.denton@unatco.int
-param-account=jc.denton@unatco.int
-param-password=ionstorm
-Enabled=1
-""")
-
- accounts_cfg.close()
+ account_id = 'fakecm/fakeprotocol/jc_2edenton_40unatco_2eint'
+
+ escaped = account_id.replace('/', '_')
+ filename = accounts_dir + '/' + escaped
+ account = open(filename, 'w')
+
+ # 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.
+ account.write("""{
+'id': <'%s'>,
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Work account'>,
+'NormalizedName': <'jc.denton@unatco.int'>,
+'param-account': <'jc.denton@unatco.int'>,
+'param-password': <'ionstorm'>,
+'Enabled': <true>
+}""" % account_id)
+ account.close()
account_connections_file = open(accounts_dir + '/.mc_connections', 'w')
account_connections_file.write("%s\t%s\t%s\n" %
(cs.tp_path_prefix + '/Connection/fakecm/fakeprotocol/jc',
- cs.tp_name_prefix + '.Connection.fakecm.fakeprotocol.jc',
- 'fakecm/fakeprotocol/jc_2edenton_40unatco_2eint'))
+ cs.tp_name_prefix + '.Connection.fakecm.fakeprotocol.jc',
+ account_id))
def test(q, bus, unused):
text_fixed_properties = dbus.Dictionary({
diff --git a/tests/twisted/dispatcher/create-at-startup.py b/tests/twisted/dispatcher/create-at-startup.py
index c4e24765..8c1ff278 100644
--- a/tests/twisted/dispatcher/create-at-startup.py
+++ b/tests/twisted/dispatcher/create-at-startup.py
@@ -35,22 +35,27 @@ import constants as cs
def preseed():
accounts_dir = os.environ['MC_ACCOUNT_DIR']
- accounts_cfg = open(accounts_dir + '/accounts.cfg', 'w')
- accounts_cfg.write("""# Telepathy accounts
-[fakecm/fakeprotocol/jc_2edenton_40unatco_2eint]
-manager=fakecm
-protocol=fakeprotocol
-DisplayName=Work account
-NormalizedName=jc.denton@unatco.int
-param-account=jc.denton@unatco.int
-param-password=ionstorm
-Enabled=1
-ConnectAutomatically=0
-AutomaticPresenceType=2
-AutomaticPresenceStatus=available
-AutomaticPresenceMessage=
-""")
- accounts_cfg.close()
+ account_id = 'fakecm/fakeprotocol/jc_2edenton_40unatco_2eint'
+
+ escaped = account_id.replace('/', '_')
+ filename = accounts_dir + '/' + escaped
+ account = open(filename, 'w')
+
+ account.write("""{
+'id': <'%s'>,
+'manager': <'fakecm'>,
+'protocol': <'fakeprotocol'>,
+'DisplayName': <'Work account'>,
+'NormalizedName': <'jc.denton@unatco.int'>,
+'param-account': <'jc.denton@unatco.int'>,
+'param-password': <'ionstorm'>,
+'Enabled': <true>,
+'ConnectAutomatically': <false>,
+'AutomaticPresenceType': <2>,
+'AutomaticPresenceStatus': <'available'>,
+'AutomaticPresenceMessage': <''>
+}""" % account_id)
+ account.close()
account_connections_file = open(accounts_dir + '/.mc_connections', 'w')
account_connections_file.write("")