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
=== modified file 'pylintrc'
--- pylintrc 2010-09-22 16:14:28 +0000
+++ pylintrc 2011-04-12 15:43:29 +0000
@@ -50,7 +50,8 @@
50# W0142: Used * or ** magic50# W0142: Used * or ** magic
51# W0613: Unused argument 'yyy'51# W0613: Unused argument 'yyy'
52# C0302: Too many lines in module52# C0302: Too many lines in module
53disable=R,I,W0142,W0613,C030253# W0404: Reimport of module
54disable=R,I,W0142,W0613,C0302,W0404
5455
5556
56[REPORTS]57[REPORTS]
5758
=== modified file 'ubuntu_sso/utils/tests/test_txsecrets.py'
--- ubuntu_sso/utils/tests/test_txsecrets.py 2011-02-03 13:55:02 +0000
+++ ubuntu_sso/utils/tests/test_txsecrets.py 2011-04-12 15:43:29 +0000
@@ -40,6 +40,7 @@
40PROMPT_BASE_PATH = "/org/freedesktop/secrets/prompt"40PROMPT_BASE_PATH = "/org/freedesktop/secrets/prompt"
41SESSION_BASE_PATH = "/org/freedesktop/secrets/session"41SESSION_BASE_PATH = "/org/freedesktop/secrets/session"
42COLLECTION_BASE_PATH = "/org/freedesktop/secrets/collection/"42COLLECTION_BASE_PATH = "/org/freedesktop/secrets/collection/"
43SAMPLE_CONTENT_TYPE = "text/plain; charset=utf8"
4344
4445
45class SampleMiscException(Exception):46class SampleMiscException(Exception):
@@ -95,6 +96,18 @@
95 return True96 return True
9697
9798
99class AltItemMock(ItemMock):
100 """The secret in this item has a content_type."""
101
102 @dbus.service.method(dbus_interface=txsecrets.ITEM_IFACE,
103 in_signature="o", out_signature="(oayays)")
104 def GetSecret(self, session):
105 """Retrieve the secret for this item."""
106 if self.get_secret_fail:
107 raise SampleMiscException()
108 return (session, "", self.value, SAMPLE_CONTENT_TYPE)
109
110
98class PromptMock(dbus.service.Object):111class PromptMock(dbus.service.Object):
99 """A prompt necessary to complete an operation."""112 """A prompt necessary to complete an operation."""
100113
@@ -126,6 +139,7 @@
126 create_item_fail = False139 create_item_fail = False
127 locked = False140 locked = False
128 unlock_prompts = False141 unlock_prompts = False
142 item_mock_class = ItemMock
129143
130 def __init__(self, label, *args, **kwargs):144 def __init__(self, label, *args, **kwargs):
131 """Initialize this instance."""145 """Initialize this instance."""
@@ -150,8 +164,8 @@
150 item_label = properties[txsecrets.LABEL_PROPERTY]164 item_label = properties[txsecrets.LABEL_PROPERTY]
151 session, parameters, value = secret165 session, parameters, value = secret
152 item_path = create_object_path(make_coll_path(self.label))166 item_path = create_object_path(make_coll_path(self.label))
153 item = self.dbus_publish(item_path, ItemMock, self, item_label,167 item = self.dbus_publish(item_path, self.item_mock_class, self,
154 attributes, value)168 item_label, attributes, value)
155 self.items.append(item)169 self.items.append(item)
156 if self.create_item_prompt:170 if self.create_item_prompt:
157 prompt_path = create_object_path(PROMPT_BASE_PATH)171 prompt_path = create_object_path(PROMPT_BASE_PATH)
@@ -746,6 +760,22 @@
746 self.assertEqual(value, sample_secret)760 self.assertEqual(value, sample_secret)
747761
748 @inlineCallbacks762 @inlineCallbacks
763 def test_get_value_four_items_per_secret(self):
764 """The code works fine when the secret dbus struct has 4 items."""
765 yield self.secretservice.open_session()
766 collection_label = "sample_keyring"
767 coll = yield self.create_sample_collection(collection_label)
768 mock_coll = self.mock_service.collections[collection_label]
769 mock_coll.item_mock_class = AltItemMock
770 attr = {"key-type": "Ubuntu SSO credentials"}
771 sample_secret = "secret83!"
772 yield coll.create_item("Cucaracha", attr, sample_secret)
773 items = yield self.secretservice.search_items(attr)
774 self.assertEqual(len(items), 1)
775 value = yield items[0].get_value()
776 self.assertEqual(value, sample_secret)
777
778 @inlineCallbacks
749 def test_get_value_throws_dbus_error(self):779 def test_get_value_throws_dbus_error(self):
750 """The secret value is not retrieved if DBus fails."""780 """The secret value is not retrieved if DBus fails."""
751 yield self.secretservice.open_session()781 yield self.secretservice.open_session()
752782
=== modified file 'ubuntu_sso/utils/txsecrets.py'
--- ubuntu_sso/utils/txsecrets.py 2011-02-03 13:55:02 +0000
+++ ubuntu_sso/utils/txsecrets.py 2011-04-12 15:43:29 +0000
@@ -316,7 +316,7 @@
316 def getsecret_handler(secret):316 def getsecret_handler(secret):
317 """The secret for this item was found."""317 """The secret for this item was found."""
318 # pylint: disable=W0612318 # pylint: disable=W0612
319 session, parameters, value = secret319 value = secret[2]
320 d.callback(value)320 d.callback(value)
321321
322 self.item_iface.GetSecret(self.service.session, byte_arrays=True,322 self.item_iface.GetSecret(self.service.session, byte_arrays=True,

Subscribers

People subscribed via source and target branches