Merge lp:~nataliabidart/ubuntu/maverick/ubuntu-sso-client/ubuntu-sso-client-0.99.1 into lp:ubuntu/maverick/ubuntu-sso-client
- Maverick (10.10)
- ubuntu-sso-client-0.99.1
- Merge into maverick
Proposed by
Natalia Bidart
Status: | Merged |
---|---|
Merged at revision: | 5 |
Proposed branch: | lp:~nataliabidart/ubuntu/maverick/ubuntu-sso-client/ubuntu-sso-client-0.99.1 |
Merge into: | lp:ubuntu/maverick/ubuntu-sso-client |
Diff against target: |
725 lines (+321/-154) 12 files modified
PKG-INFO (+1/-1) bin/ubuntu-sso-login-gui (+2/-2) data/ui.glade (+2/-0) debian/changelog (+10/-0) debian/control (+1/-1) run-tests (+5/-3) setup.py (+1/-1) ubuntu_sso/gui.py (+38/-23) ubuntu_sso/keyring.py (+112/-111) ubuntu_sso/main.py (+4/-4) ubuntu_sso/tests/test_gui.py (+30/-8) ubuntu_sso/tests/test_keyring.py (+115/-0) |
To merge this branch: | bzr merge lp:~nataliabidart/ubuntu/maverick/ubuntu-sso-client/ubuntu-sso-client-0.99.1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu branches | Pending | ||
Review via email: mp+33134@code.launchpad.net |
Commit message
Description of the change
Critical bug fixes for v0.99.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'PKG-INFO' | |||
2 | --- PKG-INFO 2010-08-12 00:00:08 +0000 | |||
3 | +++ PKG-INFO 2010-08-19 17:58:43 +0000 | |||
4 | @@ -1,6 +1,6 @@ | |||
5 | 1 | Metadata-Version: 1.0 | 1 | Metadata-Version: 1.0 |
6 | 2 | Name: ubuntu-sso-client | 2 | Name: ubuntu-sso-client |
8 | 3 | Version: 0.99 | 3 | Version: 0.99.1 |
9 | 4 | Summary: Ubuntu Single Sign-On client | 4 | Summary: Ubuntu Single Sign-On client |
10 | 5 | Home-page: https://launchpad.net/ubuntu-sso-client | 5 | Home-page: https://launchpad.net/ubuntu-sso-client |
11 | 6 | Author: Natalia Bidart | 6 | Author: Natalia Bidart |
12 | 7 | 7 | ||
13 | === modified file 'bin/ubuntu-sso-login-gui' | |||
14 | --- bin/ubuntu-sso-login-gui 2010-08-12 00:00:08 +0000 | |||
15 | +++ bin/ubuntu-sso-login-gui 2010-08-19 17:58:43 +0000 | |||
16 | @@ -25,8 +25,8 @@ | |||
17 | 25 | from ubuntu_sso.gui import UbuntuSSOClientGUI | 25 | from ubuntu_sso.gui import UbuntuSSOClientGUI |
18 | 26 | 26 | ||
19 | 27 | 27 | ||
22 | 28 | APP_NAME = 'Super Testing App' | 28 | APP_NAME = 'Ubuntu' |
23 | 29 | TC_URI = 'http://ubuntu.com' | 29 | TC_URI = 'http://one.ubuntu.com/terms' |
24 | 30 | HELP_TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \ | 30 | HELP_TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \ |
25 | 31 | 'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit ' \ | 31 | 'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit ' \ |
26 | 32 | 'pulvinar tempus ut augue.' | 32 | 'pulvinar tempus ut augue.' |
27 | 33 | 33 | ||
28 | === modified file 'data/ui.glade' | |||
29 | --- data/ui.glade 2010-08-12 00:00:08 +0000 | |||
30 | +++ data/ui.glade 2010-08-19 17:58:43 +0000 | |||
31 | @@ -349,6 +349,8 @@ | |||
32 | 349 | </object> | 349 | </object> |
33 | 350 | <object class="GtkVBox" id="tc_browser_vbox"> | 350 | <object class="GtkVBox" id="tc_browser_vbox"> |
34 | 351 | <property name="visible">True</property> | 351 | <property name="visible">True</property> |
35 | 352 | <signal name="hide" handler="on_tc_browser_vbox_hide"/> | ||
36 | 353 | <signal name="show" handler="on_tc_browser_vbox_show"/> | ||
37 | 352 | <child> | 354 | <child> |
38 | 353 | <object class="GtkScrolledWindow" id="tc_browser_window"> | 355 | <object class="GtkScrolledWindow" id="tc_browser_window"> |
39 | 354 | <property name="visible">True</property> | 356 | <property name="visible">True</property> |
40 | 355 | 357 | ||
41 | === modified file 'debian/changelog' | |||
42 | --- debian/changelog 2010-08-12 09:38:17 +0000 | |||
43 | +++ debian/changelog 2010-08-19 17:58:43 +0000 | |||
44 | @@ -1,3 +1,13 @@ | |||
45 | 1 | ubuntu-sso-client (0.99.1-0ubuntu1) UNRELEASED; urgency=low | ||
46 | 2 | |||
47 | 3 | * New upstream release: | ||
48 | 4 | - Delayed opening the webkit browser to the latest possible. (LP: #617041) | ||
49 | 5 | (nataliabidart) | ||
50 | 6 | - Use a proper dictionary with different attributes for each key so old | ||
51 | 7 | keys are not overwritten nor deleted. (LP: #617347) (alecu) | ||
52 | 8 | |||
53 | 9 | -- Natalia Bidart (nessita) <nataliabidart@gmail.com> Thu, 19 Aug 2010 13:02:10 -0300 | ||
54 | 10 | |||
55 | 1 | ubuntu-sso-client (0.99-0ubuntu1) maverick; urgency=low | 11 | ubuntu-sso-client (0.99-0ubuntu1) maverick; urgency=low |
56 | 2 | 12 | ||
57 | 3 | * New upstream release. | 13 | * New upstream release. |
58 | 4 | 14 | ||
59 | === modified file 'debian/control' | |||
60 | --- debian/control 2010-08-11 16:18:28 +0000 | |||
61 | +++ debian/control 2010-08-19 17:58:43 +0000 | |||
62 | @@ -7,7 +7,7 @@ | |||
63 | 7 | python-support (>= 0.6.4), | 7 | python-support (>= 0.6.4), |
64 | 8 | python-distutils-extra (>= 2.10) | 8 | python-distutils-extra (>= 2.10) |
65 | 9 | Maintainer: Natalia Bidart <natalia.bidart@canonical.com> | 9 | Maintainer: Natalia Bidart <natalia.bidart@canonical.com> |
67 | 10 | Standards-Version: 3.8.4 | 10 | Standards-Version: 3.9.1 |
68 | 11 | XS-Python-Version: current | 11 | XS-Python-Version: current |
69 | 12 | 12 | ||
70 | 13 | Package: ubuntu-sso-client | 13 | Package: ubuntu-sso-client |
71 | 14 | 14 | ||
72 | === modified file 'run-tests' | |||
73 | --- run-tests 2010-08-11 17:03:11 +0000 | |||
74 | +++ run-tests 2010-08-19 17:58:43 +0000 | |||
75 | @@ -18,9 +18,11 @@ | |||
76 | 18 | `which xvfb-run` ./contrib/test $@ | 18 | `which xvfb-run` ./contrib/test $@ |
77 | 19 | pyflakes bin ubuntu_sso | 19 | pyflakes bin ubuntu_sso |
78 | 20 | if [ -x `which pep8` ]; then | 20 | if [ -x `which pep8` ]; then |
81 | 21 | pep8 --repeat bin ubuntu_sso/gui.py ubuntu_sso/main.py \ | 21 | pep8 --repeat bin/ contrib/ \ |
82 | 22 | ubuntu_sso/tests/test_gui.py ubuntu_sso/tests/test_main.py contrib/ | 22 | ubuntu_sso/gui.py ubuntu_sso/main.py ubuntu_sso/keyring.py \ |
83 | 23 | ubuntu_sso/tests/test_gui.py ubuntu_sso/tests/test_main.py \ | ||
84 | 24 | ubuntu_sso/tests/test_keyring.py | ||
85 | 23 | else | 25 | else |
86 | 24 | echo "Please install the 'pep8' package." | 26 | echo "Please install the 'pep8' package." |
87 | 25 | fi | 27 | fi |
88 | 26 | rm -rf _trial_temp/ | ||
89 | 27 | \ No newline at end of file | 28 | \ No newline at end of file |
90 | 29 | rm -rf _trial_temp/ | ||
91 | 28 | 30 | ||
92 | === modified file 'setup.py' | |||
93 | --- setup.py 2010-08-12 00:00:08 +0000 | |||
94 | +++ setup.py 2010-08-19 17:58:43 +0000 | |||
95 | @@ -72,7 +72,7 @@ | |||
96 | 72 | 72 | ||
97 | 73 | setup( | 73 | setup( |
98 | 74 | name='ubuntu-sso-client', | 74 | name='ubuntu-sso-client', |
100 | 75 | version='0.99', | 75 | version='0.99.1', |
101 | 76 | license='GPL v3', | 76 | license='GPL v3', |
102 | 77 | author='Natalia Bidart', | 77 | author='Natalia Bidart', |
103 | 78 | author_email='natalia.bidart@canonical.com', | 78 | author_email='natalia.bidart@canonical.com', |
104 | 79 | 79 | ||
105 | === modified file 'ubuntu_sso/gui.py' | |||
106 | --- ubuntu_sso/gui.py 2010-08-12 00:00:08 +0000 | |||
107 | +++ ubuntu_sso/gui.py 2010-08-19 17:58:43 +0000 | |||
108 | @@ -153,8 +153,8 @@ | |||
109 | 153 | """Ubuntu single sign on GUI.""" | 153 | """Ubuntu single sign on GUI.""" |
110 | 154 | 154 | ||
111 | 155 | CAPTCHA_SOLUTION_ENTRY = _('Type the characters above') | 155 | CAPTCHA_SOLUTION_ENTRY = _('Type the characters above') |
114 | 156 | CONNECT_HELP_LABEL = _('To connect this computer to') + ' %s ' + \ | 156 | CONNECT_HELP_LABEL = _('To connect this computer to %(app_name)s ' \ |
115 | 157 | _('enter your details below.') | 157 | 'enter your details below.') |
116 | 158 | EMAIL1_ENTRY = _('Email address') | 158 | EMAIL1_ENTRY = _('Email address') |
117 | 159 | EMAIL2_ENTRY = _('Re-type Email address') | 159 | EMAIL2_ENTRY = _('Re-type Email address') |
118 | 160 | EMAIL_MISMATCH = _('The email addresses don\'t match, please double check ' | 160 | EMAIL_MISMATCH = _('The email addresses don\'t match, please double check ' |
119 | @@ -163,11 +163,11 @@ | |||
120 | 163 | EMAIL_TOKEN_ENTRY = _('Enter code verification here') | 163 | EMAIL_TOKEN_ENTRY = _('Enter code verification here') |
121 | 164 | FIELD_REQUIRED = _('This field is required.') | 164 | FIELD_REQUIRED = _('This field is required.') |
122 | 165 | FORGOTTEN_PASSWORD_BUTTON = _('I\'ve forgotten my password') | 165 | FORGOTTEN_PASSWORD_BUTTON = _('I\'ve forgotten my password') |
124 | 166 | JOIN_HEADER_LABEL = _('Create') + ' %s ' + _('account') | 166 | JOIN_HEADER_LABEL = _('Create %(app_name)s account') |
125 | 167 | LOADING = _('Loading...') | 167 | LOADING = _('Loading...') |
126 | 168 | LOGIN_BUTTON_LABEL = _('Already have an account? Click here to sign in') | 168 | LOGIN_BUTTON_LABEL = _('Already have an account? Click here to sign in') |
127 | 169 | LOGIN_EMAIL_ENTRY = _('Email address') | 169 | LOGIN_EMAIL_ENTRY = _('Email address') |
129 | 170 | LOGIN_HEADER_LABEL = _('Connect to') + ' %s' | 170 | LOGIN_HEADER_LABEL = _('Connect to %(app_name)s') |
130 | 171 | LOGIN_PASSWORD_ENTRY = _('Password') | 171 | LOGIN_PASSWORD_ENTRY = _('Password') |
131 | 172 | NAME_ENTRY = _('Name') | 172 | NAME_ENTRY = _('Name') |
132 | 173 | NEXT = _('Next') | 173 | NEXT = _('Next') |
133 | @@ -185,9 +185,9 @@ | |||
134 | 185 | RESET_PASSWORD = _('Reset Password') | 185 | RESET_PASSWORD = _('Reset Password') |
135 | 186 | RESET_CODE_ENTRY = _('Reset code') | 186 | RESET_CODE_ENTRY = _('Reset code') |
136 | 187 | RESET_EMAIL_ENTRY = _('Email address') | 187 | RESET_EMAIL_ENTRY = _('Email address') |
140 | 188 | SET_NEW_PASSWORD_LABEL = _('A password reset code has been sent to %s.\n' \ | 188 | SET_NEW_PASSWORD_LABEL = _('A password reset code has been sent to ' \ |
141 | 189 | 'Please enter the code below along with your ' \ | 189 | '%(email)s.\nPlease enter the code below ' \ |
142 | 190 | 'new password.') | 190 | 'along with your new password.') |
143 | 191 | SUCCESS = _('The process finished successfully. Congratulations!') | 191 | SUCCESS = _('The process finished successfully. Congratulations!') |
144 | 192 | TC = _('Terms & Conditions') | 192 | TC = _('Terms & Conditions') |
145 | 193 | TC_NOT_ACCEPTED = _('Agreeing to the Ubuntu One Terms & Conditions is ' | 193 | TC_NOT_ACCEPTED = _('Agreeing to the Ubuntu One Terms & Conditions is ' |
146 | @@ -198,8 +198,8 @@ | |||
147 | 198 | 198 | ||
148 | 199 | A verification code has just been sent to your email address. | 199 | A verification code has just been sent to your email address. |
149 | 200 | Please enter your code from the email. An example is shown below.""") | 200 | Please enter your code from the email. An example is shown below.""") |
152 | 201 | YES_TO_TC = _('I agree with the') | 201 | YES_TO_TC = _('I agree with the %(app_name)s ') # Terms&Conditions button |
153 | 202 | YES_TO_UPDATES = _('Yes! Email me tips and updates.') | 202 | YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.') |
154 | 203 | 203 | ||
155 | 204 | def __init__(self, app_name, tc_uri, help_text, | 204 | def __init__(self, app_name, tc_uri, help_text, |
156 | 205 | window_id=0, login_only=False, close_callback=None): | 205 | window_id=0, login_only=False, close_callback=None): |
157 | @@ -211,7 +211,7 @@ | |||
158 | 211 | self._signals_receivers = {} | 211 | self._signals_receivers = {} |
159 | 212 | 212 | ||
160 | 213 | self.app_name = app_name | 213 | self.app_name = app_name |
162 | 214 | self.app_label = '<b>%s</b>' % app_name | 214 | self.app_label = '<b>%s</b>' % self.app_name |
163 | 215 | self.tc_uri = tc_uri | 215 | self.tc_uri = tc_uri |
164 | 216 | self.help_text = help_text | 216 | self.help_text = help_text |
165 | 217 | self.close_callback = close_callback | 217 | self.close_callback = close_callback |
166 | @@ -437,8 +437,8 @@ | |||
167 | 437 | 437 | ||
168 | 438 | def _build_enter_details_page(self): | 438 | def _build_enter_details_page(self): |
169 | 439 | """Build the enter details page.""" | 439 | """Build the enter details page.""" |
172 | 440 | self.enter_details_vbox.header = (self.JOIN_HEADER_LABEL % | 440 | d = {'app_name': self.app_label} |
173 | 441 | self.app_label) | 441 | self.enter_details_vbox.header = self.JOIN_HEADER_LABEL % d |
174 | 442 | self.enter_details_vbox.help_text = self.help_text | 442 | self.enter_details_vbox.help_text = self.help_text |
175 | 443 | 443 | ||
176 | 444 | self.enter_details_vbox.pack_start(self.name_entry, expand=False) | 444 | self.enter_details_vbox.pack_start(self.name_entry, expand=False) |
177 | @@ -461,8 +461,10 @@ | |||
178 | 461 | else: | 461 | else: |
179 | 462 | self._set_captcha_image() | 462 | self._set_captcha_image() |
180 | 463 | 463 | ||
183 | 464 | self.yes_to_updates_checkbutton.set_label(self.YES_TO_UPDATES) | 464 | msg = self.YES_TO_UPDATES % {'app_name': self.app_name} |
184 | 465 | self.yes_to_tc_checkbutton.set_label(self.YES_TO_TC) | 465 | self.yes_to_updates_checkbutton.set_label(msg) |
185 | 466 | msg = self.YES_TO_TC % {'app_name': self.app_name} | ||
186 | 467 | self.yes_to_tc_checkbutton.set_label(msg) | ||
187 | 466 | self.tc_button.set_label(self.TC) | 468 | self.tc_button.set_label(self.TC) |
188 | 467 | self.login_button.set_label(self.LOGIN_BUTTON_LABEL) | 469 | self.login_button.set_label(self.LOGIN_BUTTON_LABEL) |
189 | 468 | 470 | ||
190 | @@ -476,11 +478,6 @@ | |||
191 | 476 | 478 | ||
192 | 477 | def _build_tc_page(self): | 479 | def _build_tc_page(self): |
193 | 478 | """Build the Terms & Conditions page.""" | 480 | """Build the Terms & Conditions page.""" |
194 | 479 | self.tc_browser = webkit.WebView() | ||
195 | 480 | self.tc_browser.open(self.tc_uri) | ||
196 | 481 | self.tc_browser.show() | ||
197 | 482 | self.tc_browser_window.add(self.tc_browser) | ||
198 | 483 | |||
199 | 484 | return self.tc_browser_vbox | 481 | return self.tc_browser_vbox |
200 | 485 | 482 | ||
201 | 486 | def _build_processing_page(self): | 483 | def _build_processing_page(self): |
202 | @@ -510,8 +507,9 @@ | |||
203 | 510 | 507 | ||
204 | 511 | def _build_login_page(self): | 508 | def _build_login_page(self): |
205 | 512 | """Build the login page.""" | 509 | """Build the login page.""" |
208 | 513 | self.login_vbox.header = self.LOGIN_HEADER_LABEL % self.app_label | 510 | d = {'app_name': self.app_label} |
209 | 514 | self.login_vbox.help_text = self.CONNECT_HELP_LABEL % self.app_label | 511 | self.login_vbox.header = self.LOGIN_HEADER_LABEL % d |
210 | 512 | self.login_vbox.help_text = self.CONNECT_HELP_LABEL % d | ||
211 | 515 | 513 | ||
212 | 516 | self.login_details_vbox.pack_start(self.login_email_entry) | 514 | self.login_details_vbox.pack_start(self.login_email_entry) |
213 | 517 | self.login_details_vbox.reorder_child(self.login_email_entry, 0) | 515 | self.login_details_vbox.reorder_child(self.login_email_entry, 0) |
214 | @@ -777,6 +775,22 @@ | |||
215 | 777 | 775 | ||
216 | 778 | self._set_current_page(self.processing_vbox) | 776 | self._set_current_page(self.processing_vbox) |
217 | 779 | 777 | ||
218 | 778 | def on_tc_browser_vbox_show(self, *args, **kwargs): | ||
219 | 779 | """The T&C page is being shown.""" | ||
220 | 780 | browser = webkit.WebView() | ||
221 | 781 | browser.open(self.tc_uri) | ||
222 | 782 | browser.show() | ||
223 | 783 | self.tc_browser_window.add(browser) | ||
224 | 784 | |||
225 | 785 | def on_tc_browser_vbox_hide(self, *args, **kwargs): | ||
226 | 786 | """The T&C page is no longer being shown.""" | ||
227 | 787 | children = self.tc_browser_window.get_children() | ||
228 | 788 | if len(children) > 0: | ||
229 | 789 | browser = children[0] | ||
230 | 790 | self.tc_browser_window.remove(browser) | ||
231 | 791 | browser.destroy() | ||
232 | 792 | del browser | ||
233 | 793 | |||
234 | 780 | # backend callbacks | 794 | # backend callbacks |
235 | 781 | 795 | ||
236 | 782 | def on_captcha_generated(self, captcha_id, *args, **kwargs): | 796 | def on_captcha_generated(self, captcha_id, *args, **kwargs): |
237 | @@ -836,8 +850,9 @@ | |||
238 | 836 | 850 | ||
239 | 837 | def on_password_reset_token_sent(self, email, *args, **kwargs): | 851 | def on_password_reset_token_sent(self, email, *args, **kwargs): |
240 | 838 | """Password reset token was successfully sent.""" | 852 | """Password reset token was successfully sent.""" |
243 | 839 | e = self.reset_email_entry.get_text() | 853 | email = self.reset_email_entry.get_text() |
244 | 840 | self.set_new_password_vbox.help_text = self.SET_NEW_PASSWORD_LABEL % e | 854 | msg = self.SET_NEW_PASSWORD_LABEL % {'email': email} |
245 | 855 | self.set_new_password_vbox.help_text = msg | ||
246 | 841 | self._set_current_page(self.set_new_password_vbox) | 856 | self._set_current_page(self.set_new_password_vbox) |
247 | 842 | 857 | ||
248 | 843 | def on_password_reset_error(self, *args, **kwargs): | 858 | def on_password_reset_error(self, *args, **kwargs): |
249 | 844 | 859 | ||
250 | === modified file 'ubuntu_sso/keyring.py' | |||
251 | --- ubuntu_sso/keyring.py 2010-08-11 17:03:11 +0000 | |||
252 | +++ ubuntu_sso/keyring.py 2010-08-19 17:58:43 +0000 | |||
253 | @@ -1,111 +1,112 @@ | |||
365 | 1 | # Copyright (C) 2010 Canonical | 1 | # Copyright (C) 2010 Canonical |
366 | 2 | # | 2 | # |
367 | 3 | # Authors: | 3 | # Authors: |
368 | 4 | # Andrew Higginson | 4 | # Andrew Higginson |
369 | 5 | # | 5 | # Alejandro J. Cura <alecu@canonical.com> |
370 | 6 | # This program is free software; you can redistribute it and/or modify it under | 6 | # |
371 | 7 | # the terms of the GNU General Public License as published by the Free Software | 7 | # This program is free software; you can redistribute it and/or modify it under |
372 | 8 | # Foundation; version 3. | 8 | # the terms of the GNU General Public License as published by the Free Software |
373 | 9 | # | 9 | # Foundation; version 3. |
374 | 10 | # This program is distributed in the hope that it will be useful, but WITHOUT | 10 | # |
375 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 11 | # This program is distributed in the hope that it will be useful, but WITHOUT |
376 | 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
377 | 13 | # details. | 13 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
378 | 14 | # | 14 | # details. |
379 | 15 | # You should have received a copy of the GNU General Public License along with | 15 | # |
380 | 16 | # this program; if not, write to the Free Software Foundation, Inc., | 16 | # You should have received a copy of the GNU General Public License along with |
381 | 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | # this program; if not, write to the Free Software Foundation, Inc., |
382 | 18 | 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
383 | 19 | import gnomekeyring | 19 | |
384 | 20 | 20 | """Handle keys in the gnome kerying.""" | |
385 | 21 | from urllib import urlencode | 21 | |
386 | 22 | from urlparse import parse_qsl | 22 | import gnomekeyring |
387 | 23 | 23 | ||
388 | 24 | class Keyring(object): | 24 | from urllib import urlencode |
389 | 25 | 25 | from urlparse import parse_qsl | |
390 | 26 | KEYRING_NAME = "login" | 26 | |
391 | 27 | 27 | ||
392 | 28 | def __init__(self, app_name): | 28 | class Keyring(object): |
393 | 29 | 29 | ||
394 | 30 | if not gnomekeyring.is_available(): | 30 | KEYRING_NAME = "login" |
395 | 31 | raise gnomekeyring.NoKeyringDaemonError | 31 | |
396 | 32 | self.app_name = app_name | 32 | def __init__(self, app_name): |
397 | 33 | 33 | if not gnomekeyring.is_available(): | |
398 | 34 | def _create_keyring(self, name): | 34 | raise gnomekeyring.NoKeyringDaemonError |
399 | 35 | """ | 35 | self.app_name = app_name |
400 | 36 | Creates a keyring, if it already exists, | 36 | |
401 | 37 | it does nothing | 37 | def _create_keyring(self, name): |
402 | 38 | """ | 38 | """Creates a keyring, if it already exists, do nothing.""" |
403 | 39 | keyring_names = gnomekeyring.list_keyring_names_sync() | 39 | keyring_names = gnomekeyring.list_keyring_names_sync() |
404 | 40 | if not name in keyring_names: | 40 | if not name in keyring_names: |
405 | 41 | gnomekeyring.create_sync(name) | 41 | gnomekeyring.create_sync(name) |
406 | 42 | 42 | ||
407 | 43 | def _item_exists(self, sync, name): | 43 | def _get_item_id_from_name(self, sync, name): |
408 | 44 | """ | 44 | """Return the ID for a named item.""" |
409 | 45 | Returns whether a named item exists in a | 45 | for item_id in gnomekeyring.list_item_ids_sync(sync): |
410 | 46 | named keyring | 46 | item_info = gnomekeyring.item_get_info_sync(sync, item_id) |
411 | 47 | """ | 47 | display_name = item_info.get_display_name() |
412 | 48 | return self._get_item_id_from_name(sync, name) != None | 48 | if display_name == name: |
413 | 49 | 49 | return item_id | |
414 | 50 | def _get_item_id_from_name(self, sync, name): | 50 | |
415 | 51 | """ | 51 | def _get_item_info_from_name(self, sync, name): |
416 | 52 | Returns the ID for a named item | 52 | """Return the ID for a named item.""" |
417 | 53 | """ | 53 | for item_id in gnomekeyring.list_item_ids_sync(sync): |
418 | 54 | for item_id in gnomekeyring.list_item_ids_sync(sync): | 54 | item_info = gnomekeyring.item_get_info_sync(sync, item_id) |
419 | 55 | item_info = gnomekeyring.item_get_info_sync(sync, item_id) | 55 | display_name = item_info.get_display_name() |
420 | 56 | display_name = item_info.get_display_name() | 56 | if display_name == name: |
421 | 57 | if display_name == name: | 57 | return item_info |
422 | 58 | return item_id | 58 | |
423 | 59 | return None | 59 | def set_ubuntusso_attr(self, cred): |
424 | 60 | 60 | """Set the credentials of the Ubuntu SSO item.""" | |
425 | 61 | def _get_item_info_from_name(self, sync, name): | 61 | # Creates the secret from the credentials |
426 | 62 | """ | 62 | secret = urlencode(cred) |
427 | 63 | Returns the ID for a named item | 63 | |
428 | 64 | """ | 64 | # Create the keyring |
429 | 65 | for item_id in gnomekeyring.list_item_ids_sync(sync): | 65 | self._create_keyring(self.KEYRING_NAME) |
430 | 66 | item_info = gnomekeyring.item_get_info_sync(sync, item_id) | 66 | |
431 | 67 | display_name = item_info.get_display_name() | 67 | # No need to delete the item if it already exists |
432 | 68 | if display_name == name: | 68 | |
433 | 69 | return item_info | 69 | # A set of attributes for this credentials |
434 | 70 | return None | 70 | attr = {"key-type": "Ubuntu SSO credentials", |
435 | 71 | 71 | "token-name": cred["name"].encode("utf8")} | |
436 | 72 | def set_ubuntusso_attr(self, attr): | 72 | |
437 | 73 | """ | 73 | # Add our SSO credentials to the keyring |
438 | 74 | Sets the attributes of the Ubuntu SSO item | 74 | gnomekeyring.item_create_sync(self.KEYRING_NAME, |
439 | 75 | """ | 75 | gnomekeyring.ITEM_GENERIC_SECRET, self.app_name, attr, |
440 | 76 | # Creates the secret from the attributes | 76 | secret, True) |
441 | 77 | secret = urlencode(attr) | 77 | |
442 | 78 | 78 | def get_ubuntusso_attr(self): | |
443 | 79 | # Create the keyring | 79 | """Return the secret of the SSO item in a dictionary.""" |
444 | 80 | self._create_keyring(self.KEYRING_NAME) | 80 | # If we have no attributes, return None |
445 | 81 | 81 | exist = self._get_item_info_from_name(self.KEYRING_NAME, self.app_name) | |
446 | 82 | # If the item already exists, delete it | 82 | if exist is not None: |
447 | 83 | if self._item_exists(self.KEYRING_NAME, self.app_name): | 83 | secret = self._get_item_info_from_name(self.KEYRING_NAME, |
448 | 84 | item_id = self._get_item_id_from_name(self.KEYRING_NAME, | 84 | self.app_name).get_secret() |
449 | 85 | self.app_name) | 85 | return dict(parse_qsl(secret)) |
450 | 86 | gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id) | 86 | |
451 | 87 | 87 | def delete_ubuntusso_attr(self): | |
452 | 88 | # Add our SSO item | 88 | """Delete a set of credentials from the keyring.""" |
453 | 89 | gnomekeyring.item_create_sync(self.KEYRING_NAME, | 89 | item_id = self._get_item_id_from_name(self.KEYRING_NAME, |
454 | 90 | gnomekeyring.ITEM_GENERIC_SECRET, self.app_name, {}, | 90 | self.app_name) |
455 | 91 | secret, True) | 91 | if item_id is not None: |
456 | 92 | 92 | gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id) | |
457 | 93 | def get_ubuntusso_attr(self): | 93 | |
458 | 94 | """ | 94 | |
459 | 95 | Returns the secret of the SSO item in a dictionary | 95 | if __name__ == "__main__": |
460 | 96 | """ | 96 | kr1 = Keyring("Test key 1") |
461 | 97 | # If we have no attributes, return None | 97 | kr2 = Keyring("Test key 2") |
462 | 98 | if self._get_item_info_from_name(self.KEYRING_NAME, | 98 | |
463 | 99 | self.app_name) == None: | 99 | kr1.delete_ubuntusso_attr() |
464 | 100 | return None | 100 | kr2.delete_ubuntusso_attr() |
465 | 101 | secret = self._get_item_info_from_name(self.KEYRING_NAME, | 101 | |
466 | 102 | self.app_name).get_secret() | 102 | d1 = {"name": "test-1", "ha": "hehddddeff", "hi": "hggehes", "ho": "he"} |
467 | 103 | return dict(parse_qsl(secret)) | 103 | d2 = {"name": "test-2", "hi": "ho", "let's": "go"} |
468 | 104 | 104 | ||
469 | 105 | if __name__ == "__main__": | 105 | kr1.set_ubuntusso_attr(d1) |
470 | 106 | SSO_ITEM_NAME = "Software Center UbuntuSSO token" | 106 | kr2.set_ubuntusso_attr(d2) |
471 | 107 | keyring = Keyring(SSO_ITEM_NAME) | 107 | |
472 | 108 | keyring.set_ubuntusso_attr({"ha":"hehddddeff", "hi":"hggehes", "ho":"he"}) | 108 | r1 = kr1.get_ubuntusso_attr() |
473 | 109 | print keyring.get_ubuntusso_attr() | 109 | r2 = kr2.get_ubuntusso_attr() |
474 | 110 | 110 | ||
475 | 111 | 111 | assert r1 == d1 | |
476 | 112 | assert r2 == d2 | ||
477 | 112 | 113 | ||
478 | === modified file 'ubuntu_sso/main.py' | |||
479 | --- ubuntu_sso/main.py 2010-08-12 00:00:08 +0000 | |||
480 | +++ ubuntu_sso/main.py 2010-08-19 17:58:43 +0000 | |||
481 | @@ -199,8 +199,8 @@ | |||
482 | 199 | logger.exception('login failed with:') | 199 | logger.exception('login failed with:') |
483 | 200 | raise AuthenticationError() | 200 | raise AuthenticationError() |
484 | 201 | 201 | ||
487 | 202 | logger.debug('login: authentication successful! consumer_key: %r', | 202 | logger.debug('login: authentication successful! consumer_key: %r, ' \ |
488 | 203 | credentials['consumer_key']) | 203 | 'token_name: %r', credentials['consumer_key'], token_name) |
489 | 204 | keyring_store_credentials(app_name, credentials) | 204 | keyring_store_credentials(app_name, credentials) |
490 | 205 | return credentials | 205 | return credentials |
491 | 206 | 206 | ||
492 | @@ -413,8 +413,8 @@ | |||
493 | 413 | class SSOCredentials(dbus.service.Object): | 413 | class SSOCredentials(dbus.service.Object): |
494 | 414 | """DBus object that gets credentials, and login/registers if needed.""" | 414 | """DBus object that gets credentials, and login/registers if needed.""" |
495 | 415 | 415 | ||
498 | 416 | @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="s") | 416 | @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="") |
499 | 417 | def AuthorizationDenied(self, app_name): | 417 | def AuthorizationDenied(self): |
500 | 418 | """Signal thrown when the user denies the authorization.""" | 418 | """Signal thrown when the user denies the authorization.""" |
501 | 419 | 419 | ||
502 | 420 | @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="a{ss}") | 420 | @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="a{ss}") |
503 | 421 | 421 | ||
504 | === modified file 'ubuntu_sso/tests/test_gui.py' | |||
505 | --- ubuntu_sso/tests/test_gui.py 2010-08-12 00:00:08 +0000 | |||
506 | +++ ubuntu_sso/tests/test_gui.py 2010-08-19 17:58:43 +0000 | |||
507 | @@ -22,10 +22,10 @@ | |||
508 | 22 | import itertools | 22 | import itertools |
509 | 23 | import logging | 23 | import logging |
510 | 24 | import os | 24 | import os |
511 | 25 | import socket | ||
512 | 26 | 25 | ||
513 | 27 | import dbus | 26 | import dbus |
514 | 28 | import gtk | 27 | import gtk |
515 | 28 | import webkit | ||
516 | 29 | 29 | ||
517 | 30 | from twisted.trial.unittest import TestCase | 30 | from twisted.trial.unittest import TestCase |
518 | 31 | 31 | ||
519 | @@ -300,7 +300,6 @@ | |||
520 | 300 | super(UbuntuSSOClientTestCase, self).setUp() | 300 | super(UbuntuSSOClientTestCase, self).setUp() |
521 | 301 | self.patch(dbus, 'SessionBus', FakedSessionBus) | 301 | self.patch(dbus, 'SessionBus', FakedSessionBus) |
522 | 302 | self.patch(dbus, 'Interface', FakedSSOBackend) | 302 | self.patch(dbus, 'Interface', FakedSSOBackend) |
523 | 303 | self.patch(socket, 'gethostname', lambda: TOKEN_NAME) | ||
524 | 304 | self.pages = ('enter_details', 'processing', 'verify_email', 'success', | 303 | self.pages = ('enter_details', 'processing', 'verify_email', 'success', |
525 | 305 | 'tc_browser', 'login', 'request_password_token', | 304 | 'tc_browser', 'login', 'request_password_token', |
526 | 306 | 'set_new_password') | 305 | 'set_new_password') |
527 | @@ -562,7 +561,7 @@ | |||
528 | 562 | def test_initial_text_for_header_label(self): | 561 | def test_initial_text_for_header_label(self): |
529 | 563 | """The header must have the correct text at startup.""" | 562 | """The header must have the correct text at startup.""" |
530 | 564 | msg = 'Text for the header must be "%s" (got "%s" instead).' | 563 | msg = 'Text for the header must be "%s" (got "%s" instead).' |
532 | 565 | expected = self.ui.JOIN_HEADER_LABEL % APP_NAME | 564 | expected = self.ui.JOIN_HEADER_LABEL % {'app_name': APP_NAME} |
533 | 566 | actual = self.ui.header_label.get_text() | 565 | actual = self.ui.header_label.get_text() |
534 | 567 | # text content is correct | 566 | # text content is correct |
535 | 568 | self.assertEqual(expected, actual, msg % (expected, actual)) | 567 | self.assertEqual(expected, actual, msg % (expected, actual)) |
536 | @@ -583,11 +582,11 @@ | |||
537 | 583 | def test_initial_texts_for_checkbuttons(self): | 582 | def test_initial_texts_for_checkbuttons(self): |
538 | 584 | """Check buttons have the correct text at startup.""" | 583 | """Check buttons have the correct text at startup.""" |
539 | 585 | msg = 'Text for "%s" must be "%s" (got "%s" instead).' | 584 | msg = 'Text for "%s" must be "%s" (got "%s" instead).' |
541 | 586 | expected = self.ui.YES_TO_UPDATES | 585 | expected = self.ui.YES_TO_UPDATES % {'app_name': APP_NAME} |
542 | 587 | actual = self.ui.yes_to_updates_checkbutton.get_label() | 586 | actual = self.ui.yes_to_updates_checkbutton.get_label() |
543 | 588 | self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton', | 587 | self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton', |
544 | 589 | expected, actual)) | 588 | expected, actual)) |
546 | 590 | expected = self.ui.YES_TO_TC | 589 | expected = self.ui.YES_TO_TC % {'app_name': APP_NAME} |
547 | 591 | actual = self.ui.yes_to_tc_checkbutton.get_label() | 590 | actual = self.ui.yes_to_tc_checkbutton.get_label() |
548 | 592 | self.assertEqual(expected, actual, | 591 | self.assertEqual(expected, actual, |
549 | 593 | msg % ('yes_to_tc_checkbutton', expected, actual)) | 592 | msg % ('yes_to_tc_checkbutton', expected, actual)) |
550 | @@ -731,6 +730,29 @@ | |||
551 | 731 | class TermsAndConditionsTestCase(UbuntuSSOClientTestCase): | 730 | class TermsAndConditionsTestCase(UbuntuSSOClientTestCase): |
552 | 732 | """Test suite for the user registration (terms & conditions page).""" | 731 | """Test suite for the user registration (terms & conditions page).""" |
553 | 733 | 732 | ||
554 | 733 | def test_tc_browser_is_created_when_tc_page_is_shown(self): | ||
555 | 734 | """The webkit browser is created when the TC page is shown.""" | ||
556 | 735 | self.ui.tc_browser_vbox.show() | ||
557 | 736 | |||
558 | 737 | children = self.ui.tc_browser_window.get_children() | ||
559 | 738 | self.assertEqual(1, len(children)) | ||
560 | 739 | browser = children[0] | ||
561 | 740 | self.assertIsInstance(browser, webkit.WebView) | ||
562 | 741 | self.assertTrue(browser.get_property('visible')) | ||
563 | 742 | |||
564 | 743 | self.ui.tc_browser_vbox.hide() | ||
565 | 744 | |||
566 | 745 | def test_tc_browser_is_destroyed_when_tc_page_is_hid(self): | ||
567 | 746 | """The webkit browser is destroyed when the TC page is hid.""" | ||
568 | 747 | self.ui.tc_browser_vbox.show() | ||
569 | 748 | browser = self.ui.tc_browser_window.get_children()[0] | ||
570 | 749 | self.patch(browser, 'destroy', self._set_called) | ||
571 | 750 | self.ui.tc_browser_vbox.hide() | ||
572 | 751 | |||
573 | 752 | children = self.ui.tc_browser_window.get_children() | ||
574 | 753 | self.assertEqual(0, len(children)) | ||
575 | 754 | self.assertEqual(self._called, ((), {})) | ||
576 | 755 | |||
577 | 734 | def test_tc_button_clicked_morphs_into_tc_browser_vbox(self): | 756 | def test_tc_button_clicked_morphs_into_tc_browser_vbox(self): |
578 | 735 | """Terms & Conditions morphs to a browser window.""" | 757 | """Terms & Conditions morphs to a browser window.""" |
579 | 736 | self.ui.tc_button.clicked() | 758 | self.ui.tc_button.clicked() |
580 | @@ -1001,14 +1023,14 @@ | |||
581 | 1001 | def test_initial_text_for_header_label(self): | 1023 | def test_initial_text_for_header_label(self): |
582 | 1002 | """The header must have the correct text when logging in.""" | 1024 | """The header must have the correct text when logging in.""" |
583 | 1003 | msg = 'Text for the header must be "%s" (got "%s" instead).' | 1025 | msg = 'Text for the header must be "%s" (got "%s" instead).' |
585 | 1004 | expected = self.ui.LOGIN_HEADER_LABEL % APP_NAME | 1026 | expected = self.ui.LOGIN_HEADER_LABEL % {'app_name': APP_NAME} |
586 | 1005 | actual = self.ui.header_label.get_text() | 1027 | actual = self.ui.header_label.get_text() |
587 | 1006 | self.assertEqual(expected, actual, msg % (expected, actual)) | 1028 | self.assertEqual(expected, actual, msg % (expected, actual)) |
588 | 1007 | 1029 | ||
589 | 1008 | def test_initial_text_for_help_label(self): | 1030 | def test_initial_text_for_help_label(self): |
590 | 1009 | """The help must have the correct text at startup.""" | 1031 | """The help must have the correct text at startup.""" |
591 | 1010 | msg = 'Text for the help must be "%s" (got "%s" instead).' | 1032 | msg = 'Text for the help must be "%s" (got "%s" instead).' |
593 | 1011 | expected = self.ui.CONNECT_HELP_LABEL % APP_NAME | 1033 | expected = self.ui.CONNECT_HELP_LABEL % {'app_name': APP_NAME} |
594 | 1012 | actual = self.ui.help_label.get_text() | 1034 | actual = self.ui.help_label.get_text() |
595 | 1013 | self.assertEqual(expected, actual, msg % (expected, actual)) | 1035 | self.assertEqual(expected, actual, msg % (expected, actual)) |
596 | 1014 | 1036 | ||
597 | @@ -1225,7 +1247,7 @@ | |||
598 | 1225 | self.ui.on_password_reset_token_sent(email=EMAIL) | 1247 | self.ui.on_password_reset_token_sent(email=EMAIL) |
599 | 1226 | 1248 | ||
600 | 1227 | self.assertEqual(self.ui.help_label.get_text(), | 1249 | self.assertEqual(self.ui.help_label.get_text(), |
602 | 1228 | self.ui.SET_NEW_PASSWORD_LABEL % EMAIL) | 1250 | self.ui.SET_NEW_PASSWORD_LABEL % {'email': EMAIL}) |
603 | 1229 | 1251 | ||
604 | 1230 | def test_on_password_reset_token_sent_ok_button(self): | 1252 | def test_on_password_reset_token_sent_ok_button(self): |
605 | 1231 | """After request_password_token_ok_button the ok button is updated.""" | 1253 | """After request_password_token_ok_button the ok button is updated.""" |
606 | 1232 | 1254 | ||
607 | === added file 'ubuntu_sso/tests/test_keyring.py' | |||
608 | --- ubuntu_sso/tests/test_keyring.py 1970-01-01 00:00:00 +0000 | |||
609 | +++ ubuntu_sso/tests/test_keyring.py 2010-08-19 17:58:43 +0000 | |||
610 | @@ -0,0 +1,115 @@ | |||
611 | 1 | # test_keyring - tests for ubuntu_sso.keyring | ||
612 | 2 | # | ||
613 | 3 | # Author: Alejandro J. Cura <alecu@canonical.com> | ||
614 | 4 | # | ||
615 | 5 | # Copyright 2010 Canonical Ltd. | ||
616 | 6 | # | ||
617 | 7 | # This program is free software: you can redistribute it and/or modify it | ||
618 | 8 | # under the terms of the GNU General Public License version 3, as published | ||
619 | 9 | # by the Free Software Foundation. | ||
620 | 10 | # | ||
621 | 11 | # This program is distributed in the hope that it will be useful, but | ||
622 | 12 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
623 | 13 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
624 | 14 | # PURPOSE. See the GNU General Public License for more details. | ||
625 | 15 | # | ||
626 | 16 | # You should have received a copy of the GNU General Public License along | ||
627 | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
628 | 18 | """Tests for the keyring.py module.""" | ||
629 | 19 | |||
630 | 20 | import gnomekeyring | ||
631 | 21 | from twisted.trial.unittest import TestCase | ||
632 | 22 | |||
633 | 23 | from ubuntu_sso import keyring | ||
634 | 24 | |||
635 | 25 | |||
636 | 26 | class MockInfoSync(object): | ||
637 | 27 | """A mock object that represents a fake key.""" | ||
638 | 28 | |||
639 | 29 | def __init__(self, (key, key_name, secret)): | ||
640 | 30 | """Initialize this instance.""" | ||
641 | 31 | self.key = key | ||
642 | 32 | self.key_name = key_name | ||
643 | 33 | self.secret = secret | ||
644 | 34 | |||
645 | 35 | def get_display_name(self): | ||
646 | 36 | """Return info on the mocked object.""" | ||
647 | 37 | return self.key_name | ||
648 | 38 | |||
649 | 39 | |||
650 | 40 | class MockGnomeKeyring(object): | ||
651 | 41 | """A mock keyring that stores keys according to a given attr.""" | ||
652 | 42 | |||
653 | 43 | def __init__(self): | ||
654 | 44 | """Initialize this instance.""" | ||
655 | 45 | self.keyrings = set() | ||
656 | 46 | self.store = [] | ||
657 | 47 | self.deleted = [] | ||
658 | 48 | |||
659 | 49 | def item_create_sync(self, keyring_name, item_type, key_name, attr, | ||
660 | 50 | secret, update_if_exists): | ||
661 | 51 | """Sets a value in the keyring.""" | ||
662 | 52 | # we'll use the attr as the dict key, so make it a tuple | ||
663 | 53 | key = tuple(attr.items()) | ||
664 | 54 | self.store.append((key, key_name, secret)) | ||
665 | 55 | |||
666 | 56 | def item_delete_sync(self, keyring_name, item_id): | ||
667 | 57 | """Makes a list of deleted items.""" | ||
668 | 58 | key, key_name, secret = self.store.pop(item_id) | ||
669 | 59 | self.deleted.append(key_name) | ||
670 | 60 | |||
671 | 61 | def list_item_ids_sync(self, keyring_name): | ||
672 | 62 | """Return a list of ids for all the items.""" | ||
673 | 63 | return [n for n, v in enumerate(self.store)] | ||
674 | 64 | |||
675 | 65 | def item_get_info_sync(self, keyring_name, item_id): | ||
676 | 66 | """Return an info sync object for the item.""" | ||
677 | 67 | return MockInfoSync(self.store[item_id]) | ||
678 | 68 | |||
679 | 69 | def list_keyring_names_sync(self): | ||
680 | 70 | """The keyring you are looking for may be here.""" | ||
681 | 71 | return self.keyrings | ||
682 | 72 | |||
683 | 73 | def create_sync(self, name): | ||
684 | 74 | """Thanks, I'll create that keyring for you.""" | ||
685 | 75 | self.keyrings.add(name) | ||
686 | 76 | |||
687 | 77 | def is_available(self): | ||
688 | 78 | """A very available keyring.""" | ||
689 | 79 | return True | ||
690 | 80 | |||
691 | 81 | |||
692 | 82 | class TestKeyring(TestCase): | ||
693 | 83 | """Test the gnome keyring related functions.""" | ||
694 | 84 | def setUp(self): | ||
695 | 85 | """Initialize the mock used in these tests.""" | ||
696 | 86 | self.mgk = MockGnomeKeyring() | ||
697 | 87 | self.patch(gnomekeyring, "item_create_sync", self.mgk.item_create_sync) | ||
698 | 88 | self.patch(gnomekeyring, "is_available", self.mgk.is_available) | ||
699 | 89 | self.patch(gnomekeyring, "create_sync", self.mgk.create_sync) | ||
700 | 90 | self.patch(gnomekeyring, "list_keyring_names_sync", | ||
701 | 91 | self.mgk.list_keyring_names_sync) | ||
702 | 92 | self.patch(gnomekeyring, "list_item_ids_sync", | ||
703 | 93 | self.mgk.list_item_ids_sync) | ||
704 | 94 | self.patch(gnomekeyring, "item_get_info_sync", | ||
705 | 95 | self.mgk.item_get_info_sync) | ||
706 | 96 | self.patch(gnomekeyring, "item_delete_sync", self.mgk.item_delete_sync) | ||
707 | 97 | |||
708 | 98 | def test_set_ubuntusso(self): | ||
709 | 99 | """Test that the set method does not erase previous keys.""" | ||
710 | 100 | sample_creds = {"name": "sample creds name"} | ||
711 | 101 | sample_creds2 = {"name": "sample creds name 2"} | ||
712 | 102 | keyring.Keyring("appname").set_ubuntusso_attr(sample_creds) | ||
713 | 103 | keyring.Keyring("appname").set_ubuntusso_attr(sample_creds2) | ||
714 | 104 | |||
715 | 105 | self.assertEqual(len(self.mgk.store), 2) | ||
716 | 106 | self.assertEqual(len(self.mgk.deleted), 0) | ||
717 | 107 | |||
718 | 108 | def test_delete_ubuntusso(self): | ||
719 | 109 | """Test that a given key is deleted.""" | ||
720 | 110 | sample_creds = {"name": "sample creds name"} | ||
721 | 111 | keyring.Keyring("appname").set_ubuntusso_attr(sample_creds) | ||
722 | 112 | keyring.Keyring("appname").delete_ubuntusso_attr() | ||
723 | 113 | |||
724 | 114 | self.assertEqual(len(self.mgk.store), 0) | ||
725 | 115 | self.assertEqual(len(self.mgk.deleted), 1) |