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

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Natalia Bidart
Approved revision: 688
Merged at revision: 687
Proposed branch: lp:~alecu/ubuntu-sso-client/tx-unpack-toomany-1-2
Merge into: lp:ubuntu-sso-client/stable-1-2
Diff against target: 99 lines (+35/-4)
3 files modified
pylintrc (+2/-1)
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-1-2
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+57331@code.launchpad.net

Commit message

A new value was added the Secret DBus struct (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.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve
688. By Alejandro J. Cura

disable pylint warning W0404: Reimport of module

Revision history for this message
Natalia Bidart (nataliabidart) :
review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches