Merge lp:~nataliabidart/ubuntu/maverick/ubuntu-sso-client/ubuntu-sso-client-0.99.1 into lp:ubuntu/maverick/ubuntu-sso-client

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
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+33134@code.launchpad.net

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
=== modified file 'PKG-INFO'
--- PKG-INFO 2010-08-12 00:00:08 +0000
+++ PKG-INFO 2010-08-19 17:58:43 +0000
@@ -1,6 +1,6 @@
1Metadata-Version: 1.01Metadata-Version: 1.0
2Name: ubuntu-sso-client2Name: ubuntu-sso-client
3Version: 0.993Version: 0.99.1
4Summary: Ubuntu Single Sign-On client4Summary: Ubuntu Single Sign-On client
5Home-page: https://launchpad.net/ubuntu-sso-client5Home-page: https://launchpad.net/ubuntu-sso-client
6Author: Natalia Bidart6Author: Natalia Bidart
77
=== modified file 'bin/ubuntu-sso-login-gui'
--- bin/ubuntu-sso-login-gui 2010-08-12 00:00:08 +0000
+++ bin/ubuntu-sso-login-gui 2010-08-19 17:58:43 +0000
@@ -25,8 +25,8 @@
25from ubuntu_sso.gui import UbuntuSSOClientGUI25from ubuntu_sso.gui import UbuntuSSOClientGUI
2626
2727
28APP_NAME = 'Super Testing App'28APP_NAME = 'Ubuntu'
29TC_URI = 'http://ubuntu.com'29TC_URI = 'http://one.ubuntu.com/terms'
30HELP_TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \30HELP_TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \
31 'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit ' \31 'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit ' \
32 'pulvinar tempus ut augue.'32 'pulvinar tempus ut augue.'
3333
=== modified file 'data/ui.glade'
--- data/ui.glade 2010-08-12 00:00:08 +0000
+++ data/ui.glade 2010-08-19 17:58:43 +0000
@@ -349,6 +349,8 @@
349 </object>349 </object>
350 <object class="GtkVBox" id="tc_browser_vbox">350 <object class="GtkVBox" id="tc_browser_vbox">
351 <property name="visible">True</property>351 <property name="visible">True</property>
352 <signal name="hide" handler="on_tc_browser_vbox_hide"/>
353 <signal name="show" handler="on_tc_browser_vbox_show"/>
352 <child>354 <child>
353 <object class="GtkScrolledWindow" id="tc_browser_window">355 <object class="GtkScrolledWindow" id="tc_browser_window">
354 <property name="visible">True</property>356 <property name="visible">True</property>
355357
=== modified file 'debian/changelog'
--- debian/changelog 2010-08-12 09:38:17 +0000
+++ debian/changelog 2010-08-19 17:58:43 +0000
@@ -1,3 +1,13 @@
1ubuntu-sso-client (0.99.1-0ubuntu1) UNRELEASED; urgency=low
2
3 * New upstream release:
4 - Delayed opening the webkit browser to the latest possible. (LP: #617041)
5 (nataliabidart)
6 - Use a proper dictionary with different attributes for each key so old
7 keys are not overwritten nor deleted. (LP: #617347) (alecu)
8
9 -- Natalia Bidart (nessita) <nataliabidart@gmail.com> Thu, 19 Aug 2010 13:02:10 -0300
10
1ubuntu-sso-client (0.99-0ubuntu1) maverick; urgency=low11ubuntu-sso-client (0.99-0ubuntu1) maverick; urgency=low
212
3 * New upstream release.13 * New upstream release.
414
=== modified file 'debian/control'
--- debian/control 2010-08-11 16:18:28 +0000
+++ debian/control 2010-08-19 17:58:43 +0000
@@ -7,7 +7,7 @@
7 python-support (>= 0.6.4),7 python-support (>= 0.6.4),
8 python-distutils-extra (>= 2.10)8 python-distutils-extra (>= 2.10)
9Maintainer: Natalia Bidart <natalia.bidart@canonical.com>9Maintainer: Natalia Bidart <natalia.bidart@canonical.com>
10Standards-Version: 3.8.410Standards-Version: 3.9.1
11XS-Python-Version: current11XS-Python-Version: current
1212
13Package: ubuntu-sso-client13Package: ubuntu-sso-client
1414
=== modified file 'run-tests'
--- run-tests 2010-08-11 17:03:11 +0000
+++ run-tests 2010-08-19 17:58:43 +0000
@@ -18,9 +18,11 @@
18`which xvfb-run` ./contrib/test $@18`which xvfb-run` ./contrib/test $@
19pyflakes bin ubuntu_sso19pyflakes bin ubuntu_sso
20if [ -x `which pep8` ]; then20if [ -x `which pep8` ]; then
21 pep8 --repeat bin ubuntu_sso/gui.py ubuntu_sso/main.py \21 pep8 --repeat bin/ contrib/ \
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 \
23 ubuntu_sso/tests/test_gui.py ubuntu_sso/tests/test_main.py \
24 ubuntu_sso/tests/test_keyring.py
23else25else
24 echo "Please install the 'pep8' package."26 echo "Please install the 'pep8' package."
25fi27fi
26rm -rf _trial_temp/
27\ No newline at end of file28\ No newline at end of file
29rm -rf _trial_temp/
2830
=== modified file 'setup.py'
--- setup.py 2010-08-12 00:00:08 +0000
+++ setup.py 2010-08-19 17:58:43 +0000
@@ -72,7 +72,7 @@
7272
73setup(73setup(
74 name='ubuntu-sso-client',74 name='ubuntu-sso-client',
75 version='0.99',75 version='0.99.1',
76 license='GPL v3',76 license='GPL v3',
77 author='Natalia Bidart',77 author='Natalia Bidart',
78 author_email='natalia.bidart@canonical.com',78 author_email='natalia.bidart@canonical.com',
7979
=== modified file 'ubuntu_sso/gui.py'
--- ubuntu_sso/gui.py 2010-08-12 00:00:08 +0000
+++ ubuntu_sso/gui.py 2010-08-19 17:58:43 +0000
@@ -153,8 +153,8 @@
153 """Ubuntu single sign on GUI."""153 """Ubuntu single sign on GUI."""
154154
155 CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')155 CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')
156 CONNECT_HELP_LABEL = _('To connect this computer to') + ' %s ' + \156 CONNECT_HELP_LABEL = _('To connect this computer to %(app_name)s ' \
157 _('enter your details below.')157 'enter your details below.')
158 EMAIL1_ENTRY = _('Email address')158 EMAIL1_ENTRY = _('Email address')
159 EMAIL2_ENTRY = _('Re-type Email address')159 EMAIL2_ENTRY = _('Re-type Email address')
160 EMAIL_MISMATCH = _('The email addresses don\'t match, please double check '160 EMAIL_MISMATCH = _('The email addresses don\'t match, please double check '
@@ -163,11 +163,11 @@
163 EMAIL_TOKEN_ENTRY = _('Enter code verification here')163 EMAIL_TOKEN_ENTRY = _('Enter code verification here')
164 FIELD_REQUIRED = _('This field is required.')164 FIELD_REQUIRED = _('This field is required.')
165 FORGOTTEN_PASSWORD_BUTTON = _('I\'ve forgotten my password')165 FORGOTTEN_PASSWORD_BUTTON = _('I\'ve forgotten my password')
166 JOIN_HEADER_LABEL = _('Create') + ' %s ' + _('account')166 JOIN_HEADER_LABEL = _('Create %(app_name)s account')
167 LOADING = _('Loading...')167 LOADING = _('Loading...')
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')
169 LOGIN_EMAIL_ENTRY = _('Email address')169 LOGIN_EMAIL_ENTRY = _('Email address')
170 LOGIN_HEADER_LABEL = _('Connect to') + ' %s'170 LOGIN_HEADER_LABEL = _('Connect to %(app_name)s')
171 LOGIN_PASSWORD_ENTRY = _('Password')171 LOGIN_PASSWORD_ENTRY = _('Password')
172 NAME_ENTRY = _('Name')172 NAME_ENTRY = _('Name')
173 NEXT = _('Next')173 NEXT = _('Next')
@@ -185,9 +185,9 @@
185 RESET_PASSWORD = _('Reset Password')185 RESET_PASSWORD = _('Reset Password')
186 RESET_CODE_ENTRY = _('Reset code')186 RESET_CODE_ENTRY = _('Reset code')
187 RESET_EMAIL_ENTRY = _('Email address')187 RESET_EMAIL_ENTRY = _('Email address')
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 ' \
189 'Please enter the code below along with your ' \189 '%(email)s.\nPlease enter the code below ' \
190 'new password.')190 'along with your new password.')
191 SUCCESS = _('The process finished successfully. Congratulations!')191 SUCCESS = _('The process finished successfully. Congratulations!')
192 TC = _('Terms & Conditions')192 TC = _('Terms & Conditions')
193 TC_NOT_ACCEPTED = _('Agreeing to the Ubuntu One Terms & Conditions is '193 TC_NOT_ACCEPTED = _('Agreeing to the Ubuntu One Terms & Conditions is '
@@ -198,8 +198,8 @@
198198
199A verification code has just been sent to your email address.199A verification code has just been sent to your email address.
200Please enter your code from the email. An example is shown below.""")200Please enter your code from the email. An example is shown below.""")
201 YES_TO_TC = _('I agree with the')201 YES_TO_TC = _('I agree with the %(app_name)s ') # Terms&Conditions button
202 YES_TO_UPDATES = _('Yes! Email me tips and updates.')202 YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')
203203
204 def __init__(self, app_name, tc_uri, help_text,204 def __init__(self, app_name, tc_uri, help_text,
205 window_id=0, login_only=False, close_callback=None):205 window_id=0, login_only=False, close_callback=None):
@@ -211,7 +211,7 @@
211 self._signals_receivers = {}211 self._signals_receivers = {}
212212
213 self.app_name = app_name213 self.app_name = app_name
214 self.app_label = '<b>%s</b>' % app_name214 self.app_label = '<b>%s</b>' % self.app_name
215 self.tc_uri = tc_uri215 self.tc_uri = tc_uri
216 self.help_text = help_text216 self.help_text = help_text
217 self.close_callback = close_callback217 self.close_callback = close_callback
@@ -437,8 +437,8 @@
437437
438 def _build_enter_details_page(self):438 def _build_enter_details_page(self):
439 """Build the enter details page."""439 """Build the enter details page."""
440 self.enter_details_vbox.header = (self.JOIN_HEADER_LABEL %440 d = {'app_name': self.app_label}
441 self.app_label)441 self.enter_details_vbox.header = self.JOIN_HEADER_LABEL % d
442 self.enter_details_vbox.help_text = self.help_text442 self.enter_details_vbox.help_text = self.help_text
443443
444 self.enter_details_vbox.pack_start(self.name_entry, expand=False)444 self.enter_details_vbox.pack_start(self.name_entry, expand=False)
@@ -461,8 +461,10 @@
461 else:461 else:
462 self._set_captcha_image()462 self._set_captcha_image()
463463
464 self.yes_to_updates_checkbutton.set_label(self.YES_TO_UPDATES)464 msg = self.YES_TO_UPDATES % {'app_name': self.app_name}
465 self.yes_to_tc_checkbutton.set_label(self.YES_TO_TC)465 self.yes_to_updates_checkbutton.set_label(msg)
466 msg = self.YES_TO_TC % {'app_name': self.app_name}
467 self.yes_to_tc_checkbutton.set_label(msg)
466 self.tc_button.set_label(self.TC)468 self.tc_button.set_label(self.TC)
467 self.login_button.set_label(self.LOGIN_BUTTON_LABEL)469 self.login_button.set_label(self.LOGIN_BUTTON_LABEL)
468470
@@ -476,11 +478,6 @@
476478
477 def _build_tc_page(self):479 def _build_tc_page(self):
478 """Build the Terms & Conditions page."""480 """Build the Terms & Conditions page."""
479 self.tc_browser = webkit.WebView()
480 self.tc_browser.open(self.tc_uri)
481 self.tc_browser.show()
482 self.tc_browser_window.add(self.tc_browser)
483
484 return self.tc_browser_vbox481 return self.tc_browser_vbox
485482
486 def _build_processing_page(self):483 def _build_processing_page(self):
@@ -510,8 +507,9 @@
510507
511 def _build_login_page(self):508 def _build_login_page(self):
512 """Build the login page."""509 """Build the login page."""
513 self.login_vbox.header = self.LOGIN_HEADER_LABEL % self.app_label510 d = {'app_name': self.app_label}
514 self.login_vbox.help_text = self.CONNECT_HELP_LABEL % self.app_label511 self.login_vbox.header = self.LOGIN_HEADER_LABEL % d
512 self.login_vbox.help_text = self.CONNECT_HELP_LABEL % d
515513
516 self.login_details_vbox.pack_start(self.login_email_entry)514 self.login_details_vbox.pack_start(self.login_email_entry)
517 self.login_details_vbox.reorder_child(self.login_email_entry, 0)515 self.login_details_vbox.reorder_child(self.login_email_entry, 0)
@@ -777,6 +775,22 @@
777775
778 self._set_current_page(self.processing_vbox)776 self._set_current_page(self.processing_vbox)
779777
778 def on_tc_browser_vbox_show(self, *args, **kwargs):
779 """The T&C page is being shown."""
780 browser = webkit.WebView()
781 browser.open(self.tc_uri)
782 browser.show()
783 self.tc_browser_window.add(browser)
784
785 def on_tc_browser_vbox_hide(self, *args, **kwargs):
786 """The T&C page is no longer being shown."""
787 children = self.tc_browser_window.get_children()
788 if len(children) > 0:
789 browser = children[0]
790 self.tc_browser_window.remove(browser)
791 browser.destroy()
792 del browser
793
780 # backend callbacks794 # backend callbacks
781795
782 def on_captcha_generated(self, captcha_id, *args, **kwargs):796 def on_captcha_generated(self, captcha_id, *args, **kwargs):
@@ -836,8 +850,9 @@
836850
837 def on_password_reset_token_sent(self, email, *args, **kwargs):851 def on_password_reset_token_sent(self, email, *args, **kwargs):
838 """Password reset token was successfully sent."""852 """Password reset token was successfully sent."""
839 e = self.reset_email_entry.get_text()853 email = self.reset_email_entry.get_text()
840 self.set_new_password_vbox.help_text = self.SET_NEW_PASSWORD_LABEL % e854 msg = self.SET_NEW_PASSWORD_LABEL % {'email': email}
855 self.set_new_password_vbox.help_text = msg
841 self._set_current_page(self.set_new_password_vbox)856 self._set_current_page(self.set_new_password_vbox)
842857
843 def on_password_reset_error(self, *args, **kwargs):858 def on_password_reset_error(self, *args, **kwargs):
844859
=== modified file 'ubuntu_sso/keyring.py'
--- ubuntu_sso/keyring.py 2010-08-11 17:03:11 +0000
+++ ubuntu_sso/keyring.py 2010-08-19 17:58:43 +0000
@@ -1,111 +1,112 @@
1# Copyright (C) 2010 Canonical1# Copyright (C) 2010 Canonical
2#2#
3# Authors:3# Authors:
4# Andrew Higginson4# Andrew Higginson
5#5# Alejandro J. Cura <alecu@canonical.com>
6# This program is free software; you can redistribute it and/or modify it under6#
7# the terms of the GNU General Public License as published by the Free Software7# This program is free software; you can redistribute it and/or modify it under
8# Foundation; version 3.8# the terms of the GNU General Public License as published by the Free Software
9#9# Foundation; version 3.
10# This program is distributed in the hope that it will be useful, but WITHOUT10#
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS11# This program is distributed in the hope that it will be useful, but WITHOUT
12# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13# details.13# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14#14# details.
15# You should have received a copy of the GNU General Public License along with15#
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
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA17# this program; if not, write to the Free Software Foundation, Inc.,
1818# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19import gnomekeyring19
2020"""Handle keys in the gnome kerying."""
21from urllib import urlencode21
22from urlparse import parse_qsl22import gnomekeyring
2323
24class Keyring(object):24from urllib import urlencode
2525from urlparse import parse_qsl
26 KEYRING_NAME = "login"26
2727
28 def __init__(self, app_name):28class Keyring(object):
2929
30 if not gnomekeyring.is_available():30 KEYRING_NAME = "login"
31 raise gnomekeyring.NoKeyringDaemonError31
32 self.app_name = app_name32 def __init__(self, app_name):
3333 if not gnomekeyring.is_available():
34 def _create_keyring(self, name):34 raise gnomekeyring.NoKeyringDaemonError
35 """35 self.app_name = app_name
36 Creates a keyring, if it already exists,36
37 it does nothing37 def _create_keyring(self, name):
38 """38 """Creates a keyring, if it already exists, do nothing."""
39 keyring_names = gnomekeyring.list_keyring_names_sync()39 keyring_names = gnomekeyring.list_keyring_names_sync()
40 if not name in keyring_names:40 if not name in keyring_names:
41 gnomekeyring.create_sync(name)41 gnomekeyring.create_sync(name)
4242
43 def _item_exists(self, sync, name):43 def _get_item_id_from_name(self, sync, name):
44 """44 """Return the ID for a named item."""
45 Returns whether a named item exists in a45 for item_id in gnomekeyring.list_item_ids_sync(sync):
46 named keyring46 item_info = gnomekeyring.item_get_info_sync(sync, item_id)
47 """47 display_name = item_info.get_display_name()
48 return self._get_item_id_from_name(sync, name) != None48 if display_name == name:
4949 return item_id
50 def _get_item_id_from_name(self, sync, name):50
51 """51 def _get_item_info_from_name(self, sync, name):
52 Returns the ID for a named item52 """Return the ID for a named item."""
53 """53 for item_id in gnomekeyring.list_item_ids_sync(sync):
54 for item_id in gnomekeyring.list_item_ids_sync(sync):54 item_info = gnomekeyring.item_get_info_sync(sync, item_id)
55 item_info = gnomekeyring.item_get_info_sync(sync, item_id)55 display_name = item_info.get_display_name()
56 display_name = item_info.get_display_name()56 if display_name == name:
57 if display_name == name:57 return item_info
58 return item_id58
59 return None59 def set_ubuntusso_attr(self, cred):
6060 """Set the credentials of the Ubuntu SSO item."""
61 def _get_item_info_from_name(self, sync, name):61 # Creates the secret from the credentials
62 """62 secret = urlencode(cred)
63 Returns the ID for a named item63
64 """64 # Create the keyring
65 for item_id in gnomekeyring.list_item_ids_sync(sync):65 self._create_keyring(self.KEYRING_NAME)
66 item_info = gnomekeyring.item_get_info_sync(sync, item_id)66
67 display_name = item_info.get_display_name()67 # No need to delete the item if it already exists
68 if display_name == name:68
69 return item_info69 # A set of attributes for this credentials
70 return None70 attr = {"key-type": "Ubuntu SSO credentials",
7171 "token-name": cred["name"].encode("utf8")}
72 def set_ubuntusso_attr(self, attr):72
73 """73 # Add our SSO credentials to the keyring
74 Sets the attributes of the Ubuntu SSO item74 gnomekeyring.item_create_sync(self.KEYRING_NAME,
75 """75 gnomekeyring.ITEM_GENERIC_SECRET, self.app_name, attr,
76 # Creates the secret from the attributes76 secret, True)
77 secret = urlencode(attr)77
7878 def get_ubuntusso_attr(self):
79 # Create the keyring79 """Return the secret of the SSO item in a dictionary."""
80 self._create_keyring(self.KEYRING_NAME)80 # If we have no attributes, return None
8181 exist = self._get_item_info_from_name(self.KEYRING_NAME, self.app_name)
82 # If the item already exists, delete it82 if exist is not None:
83 if self._item_exists(self.KEYRING_NAME, self.app_name):83 secret = self._get_item_info_from_name(self.KEYRING_NAME,
84 item_id = self._get_item_id_from_name(self.KEYRING_NAME,84 self.app_name).get_secret()
85 self.app_name)85 return dict(parse_qsl(secret))
86 gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id)86
8787 def delete_ubuntusso_attr(self):
88 # Add our SSO item88 """Delete a set of credentials from the keyring."""
89 gnomekeyring.item_create_sync(self.KEYRING_NAME,89 item_id = self._get_item_id_from_name(self.KEYRING_NAME,
90 gnomekeyring.ITEM_GENERIC_SECRET, self.app_name, {},90 self.app_name)
91 secret, True)91 if item_id is not None:
9292 gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id)
93 def get_ubuntusso_attr(self):93
94 """94
95 Returns the secret of the SSO item in a dictionary95if __name__ == "__main__":
96 """96 kr1 = Keyring("Test key 1")
97 # If we have no attributes, return None97 kr2 = Keyring("Test key 2")
98 if self._get_item_info_from_name(self.KEYRING_NAME,98
99 self.app_name) == None:99 kr1.delete_ubuntusso_attr()
100 return None100 kr2.delete_ubuntusso_attr()
101 secret = self._get_item_info_from_name(self.KEYRING_NAME,101
102 self.app_name).get_secret()102 d1 = {"name": "test-1", "ha": "hehddddeff", "hi": "hggehes", "ho": "he"}
103 return dict(parse_qsl(secret))103 d2 = {"name": "test-2", "hi": "ho", "let's": "go"}
104104
105if __name__ == "__main__":105 kr1.set_ubuntusso_attr(d1)
106 SSO_ITEM_NAME = "Software Center UbuntuSSO token"106 kr2.set_ubuntusso_attr(d2)
107 keyring = Keyring(SSO_ITEM_NAME)107
108 keyring.set_ubuntusso_attr({"ha":"hehddddeff", "hi":"hggehes", "ho":"he"})108 r1 = kr1.get_ubuntusso_attr()
109 print keyring.get_ubuntusso_attr()109 r2 = kr2.get_ubuntusso_attr()
110110
111111 assert r1 == d1
112 assert r2 == d2
112113
=== modified file 'ubuntu_sso/main.py'
--- ubuntu_sso/main.py 2010-08-12 00:00:08 +0000
+++ ubuntu_sso/main.py 2010-08-19 17:58:43 +0000
@@ -199,8 +199,8 @@
199 logger.exception('login failed with:')199 logger.exception('login failed with:')
200 raise AuthenticationError()200 raise AuthenticationError()
201201
202 logger.debug('login: authentication successful! consumer_key: %r',202 logger.debug('login: authentication successful! consumer_key: %r, ' \
203 credentials['consumer_key'])203 'token_name: %r', credentials['consumer_key'], token_name)
204 keyring_store_credentials(app_name, credentials)204 keyring_store_credentials(app_name, credentials)
205 return credentials205 return credentials
206206
@@ -413,8 +413,8 @@
413class SSOCredentials(dbus.service.Object):413class SSOCredentials(dbus.service.Object):
414 """DBus object that gets credentials, and login/registers if needed."""414 """DBus object that gets credentials, and login/registers if needed."""
415415
416 @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="s")416 @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="")
417 def AuthorizationDenied(self, app_name):417 def AuthorizationDenied(self):
418 """Signal thrown when the user denies the authorization."""418 """Signal thrown when the user denies the authorization."""
419419
420 @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="a{ss}")420 @dbus.service.signal(DBUS_IFACE_CRED_NAME, signature="a{ss}")
421421
=== modified file 'ubuntu_sso/tests/test_gui.py'
--- ubuntu_sso/tests/test_gui.py 2010-08-12 00:00:08 +0000
+++ ubuntu_sso/tests/test_gui.py 2010-08-19 17:58:43 +0000
@@ -22,10 +22,10 @@
22import itertools22import itertools
23import logging23import logging
24import os24import os
25import socket
2625
27import dbus26import dbus
28import gtk27import gtk
28import webkit
2929
30from twisted.trial.unittest import TestCase30from twisted.trial.unittest import TestCase
3131
@@ -300,7 +300,6 @@
300 super(UbuntuSSOClientTestCase, self).setUp()300 super(UbuntuSSOClientTestCase, self).setUp()
301 self.patch(dbus, 'SessionBus', FakedSessionBus)301 self.patch(dbus, 'SessionBus', FakedSessionBus)
302 self.patch(dbus, 'Interface', FakedSSOBackend)302 self.patch(dbus, 'Interface', FakedSSOBackend)
303 self.patch(socket, 'gethostname', lambda: TOKEN_NAME)
304 self.pages = ('enter_details', 'processing', 'verify_email', 'success',303 self.pages = ('enter_details', 'processing', 'verify_email', 'success',
305 'tc_browser', 'login', 'request_password_token',304 'tc_browser', 'login', 'request_password_token',
306 'set_new_password')305 'set_new_password')
@@ -562,7 +561,7 @@
562 def test_initial_text_for_header_label(self):561 def test_initial_text_for_header_label(self):
563 """The header must have the correct text at startup."""562 """The header must have the correct text at startup."""
564 msg = 'Text for the header must be "%s" (got "%s" instead).'563 msg = 'Text for the header must be "%s" (got "%s" instead).'
565 expected = self.ui.JOIN_HEADER_LABEL % APP_NAME564 expected = self.ui.JOIN_HEADER_LABEL % {'app_name': APP_NAME}
566 actual = self.ui.header_label.get_text()565 actual = self.ui.header_label.get_text()
567 # text content is correct566 # text content is correct
568 self.assertEqual(expected, actual, msg % (expected, actual))567 self.assertEqual(expected, actual, msg % (expected, actual))
@@ -583,11 +582,11 @@
583 def test_initial_texts_for_checkbuttons(self):582 def test_initial_texts_for_checkbuttons(self):
584 """Check buttons have the correct text at startup."""583 """Check buttons have the correct text at startup."""
585 msg = 'Text for "%s" must be "%s" (got "%s" instead).'584 msg = 'Text for "%s" must be "%s" (got "%s" instead).'
586 expected = self.ui.YES_TO_UPDATES585 expected = self.ui.YES_TO_UPDATES % {'app_name': APP_NAME}
587 actual = self.ui.yes_to_updates_checkbutton.get_label()586 actual = self.ui.yes_to_updates_checkbutton.get_label()
588 self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton',587 self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton',
589 expected, actual))588 expected, actual))
590 expected = self.ui.YES_TO_TC589 expected = self.ui.YES_TO_TC % {'app_name': APP_NAME}
591 actual = self.ui.yes_to_tc_checkbutton.get_label()590 actual = self.ui.yes_to_tc_checkbutton.get_label()
592 self.assertEqual(expected, actual,591 self.assertEqual(expected, actual,
593 msg % ('yes_to_tc_checkbutton', expected, actual))592 msg % ('yes_to_tc_checkbutton', expected, actual))
@@ -731,6 +730,29 @@
731class TermsAndConditionsTestCase(UbuntuSSOClientTestCase):730class TermsAndConditionsTestCase(UbuntuSSOClientTestCase):
732 """Test suite for the user registration (terms & conditions page)."""731 """Test suite for the user registration (terms & conditions page)."""
733732
733 def test_tc_browser_is_created_when_tc_page_is_shown(self):
734 """The webkit browser is created when the TC page is shown."""
735 self.ui.tc_browser_vbox.show()
736
737 children = self.ui.tc_browser_window.get_children()
738 self.assertEqual(1, len(children))
739 browser = children[0]
740 self.assertIsInstance(browser, webkit.WebView)
741 self.assertTrue(browser.get_property('visible'))
742
743 self.ui.tc_browser_vbox.hide()
744
745 def test_tc_browser_is_destroyed_when_tc_page_is_hid(self):
746 """The webkit browser is destroyed when the TC page is hid."""
747 self.ui.tc_browser_vbox.show()
748 browser = self.ui.tc_browser_window.get_children()[0]
749 self.patch(browser, 'destroy', self._set_called)
750 self.ui.tc_browser_vbox.hide()
751
752 children = self.ui.tc_browser_window.get_children()
753 self.assertEqual(0, len(children))
754 self.assertEqual(self._called, ((), {}))
755
734 def test_tc_button_clicked_morphs_into_tc_browser_vbox(self):756 def test_tc_button_clicked_morphs_into_tc_browser_vbox(self):
735 """Terms & Conditions morphs to a browser window."""757 """Terms & Conditions morphs to a browser window."""
736 self.ui.tc_button.clicked()758 self.ui.tc_button.clicked()
@@ -1001,14 +1023,14 @@
1001 def test_initial_text_for_header_label(self):1023 def test_initial_text_for_header_label(self):
1002 """The header must have the correct text when logging in."""1024 """The header must have the correct text when logging in."""
1003 msg = 'Text for the header must be "%s" (got "%s" instead).'1025 msg = 'Text for the header must be "%s" (got "%s" instead).'
1004 expected = self.ui.LOGIN_HEADER_LABEL % APP_NAME1026 expected = self.ui.LOGIN_HEADER_LABEL % {'app_name': APP_NAME}
1005 actual = self.ui.header_label.get_text()1027 actual = self.ui.header_label.get_text()
1006 self.assertEqual(expected, actual, msg % (expected, actual))1028 self.assertEqual(expected, actual, msg % (expected, actual))
10071029
1008 def test_initial_text_for_help_label(self):1030 def test_initial_text_for_help_label(self):
1009 """The help must have the correct text at startup."""1031 """The help must have the correct text at startup."""
1010 msg = 'Text for the help must be "%s" (got "%s" instead).'1032 msg = 'Text for the help must be "%s" (got "%s" instead).'
1011 expected = self.ui.CONNECT_HELP_LABEL % APP_NAME1033 expected = self.ui.CONNECT_HELP_LABEL % {'app_name': APP_NAME}
1012 actual = self.ui.help_label.get_text()1034 actual = self.ui.help_label.get_text()
1013 self.assertEqual(expected, actual, msg % (expected, actual))1035 self.assertEqual(expected, actual, msg % (expected, actual))
10141036
@@ -1225,7 +1247,7 @@
1225 self.ui.on_password_reset_token_sent(email=EMAIL)1247 self.ui.on_password_reset_token_sent(email=EMAIL)
12261248
1227 self.assertEqual(self.ui.help_label.get_text(),1249 self.assertEqual(self.ui.help_label.get_text(),
1228 self.ui.SET_NEW_PASSWORD_LABEL % EMAIL)1250 self.ui.SET_NEW_PASSWORD_LABEL % {'email': EMAIL})
12291251
1230 def test_on_password_reset_token_sent_ok_button(self):1252 def test_on_password_reset_token_sent_ok_button(self):
1231 """After request_password_token_ok_button the ok button is updated."""1253 """After request_password_token_ok_button the ok button is updated."""
12321254
=== added file 'ubuntu_sso/tests/test_keyring.py'
--- ubuntu_sso/tests/test_keyring.py 1970-01-01 00:00:00 +0000
+++ ubuntu_sso/tests/test_keyring.py 2010-08-19 17:58:43 +0000
@@ -0,0 +1,115 @@
1# test_keyring - tests for ubuntu_sso.keyring
2#
3# Author: Alejandro J. Cura <alecu@canonical.com>
4#
5# Copyright 2010 Canonical Ltd.
6#
7# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 3, as published
9# by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranties of
13# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14# PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.
18"""Tests for the keyring.py module."""
19
20import gnomekeyring
21from twisted.trial.unittest import TestCase
22
23from ubuntu_sso import keyring
24
25
26class MockInfoSync(object):
27 """A mock object that represents a fake key."""
28
29 def __init__(self, (key, key_name, secret)):
30 """Initialize this instance."""
31 self.key = key
32 self.key_name = key_name
33 self.secret = secret
34
35 def get_display_name(self):
36 """Return info on the mocked object."""
37 return self.key_name
38
39
40class MockGnomeKeyring(object):
41 """A mock keyring that stores keys according to a given attr."""
42
43 def __init__(self):
44 """Initialize this instance."""
45 self.keyrings = set()
46 self.store = []
47 self.deleted = []
48
49 def item_create_sync(self, keyring_name, item_type, key_name, attr,
50 secret, update_if_exists):
51 """Sets a value in the keyring."""
52 # we'll use the attr as the dict key, so make it a tuple
53 key = tuple(attr.items())
54 self.store.append((key, key_name, secret))
55
56 def item_delete_sync(self, keyring_name, item_id):
57 """Makes a list of deleted items."""
58 key, key_name, secret = self.store.pop(item_id)
59 self.deleted.append(key_name)
60
61 def list_item_ids_sync(self, keyring_name):
62 """Return a list of ids for all the items."""
63 return [n for n, v in enumerate(self.store)]
64
65 def item_get_info_sync(self, keyring_name, item_id):
66 """Return an info sync object for the item."""
67 return MockInfoSync(self.store[item_id])
68
69 def list_keyring_names_sync(self):
70 """The keyring you are looking for may be here."""
71 return self.keyrings
72
73 def create_sync(self, name):
74 """Thanks, I'll create that keyring for you."""
75 self.keyrings.add(name)
76
77 def is_available(self):
78 """A very available keyring."""
79 return True
80
81
82class TestKeyring(TestCase):
83 """Test the gnome keyring related functions."""
84 def setUp(self):
85 """Initialize the mock used in these tests."""
86 self.mgk = MockGnomeKeyring()
87 self.patch(gnomekeyring, "item_create_sync", self.mgk.item_create_sync)
88 self.patch(gnomekeyring, "is_available", self.mgk.is_available)
89 self.patch(gnomekeyring, "create_sync", self.mgk.create_sync)
90 self.patch(gnomekeyring, "list_keyring_names_sync",
91 self.mgk.list_keyring_names_sync)
92 self.patch(gnomekeyring, "list_item_ids_sync",
93 self.mgk.list_item_ids_sync)
94 self.patch(gnomekeyring, "item_get_info_sync",
95 self.mgk.item_get_info_sync)
96 self.patch(gnomekeyring, "item_delete_sync", self.mgk.item_delete_sync)
97
98 def test_set_ubuntusso(self):
99 """Test that the set method does not erase previous keys."""
100 sample_creds = {"name": "sample creds name"}
101 sample_creds2 = {"name": "sample creds name 2"}
102 keyring.Keyring("appname").set_ubuntusso_attr(sample_creds)
103 keyring.Keyring("appname").set_ubuntusso_attr(sample_creds2)
104
105 self.assertEqual(len(self.mgk.store), 2)
106 self.assertEqual(len(self.mgk.deleted), 0)
107
108 def test_delete_ubuntusso(self):
109 """Test that a given key is deleted."""
110 sample_creds = {"name": "sample creds name"}
111 keyring.Keyring("appname").set_ubuntusso_attr(sample_creds)
112 keyring.Keyring("appname").delete_ubuntusso_attr()
113
114 self.assertEqual(len(self.mgk.store), 0)
115 self.assertEqual(len(self.mgk.deleted), 1)

Subscribers

People subscribed via source and target branches

to all changes: