Merge lp:~alecu/ubuntu-sso-client/tx-unpack-toomany into lp:ubuntu-sso-client

Proposed by Alejandro J. Cura on 2011-04-12
Status: Merged
Approved by: Alejandro J. Cura on 2011-04-12
Approved revision: 698
Merged at revision: 699
Proposed branch: lp:~alecu/ubuntu-sso-client/tx-unpack-toomany
Merge into: lp:ubuntu-sso-client
Diff against target: 85 lines (+33/-3)
2 files modified
ubuntu_sso/utils/tests/test_txsecrets.py (+32/-2)
ubuntu_sso/utils/txsecrets.py (+1/-1)
To merge this branch: bzr merge lp:~alecu/ubuntu-sso-client/tx-unpack-toomany
Reviewer Review Type Date Requested Status
Natalia Bidart Approve on 2011-04-12
Roberto Alsina (community) 2011-04-12 Approve on 2011-04-12
Review via email: mp+57330@code.launchpad.net

Commit message

A new value was added the Secret DBus struct, let's handle it (LP: #734671).

Description of the change

A new value was added the Secret DBus struct (LP: #734671)

To post a comment you must log in.
Roberto Alsina (ralsina) wrote :

+1

review: Approve
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/utils/tests/test_txsecrets.py'
2--- ubuntu_sso/utils/tests/test_txsecrets.py 2011-02-03 13:55:02 +0000
3+++ ubuntu_sso/utils/tests/test_txsecrets.py 2011-04-12 14:35:48 +0000
4@@ -40,6 +40,7 @@
5 PROMPT_BASE_PATH = "/org/freedesktop/secrets/prompt"
6 SESSION_BASE_PATH = "/org/freedesktop/secrets/session"
7 COLLECTION_BASE_PATH = "/org/freedesktop/secrets/collection/"
8+SAMPLE_CONTENT_TYPE = "text/plain; charset=utf8"
9
10
11 class SampleMiscException(Exception):
12@@ -95,6 +96,18 @@
13 return True
14
15
16+class AltItemMock(ItemMock):
17+ """The secret in this item has a content_type."""
18+
19+ @dbus.service.method(dbus_interface=txsecrets.ITEM_IFACE,
20+ in_signature="o", out_signature="(oayays)")
21+ def GetSecret(self, session):
22+ """Retrieve the secret for this item."""
23+ if self.get_secret_fail:
24+ raise SampleMiscException()
25+ return (session, "", self.value, SAMPLE_CONTENT_TYPE)
26+
27+
28 class PromptMock(dbus.service.Object):
29 """A prompt necessary to complete an operation."""
30
31@@ -126,6 +139,7 @@
32 create_item_fail = False
33 locked = False
34 unlock_prompts = False
35+ item_mock_class = ItemMock
36
37 def __init__(self, label, *args, **kwargs):
38 """Initialize this instance."""
39@@ -150,8 +164,8 @@
40 item_label = properties[txsecrets.LABEL_PROPERTY]
41 session, parameters, value = secret
42 item_path = create_object_path(make_coll_path(self.label))
43- item = self.dbus_publish(item_path, ItemMock, self, item_label,
44- attributes, value)
45+ item = self.dbus_publish(item_path, self.item_mock_class, self,
46+ item_label, attributes, value)
47 self.items.append(item)
48 if self.create_item_prompt:
49 prompt_path = create_object_path(PROMPT_BASE_PATH)
50@@ -746,6 +760,22 @@
51 self.assertEqual(value, sample_secret)
52
53 @inlineCallbacks
54+ def test_get_value_four_items_per_secret(self):
55+ """The code works fine when the secret dbus struct has 4 items."""
56+ yield self.secretservice.open_session()
57+ collection_label = "sample_keyring"
58+ coll = yield self.create_sample_collection(collection_label)
59+ mock_coll = self.mock_service.collections[collection_label]
60+ mock_coll.item_mock_class = AltItemMock
61+ attr = {"key-type": "Ubuntu SSO credentials"}
62+ sample_secret = "secret83!"
63+ yield coll.create_item("Cucaracha", attr, sample_secret)
64+ items = yield self.secretservice.search_items(attr)
65+ self.assertEqual(len(items), 1)
66+ value = yield items[0].get_value()
67+ self.assertEqual(value, sample_secret)
68+
69+ @inlineCallbacks
70 def test_get_value_throws_dbus_error(self):
71 """The secret value is not retrieved if DBus fails."""
72 yield self.secretservice.open_session()
73
74=== modified file 'ubuntu_sso/utils/txsecrets.py'
75--- ubuntu_sso/utils/txsecrets.py 2011-02-03 13:55:02 +0000
76+++ ubuntu_sso/utils/txsecrets.py 2011-04-12 14:35:48 +0000
77@@ -316,7 +316,7 @@
78 def getsecret_handler(secret):
79 """The secret for this item was found."""
80 # pylint: disable=W0612
81- session, parameters, value = secret
82+ value = secret[2]
83 d.callback(value)
84
85 self.item_iface.GetSecret(self.service.session, byte_arrays=True,

Subscribers

People subscribed via source and target branches