Merge lp:~dobey/ubuntu-sso-client/update-4-0 into lp:ubuntu-sso-client/stable-4-0
- update-4-0
- Merge into stable-4-0
Proposed by
dobey
on 2012-09-10
| Status: | Merged |
|---|---|
| Approved by: | Roberto Alsina on 2012-09-10 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 969 |
| Proposed branch: | lp:~dobey/ubuntu-sso-client/update-4-0 |
| Merge into: | lp:ubuntu-sso-client/stable-4-0 |
| Diff against target: |
693 lines (+246/-36) 10 files modified
data/qt/current_user_sign_in.ui (+9/-1) data/qt/setup_account.ui (+28/-16) ubuntu_sso/qt/current_user_sign_in_page.py (+13/-0) ubuntu_sso/qt/setup_account_page.py (+6/-0) ubuntu_sso/qt/tests/test_current_user_sign_in_page.py (+18/-1) ubuntu_sso/qt/tests/test_setup_account.py (+40/-1) ubuntu_sso/qt/ubuntu_sso_wizard.py (+19/-11) ubuntu_sso/utils/ipc.py (+34/-6) ubuntu_sso/utils/tests/test_ipc.py (+77/-0) ubuntu_sso/utils/ui.py (+2/-0) |
| To merge this branch: | bzr merge lp:~dobey/ubuntu-sso-client/update-4-0 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Roberto Alsina (community) | 2012-09-10 | Approve on 2012-09-10 | |
|
Review via email:
|
|||
Description of the Change
To post a comment you must log in.
review:
Approve
lp:~dobey/ubuntu-sso-client/update-4-0
updated
on 2012-09-10
- 969. By Roberto Alsina on 2012-09-10
-
[Roberto Alsina]
- Added cross-links from/to signing/signup tabs (Fixes LP:974637)
[Manuel de la Peña]
- Re-start sso if we get a stale broker amd re-request all the remote objects (LP: #1043367).
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'data/qt/current_user_sign_in.ui' |
| 2 | --- data/qt/current_user_sign_in.ui 2012-03-05 20:40:24 +0000 |
| 3 | +++ data/qt/current_user_sign_in.ui 2012-09-10 20:23:21 +0000 |
| 4 | @@ -7,7 +7,7 @@ |
| 5 | <x>0</x> |
| 6 | <y>0</y> |
| 7 | <width>302</width> |
| 8 | - <height>244</height> |
| 9 | + <height>295</height> |
| 10 | </rect> |
| 11 | </property> |
| 12 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
| 13 | @@ -18,6 +18,13 @@ |
| 14 | <number>0</number> |
| 15 | </property> |
| 16 | <item> |
| 17 | + <widget class="QLabel" name="create_account_label"> |
| 18 | + <property name="text"> |
| 19 | + <string>Register with {app_name}.</string> |
| 20 | + </property> |
| 21 | + </widget> |
| 22 | + </item> |
| 23 | + <item> |
| 24 | <layout class="QVBoxLayout" name="verticalLayout"> |
| 25 | <property name="spacing"> |
| 26 | <number>3</number> |
| 27 | @@ -140,6 +147,7 @@ |
| 28 | <zorder>verticalSpacer</zorder> |
| 29 | <zorder>forgot_password_label</zorder> |
| 30 | <zorder></zorder> |
| 31 | + <zorder>create_account_label</zorder> |
| 32 | </widget> |
| 33 | <resources/> |
| 34 | <connections> |
| 35 | |
| 36 | === modified file 'data/qt/setup_account.ui' |
| 37 | --- data/qt/setup_account.ui 2012-03-20 15:05:19 +0000 |
| 38 | +++ data/qt/setup_account.ui 2012-09-10 20:23:21 +0000 |
| 39 | @@ -37,7 +37,7 @@ |
| 40 | <property name="verticalSpacing"> |
| 41 | <number>6</number> |
| 42 | </property> |
| 43 | - <item row="4" column="0" colspan="2"> |
| 44 | + <item row="5" column="0" colspan="2"> |
| 45 | <spacer name="verticalSpacer_2"> |
| 46 | <property name="orientation"> |
| 47 | <enum>Qt::Vertical</enum> |
| 48 | @@ -50,7 +50,7 @@ |
| 49 | </property> |
| 50 | </spacer> |
| 51 | </item> |
| 52 | - <item row="10" column="0" colspan="2"> |
| 53 | + <item row="11" column="0" colspan="2"> |
| 54 | <spacer name="verticalSpacer_3"> |
| 55 | <property name="orientation"> |
| 56 | <enum>Qt::Vertical</enum> |
| 57 | @@ -63,7 +63,7 @@ |
| 58 | </property> |
| 59 | </spacer> |
| 60 | </item> |
| 61 | - <item row="7" column="0" colspan="2"> |
| 62 | + <item row="8" column="0" colspan="2"> |
| 63 | <spacer name="verticalSpacer_4"> |
| 64 | <property name="orientation"> |
| 65 | <enum>Qt::Vertical</enum> |
| 66 | @@ -76,7 +76,7 @@ |
| 67 | </property> |
| 68 | </spacer> |
| 69 | </item> |
| 70 | - <item row="0" column="0"> |
| 71 | + <item row="1" column="0"> |
| 72 | <layout class="QVBoxLayout" name="verticalLayout_5"> |
| 73 | <property name="spacing"> |
| 74 | <number>3</number> |
| 75 | @@ -85,6 +85,7 @@ |
| 76 | <widget class="QLabel" name="name_label"> |
| 77 | <property name="font"> |
| 78 | <font> |
| 79 | + <weight>75</weight> |
| 80 | <bold>true</bold> |
| 81 | </font> |
| 82 | </property> |
| 83 | @@ -120,7 +121,7 @@ |
| 84 | </item> |
| 85 | </layout> |
| 86 | </item> |
| 87 | - <item row="2" column="0"> |
| 88 | + <item row="3" column="0"> |
| 89 | <layout class="QVBoxLayout" name="verticalLayout_6"> |
| 90 | <property name="spacing"> |
| 91 | <number>3</number> |
| 92 | @@ -129,6 +130,7 @@ |
| 93 | <widget class="QLabel" name="email_label"> |
| 94 | <property name="font"> |
| 95 | <font> |
| 96 | + <weight>75</weight> |
| 97 | <bold>true</bold> |
| 98 | </font> |
| 99 | </property> |
| 100 | @@ -167,7 +169,7 @@ |
| 101 | </item> |
| 102 | </layout> |
| 103 | </item> |
| 104 | - <item row="2" column="1"> |
| 105 | + <item row="3" column="1"> |
| 106 | <layout class="QVBoxLayout" name="verticalLayout_8"> |
| 107 | <property name="spacing"> |
| 108 | <number>0</number> |
| 109 | @@ -208,7 +210,7 @@ |
| 110 | </item> |
| 111 | </layout> |
| 112 | </item> |
| 113 | - <item row="3" column="0"> |
| 114 | + <item row="4" column="0"> |
| 115 | <layout class="QVBoxLayout" name="verticalLayout_10"> |
| 116 | <property name="spacing"> |
| 117 | <number>3</number> |
| 118 | @@ -217,6 +219,7 @@ |
| 119 | <widget class="QLabel" name="confirm_email_label"> |
| 120 | <property name="font"> |
| 121 | <font> |
| 122 | + <weight>75</weight> |
| 123 | <bold>true</bold> |
| 124 | </font> |
| 125 | </property> |
| 126 | @@ -255,7 +258,7 @@ |
| 127 | </item> |
| 128 | </layout> |
| 129 | </item> |
| 130 | - <item row="3" column="1"> |
| 131 | + <item row="4" column="1"> |
| 132 | <layout class="QVBoxLayout" name="verticalLayout_9"> |
| 133 | <property name="spacing"> |
| 134 | <number>0</number> |
| 135 | @@ -299,7 +302,7 @@ |
| 136 | </item> |
| 137 | </layout> |
| 138 | </item> |
| 139 | - <item row="11" column="0" colspan="2"> |
| 140 | + <item row="12" column="0" colspan="2"> |
| 141 | <layout class="QHBoxLayout" name="hlayout_check"> |
| 142 | <property name="spacing"> |
| 143 | <number>6</number> |
| 144 | @@ -309,7 +312,7 @@ |
| 145 | </property> |
| 146 | </layout> |
| 147 | </item> |
| 148 | - <item row="0" column="1"> |
| 149 | + <item row="1" column="1"> |
| 150 | <layout class="QVBoxLayout" name="verticalLayout_7"> |
| 151 | <property name="spacing"> |
| 152 | <number>0</number> |
| 153 | @@ -350,7 +353,7 @@ |
| 154 | </item> |
| 155 | </layout> |
| 156 | </item> |
| 157 | - <item row="5" column="0"> |
| 158 | + <item row="6" column="0"> |
| 159 | <layout class="QVBoxLayout" name="verticalLayout_3"> |
| 160 | <property name="spacing"> |
| 161 | <number>3</number> |
| 162 | @@ -359,6 +362,7 @@ |
| 163 | <widget class="QLabel" name="password_label"> |
| 164 | <property name="font"> |
| 165 | <font> |
| 166 | + <weight>75</weight> |
| 167 | <bold>true</bold> |
| 168 | </font> |
| 169 | </property> |
| 170 | @@ -406,7 +410,7 @@ |
| 171 | </item> |
| 172 | </layout> |
| 173 | </item> |
| 174 | - <item row="5" column="1" rowspan="2"> |
| 175 | + <item row="6" column="1" rowspan="2"> |
| 176 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
| 177 | <property name="spacing"> |
| 178 | <number>0</number> |
| 179 | @@ -444,7 +448,7 @@ |
| 180 | </item> |
| 181 | </layout> |
| 182 | </item> |
| 183 | - <item row="6" column="0"> |
| 184 | + <item row="7" column="0"> |
| 185 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
| 186 | <property name="spacing"> |
| 187 | <number>3</number> |
| 188 | @@ -453,6 +457,7 @@ |
| 189 | <widget class="QLabel" name="confirm_password_label"> |
| 190 | <property name="font"> |
| 191 | <font> |
| 192 | + <weight>75</weight> |
| 193 | <bold>true</bold> |
| 194 | </font> |
| 195 | </property> |
| 196 | @@ -494,7 +499,7 @@ |
| 197 | </item> |
| 198 | </layout> |
| 199 | </item> |
| 200 | - <item row="8" column="0"> |
| 201 | + <item row="9" column="0"> |
| 202 | <layout class="QVBoxLayout" name="verticalLayout_4"> |
| 203 | <property name="spacing"> |
| 204 | <number>3</number> |
| 205 | @@ -569,7 +574,7 @@ |
| 206 | </item> |
| 207 | </layout> |
| 208 | </item> |
| 209 | - <item row="1" column="0" colspan="2"> |
| 210 | + <item row="2" column="0" colspan="2"> |
| 211 | <spacer name="verticalSpacer"> |
| 212 | <property name="orientation"> |
| 213 | <enum>Qt::Vertical</enum> |
| 214 | @@ -582,7 +587,7 @@ |
| 215 | </property> |
| 216 | </spacer> |
| 217 | </item> |
| 218 | - <item row="8" column="1"> |
| 219 | + <item row="9" column="1"> |
| 220 | <layout class="QVBoxLayout" name="verticalLayout_13"> |
| 221 | <property name="rightMargin"> |
| 222 | <number>0</number> |
| 223 | @@ -617,6 +622,13 @@ |
| 224 | </item> |
| 225 | </layout> |
| 226 | </item> |
| 227 | + <item row="0" column="0"> |
| 228 | + <widget class="QLabel" name="sign_in_label"> |
| 229 | + <property name="text"> |
| 230 | + <string>Log-in with my existing account.</string> |
| 231 | + </property> |
| 232 | + </widget> |
| 233 | + </item> |
| 234 | </layout> |
| 235 | </item> |
| 236 | </layout> |
| 237 | |
| 238 | === modified file 'ubuntu_sso/qt/current_user_sign_in_page.py' |
| 239 | --- ubuntu_sso/qt/current_user_sign_in_page.py 2012-07-03 15:48:59 +0000 |
| 240 | +++ ubuntu_sso/qt/current_user_sign_in_page.py 2012-09-10 20:23:21 +0000 |
| 241 | @@ -40,6 +40,7 @@ |
| 242 | from ubuntu_sso.utils import compat |
| 243 | from ubuntu_sso.utils.ui import ( |
| 244 | CANCEL_BUTTON, |
| 245 | + CREATE_ACCOUNT_LABEL, |
| 246 | EMAIL_LABEL, |
| 247 | FORGOTTEN_PASSWORD_BUTTON, |
| 248 | is_correct_email, |
| 249 | @@ -59,6 +60,7 @@ |
| 250 | ui_class = Ui_CurrentUserSignInPage |
| 251 | userLoggedIn = QtCore.pyqtSignal(compat.text_type) |
| 252 | passwordForgotten = QtCore.pyqtSignal() |
| 253 | + createAccount = QtCore.pyqtSignal() |
| 254 | userNotValidated = QtCore.pyqtSignal(compat.text_type) |
| 255 | |
| 256 | @property |
| 257 | @@ -118,12 +120,17 @@ |
| 258 | forgotten_text = LINK_STYLE.format(link_url='#', |
| 259 | link_text=FORGOTTEN_PASSWORD_BUTTON) |
| 260 | self.ui.forgot_password_label.setText(forgotten_text) |
| 261 | + account_text = LINK_STYLE.format(link_url='#', |
| 262 | + link_text=CREATE_ACCOUNT_LABEL % {'app_name': self.app_name}) |
| 263 | + self.ui.create_account_label.setText(account_text) |
| 264 | self.ui.sign_in_button.setText(SIGN_IN_BUTTON) |
| 265 | |
| 266 | def _connect_ui(self): |
| 267 | """Connect the buttons to perform actions.""" |
| 268 | self.ui.forgot_password_label.linkActivated.connect( |
| 269 | self.on_forgotten_password) |
| 270 | + self.ui.create_account_label.linkActivated.connect( |
| 271 | + self.on_create_account) |
| 272 | self.ui.email_edit.textChanged.connect(self._validate) |
| 273 | self.ui.password_edit.textChanged.connect(self._validate) |
| 274 | self.ui.sign_in_button.clicked.connect(self.login) |
| 275 | @@ -175,3 +182,9 @@ |
| 276 | self.hide_overlay() |
| 277 | logger.debug('About to emit passwordForgotten signal') |
| 278 | self.passwordForgotten.emit() |
| 279 | + |
| 280 | + def on_create_account(self, link=None): |
| 281 | + """Show the user the account creation page.""" |
| 282 | + self.hide_overlay() |
| 283 | + logger.debug('About to emit createAccount signal') |
| 284 | + self.createAccount.emit() |
| 285 | |
| 286 | === modified file 'ubuntu_sso/qt/setup_account_page.py' |
| 287 | --- ubuntu_sso/qt/setup_account_page.py 2012-08-14 16:27:53 +0000 |
| 288 | +++ ubuntu_sso/qt/setup_account_page.py 2012-09-10 20:23:21 +0000 |
| 289 | @@ -86,6 +86,7 @@ |
| 290 | RETYPE_EMAIL, |
| 291 | RETYPE_PASSWORD, |
| 292 | SET_UP_ACCOUNT_BUTTON, |
| 293 | + SIGN_IN_LABEL, |
| 294 | TERMS_TEXT, |
| 295 | REGISTER_TITLE, |
| 296 | ) |
| 297 | @@ -101,6 +102,7 @@ |
| 298 | |
| 299 | ui_class = Ui_SetUpAccountPage |
| 300 | userRegistered = QtCore.pyqtSignal(compat.text_type) |
| 301 | + signIn = QtCore.pyqtSignal() |
| 302 | |
| 303 | def __init__(self, *args, **kwargs): |
| 304 | self.captcha_file = None |
| 305 | @@ -176,6 +178,9 @@ |
| 306 | self.setSubTitle(self.help_text) |
| 307 | |
| 308 | self.ui.name_label.setText(NAME_ENTRY) |
| 309 | + sign_in_link = LINK_STYLE.format(link_url='#', |
| 310 | + link_text=SIGN_IN_LABEL) |
| 311 | + self.ui.sign_in_label.setText(sign_in_link) |
| 312 | self.ui.email_label.setText(EMAIL1_ENTRY) |
| 313 | self.ui.confirm_email_label.setText(EMAIL2_ENTRY) |
| 314 | self.ui.password_label.setText(PASSWORD1_ENTRY) |
| 315 | @@ -259,6 +264,7 @@ |
| 316 | self.ui.captcha_solution_edit.textEdited.connect( |
| 317 | self._enable_setup_button) |
| 318 | self.terms_checkbox.stateChanged.connect(self._enable_setup_button) |
| 319 | + self.ui.sign_in_label.linkActivated.connect(self.signIn) |
| 320 | |
| 321 | self._refresh_captcha() |
| 322 | |
| 323 | |
| 324 | === modified file 'ubuntu_sso/qt/tests/test_current_user_sign_in_page.py' |
| 325 | --- ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2012-07-03 19:13:54 +0000 |
| 326 | +++ ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2012-09-10 20:23:21 +0000 |
| 327 | @@ -48,7 +48,8 @@ |
| 328 | """Test the SetupAccountPage code.""" |
| 329 | |
| 330 | ui_class = gui.CurrentUserSignInPage |
| 331 | - ui_signals = ('userLoggedIn', 'passwordForgotten', 'userNotValidated') |
| 332 | + ui_signals = ('userLoggedIn', 'passwordForgotten', 'userNotValidated', |
| 333 | + 'createAccount') |
| 334 | ui_backend_signals = ('LoggedIn', 'LoginError', 'UserNotValidated') |
| 335 | |
| 336 | def test_initialize_page(self): |
| 337 | @@ -86,6 +87,10 @@ |
| 338 | self.assert_subtitle_correct(expected) |
| 339 | self.assertEqual(compat.text_type(self.ui.ui.email_label.text()), |
| 340 | gui.EMAIL_LABEL) |
| 341 | + expected = gui.LINK_STYLE.format(link_url='#', |
| 342 | + link_text=gui.CREATE_ACCOUNT_LABEL % {'app_name': self.app_name}) |
| 343 | + self.assertEqual(compat.text_type( |
| 344 | + self.ui.ui.create_account_label.text()), expected) |
| 345 | self.assertEqual(compat.text_type(self.ui.ui.password_label.text()), |
| 346 | gui.LOGIN_PASSWORD_LABEL) |
| 347 | text = gui.LINK_STYLE.format(link_url='#', |
| 348 | @@ -107,6 +112,8 @@ |
| 349 | QtCore.SIGNAL("textChanged(const QString&)")), 1) |
| 350 | self.assertEqual(self.ui.ui.sign_in_button.receivers( |
| 351 | QtCore.SIGNAL("clicked()")), 1) |
| 352 | + self.assertEqual(self.ui.ui.create_account_label.receivers( |
| 353 | + QtCore.SIGNAL("linkActivated(const QString&)")), 1) |
| 354 | |
| 355 | def test_validate_not_valid(self): |
| 356 | """Test validate method.""" |
| 357 | @@ -191,3 +198,13 @@ |
| 358 | """Forgotten passsword clicked emits passwordForgotten signal.""" |
| 359 | self.assert_signal_emitted(self.ui.passwordForgotten, (), |
| 360 | self.ui.ui.forgot_password_label.linkActivated.emit, "link") |
| 361 | + |
| 362 | + def test_on_create_account(self): |
| 363 | + """Test the on_create_account method.""" |
| 364 | + self.assert_signal_emitted(self.ui.createAccount, (), |
| 365 | + self.ui.on_create_account) |
| 366 | + |
| 367 | + def test_on_create_account_link_clicked(self): |
| 368 | + """Create account clicked emits createAccount signal.""" |
| 369 | + self.assert_signal_emitted(self.ui.createAccount, (), |
| 370 | + self.ui.ui.create_account_label.linkActivated.emit, "link") |
| 371 | |
| 372 | === modified file 'ubuntu_sso/qt/tests/test_setup_account.py' |
| 373 | --- ubuntu_sso/qt/tests/test_setup_account.py 2012-08-14 23:15:15 +0000 |
| 374 | +++ ubuntu_sso/qt/tests/test_setup_account.py 2012-09-10 20:23:21 +0000 |
| 375 | @@ -41,7 +41,7 @@ |
| 376 | """Test the SetupAccountPage code.""" |
| 377 | |
| 378 | ui_class = gui.SetupAccountPage |
| 379 | - ui_signals = ('userRegistered',) |
| 380 | + ui_signals = ('userRegistered', 'signIn') |
| 381 | ui_backend_signals = ('CaptchaGenerated', 'CaptchaGenerationError', |
| 382 | 'UserRegistered', 'UserRegistrationError') |
| 383 | |
| 384 | @@ -234,6 +234,15 @@ |
| 385 | self.assertEqual( |
| 386 | compat.text_type(self.ui.ui.confirm_password_label.text()), |
| 387 | gui.RETYPE_PASSWORD) |
| 388 | + expected = gui.LINK_STYLE.format(link_url='#', |
| 389 | + link_text=gui.SIGN_IN_LABEL) |
| 390 | + self.assertEqual( |
| 391 | + compat.text_type(self.ui.ui.sign_in_label.text()), |
| 392 | + expected) |
| 393 | + |
| 394 | + # connections |
| 395 | + self.assertEqual(self.ui.set_up_button.receivers( |
| 396 | + QtCore.SIGNAL("clicked(const bool)")), 1) |
| 397 | |
| 398 | # assistants |
| 399 | self.assertFalse(self.ui.ui.name_assistance.isVisible()) |
| 400 | @@ -242,6 +251,36 @@ |
| 401 | self.assertFalse(self.ui.ui.password_assistance.isVisible()) |
| 402 | self.assertTrue(self.ui.ui.refresh_label.isVisible()) |
| 403 | |
| 404 | + def test_connect_ui(self): |
| 405 | + """Test the connect ui method.""" |
| 406 | + self.assertEqual(self.ui.ui.password_edit.receivers( |
| 407 | + QtCore.SIGNAL("textEdited(const QString&)")), 2) |
| 408 | + self.assertEqual(self.ui.ui.refresh_label.receivers( |
| 409 | + QtCore.SIGNAL("linkActivated(const QString&)")), 2) |
| 410 | + self.assertEqual(self.ui.ui.name_edit.receivers( |
| 411 | + QtCore.SIGNAL("textEdited(const QString&)")), 1) |
| 412 | + self.assertEqual(self.ui.ui.email_edit.receivers( |
| 413 | + QtCore.SIGNAL("textEdited(const QString&)")), 1) |
| 414 | + self.assertEqual(self.ui.ui.confirm_email_edit.receivers( |
| 415 | + QtCore.SIGNAL("textEdited(const QString&)")), 1) |
| 416 | + self.assertEqual(self.ui.ui.password_edit.receivers( |
| 417 | + QtCore.SIGNAL("textEdited(const QString&)")), 2) |
| 418 | + self.assertEqual(self.ui.ui.confirm_password_edit.receivers( |
| 419 | + QtCore.SIGNAL("textEdited(const QString&)")), 1) |
| 420 | + self.assertEqual(self.ui.ui.sign_in_label.receivers( |
| 421 | + QtCore.SIGNAL("linkActivated(const QString&)")), 1) |
| 422 | + |
| 423 | + def test_connect_ui_2(self): |
| 424 | + """Test more connections from connect_ui""" |
| 425 | + |
| 426 | + # |
| 427 | + self.assertEqual(self.ui.ui.captcha_solution_edit.receivers( |
| 428 | + QtCore.SIGNAL("textEdited(const QString&)")), 1) |
| 429 | + self.assertEqual(self.ui.terms_checkbox.receivers( |
| 430 | + QtCore.SIGNAL("stateChanged(bool)")), 1) |
| 431 | + |
| 432 | + test_connect_ui_2.skip = "These oscilate 0/1 (LP:1046885)" |
| 433 | + |
| 434 | def test_set_up_button_clicked(self): |
| 435 | """Validation and overlay is shown when the setupbutton is clicked.""" |
| 436 | self.patch(self.ui, 'set_next_validation', self._set_called) |
| 437 | |
| 438 | === modified file 'ubuntu_sso/qt/ubuntu_sso_wizard.py' |
| 439 | --- ubuntu_sso/qt/ubuntu_sso_wizard.py 2012-07-03 16:31:45 +0000 |
| 440 | +++ ubuntu_sso/qt/ubuntu_sso_wizard.py 2012-09-10 20:23:21 +0000 |
| 441 | @@ -96,11 +96,13 @@ |
| 442 | self.addPage(self.network_page) |
| 443 | |
| 444 | # set the diff pages of the QWizard |
| 445 | - if not self.login_only: |
| 446 | - self.setup_account = SetupAccountPage(**kwargs) |
| 447 | - self.setup_account.userRegistered.connect( |
| 448 | - self._move_to_email_verification_page) |
| 449 | - self.addPage(self.setup_account) |
| 450 | + self.setup_account = SetupAccountPage(**kwargs) |
| 451 | + self.setup_account.userRegistered.connect( |
| 452 | + self._move_to_email_verification_page) |
| 453 | + # There are no tests for signal connections on |
| 454 | + # this file (LP:1046886) |
| 455 | + self.setup_account.signIn.connect(self._move_to_login_page) |
| 456 | + self.addPage(self.setup_account) |
| 457 | |
| 458 | self.current_user = CurrentUserSignInPage(**kwargs) |
| 459 | self.current_user.userNotValidated.connect( |
| 460 | @@ -108,6 +110,8 @@ |
| 461 | self.current_user.userLoggedIn.connect(self._move_to_success_page) |
| 462 | self.current_user.passwordForgotten.connect( |
| 463 | self._move_to_forgotten_page) |
| 464 | + self.current_user.createAccount.connect( |
| 465 | + self._move_to_setup_account_page) |
| 466 | self.addPage(self.current_user) |
| 467 | |
| 468 | self.email_verification = EmailVerificationPage(**kwargs) |
| 469 | @@ -144,6 +148,12 @@ |
| 470 | self.setMinimumSize(PREFERED_UI_SIZE['width'], |
| 471 | PREFERED_UI_SIZE['height']) |
| 472 | |
| 473 | + # This is missing tests (LP:1046887) |
| 474 | + if self.login_only: |
| 475 | + self._move_to_login_page() |
| 476 | + else: |
| 477 | + self._move_to_setup_account_page() |
| 478 | + |
| 479 | @defer.inlineCallbacks |
| 480 | def check_network_connection(self): |
| 481 | """Check if the NetworkDetectionPage is needed to be shown.""" |
| 482 | @@ -213,17 +223,15 @@ |
| 483 | """Move to the setup account page wizard.""" |
| 484 | logger.debug('Moving to SetupAccountPage from: %s', |
| 485 | self.currentPage()) |
| 486 | - self._next_id = self.setup_account_page_id |
| 487 | - self.next() |
| 488 | - self._next_id = -1 |
| 489 | + self.setStartId(self.setup_account_page_id) |
| 490 | + self.restart() |
| 491 | |
| 492 | def _move_to_login_page(self): |
| 493 | """Move to the login page wizard.""" |
| 494 | logger.debug('Moving to CurrentUserSignInPage from: %s', |
| 495 | self.currentPage()) |
| 496 | - self._next_id = self.current_user_page_id |
| 497 | - self.next() |
| 498 | - self._next_id = -1 |
| 499 | + self.setStartId(self.current_user_page_id) |
| 500 | + self.restart() |
| 501 | |
| 502 | def _move_to_success_page(self): |
| 503 | """Move to the success page wizard.""" |
| 504 | |
| 505 | === modified file 'ubuntu_sso/utils/ipc.py' |
| 506 | --- ubuntu_sso/utils/ipc.py 2012-08-09 21:17:19 +0000 |
| 507 | +++ ubuntu_sso/utils/ipc.py 2012-09-10 20:23:21 +0000 |
| 508 | @@ -237,10 +237,11 @@ |
| 509 | call_remote_functions = [] # methods that can be called on the remote obj |
| 510 | signal_handlers = [] # signals that are of interest of this client |
| 511 | |
| 512 | - def __init__(self, remote_object): |
| 513 | + def __init__(self, base_client, remote_object): |
| 514 | """Create instance.""" |
| 515 | super(RemoteClient, self).__init__() |
| 516 | self._mapping = defaultdict(list) |
| 517 | + self.base_client = base_client |
| 518 | self.remote = remote_object |
| 519 | |
| 520 | # for each function name in self.call_remote_functions, |
| 521 | @@ -284,6 +285,7 @@ |
| 522 | |
| 523 | return callback_wrapper |
| 524 | |
| 525 | + @defer.inlineCallbacks |
| 526 | def call_method(self, method_name, *args, **kwargs): |
| 527 | """Call asynchronously 'method_name(*args)'. |
| 528 | |
| 529 | @@ -293,13 +295,23 @@ |
| 530 | """ |
| 531 | logger.debug('Performing %r as a remote call (%r, %r).', |
| 532 | method_name, args, kwargs) |
| 533 | - result = self.remote.callRemote(method_name, *args) |
| 534 | - return result |
| 535 | + try: |
| 536 | + result = yield self.remote.callRemote(method_name, *args) |
| 537 | + except DeadReferenceError: |
| 538 | + yield self.base_client.reconnect() |
| 539 | + result = yield self.call_method(method_name, *args, **kwargs) |
| 540 | + defer.returnValue(result) |
| 541 | |
| 542 | + @defer.inlineCallbacks |
| 543 | def register_to_signals(self): |
| 544 | """Register to the signals.""" |
| 545 | - return self.remote.callRemote('register_to_signals', self, |
| 546 | - self.signal_handlers) |
| 547 | + try: |
| 548 | + result = yield self.remote.callRemote('register_to_signals', self, |
| 549 | + self.signal_handlers) |
| 550 | + except DeadReferenceError: |
| 551 | + yield self.base_client.reconnect() |
| 552 | + result = yield self.register_to_signals() |
| 553 | + defer.returnValue(result) |
| 554 | |
| 555 | def unregister_to_signals(self): |
| 556 | """Register to the signals.""" |
| 557 | @@ -352,7 +364,7 @@ |
| 558 | self.clients.keys(), self.__class__.__name__) |
| 559 | for name, client_class in self.clients.items(): |
| 560 | remote = yield root.callRemote('get_%s' % name) |
| 561 | - setattr(self, name, client_class(remote)) |
| 562 | + setattr(self, name, client_class(self, remote)) |
| 563 | |
| 564 | @defer.inlineCallbacks |
| 565 | def connect(self): |
| 566 | @@ -367,6 +379,22 @@ |
| 567 | yield self.register_to_signals() |
| 568 | |
| 569 | @defer.inlineCallbacks |
| 570 | + def reconnect(self): |
| 571 | + """Reconnect with the server.""" |
| 572 | + self.factory = PBClientFactory() |
| 573 | + self.client = yield client_connect(self.factory, |
| 574 | + self.service_name, |
| 575 | + self.service_cmdline, |
| 576 | + self.service_description) |
| 577 | + root = yield self.factory.getRootObject() |
| 578 | + # loop over the already present remote clients and reset their remotes |
| 579 | + for name in self.clients: |
| 580 | + remote = yield root.callRemote('get_%s' % name) |
| 581 | + remote_client = getattr(self, name) |
| 582 | + remote_client.remote = remote |
| 583 | + yield self.register_to_signals() |
| 584 | + |
| 585 | + @defer.inlineCallbacks |
| 586 | def register_to_signals(self): |
| 587 | """Register all the clients to their signals.""" |
| 588 | for name in self.clients: |
| 589 | |
| 590 | === modified file 'ubuntu_sso/utils/tests/test_ipc.py' |
| 591 | --- ubuntu_sso/utils/tests/test_ipc.py 2012-08-14 20:37:42 +0000 |
| 592 | +++ ubuntu_sso/utils/tests/test_ipc.py 2012-09-10 20:23:21 +0000 |
| 593 | @@ -619,3 +619,80 @@ |
| 594 | fake_remote_client.random_exception, |
| 595 | ) |
| 596 | self.assertTrue(self.memento.check_warning(*expected)) |
| 597 | + |
| 598 | + |
| 599 | +class FakeRootObject(object): |
| 600 | + """A fake root object.""" |
| 601 | + |
| 602 | + def __init__(self, called, remote_obj): |
| 603 | + """Create a new instance.""" |
| 604 | + self.called = called |
| 605 | + self.remote_obj = remote_obj |
| 606 | + |
| 607 | + # pylint: disable=C0103 |
| 608 | + def callRemote(self, method_name): |
| 609 | + """A fake call remove method.""" |
| 610 | + self.called.append(method_name) |
| 611 | + return defer.succeed(self.remote_obj) |
| 612 | + # pylint: enable=C0103 |
| 613 | + |
| 614 | + |
| 615 | +class FakeWorkingRemoteClient(object): |
| 616 | + """A fake remote client.""" |
| 617 | + |
| 618 | + def __init__(self, called): |
| 619 | + """Create a new instance.""" |
| 620 | + self.remote = None |
| 621 | + self.called = called |
| 622 | + |
| 623 | + def register_to_signals(self): |
| 624 | + """Register to signals.""" |
| 625 | + self.called.append('register_to_signals') |
| 626 | + return defer.succeed(True) |
| 627 | + |
| 628 | + |
| 629 | +class ReconnectTestCase(TestCase): |
| 630 | + """Test the reconnection when sso is dead.""" |
| 631 | + |
| 632 | + @defer.inlineCallbacks |
| 633 | + def setUp(self): |
| 634 | + """Set the different tests.""" |
| 635 | + yield super(ReconnectTestCase, self).setUp() |
| 636 | + self.called = [] |
| 637 | + self.remote_obj = 'remote' |
| 638 | + self.root_obj = FakeRootObject(self.called, self.remote_obj) |
| 639 | + |
| 640 | + def fake_get_root_object(): |
| 641 | + """Fake getting the root object.""" |
| 642 | + self.called.append('getRootObject') |
| 643 | + return defer.succeed(self.root_obj) |
| 644 | + |
| 645 | + def fake_client_connect(factory, service_name, cmd, description): |
| 646 | + """Fake the client connect.""" |
| 647 | + self.called.append('client_connect') |
| 648 | + self.patch(factory, 'getRootObject', fake_get_root_object) |
| 649 | + return defer.succeed(True) |
| 650 | + |
| 651 | + self.patch(ipc, 'client_connect', fake_client_connect) |
| 652 | + |
| 653 | + @defer.inlineCallbacks |
| 654 | + def test_reconnect_method(self): |
| 655 | + """Test the execcution of the reconnect method.""" |
| 656 | + clients = dict(first=FakeWorkingRemoteClient(self.called), |
| 657 | + second=FakeWorkingRemoteClient(self.called)) |
| 658 | + |
| 659 | + base_client = ipc.BaseClient() |
| 660 | + base_client.clients = clients |
| 661 | + for name, client in clients.items(): |
| 662 | + setattr(base_client, name, client) |
| 663 | + |
| 664 | + yield base_client.reconnect() |
| 665 | + # assert that we did call the correct methods |
| 666 | + self.assertIn('client_connect', self.called) |
| 667 | + self.assertIn('getRootObject', self.called) |
| 668 | + |
| 669 | + for name in clients: |
| 670 | + self.assertIn('get_%s' % name, self.called) |
| 671 | + |
| 672 | + self.assertEqual(len(clients), |
| 673 | + self.called.count('register_to_signals')) |
| 674 | |
| 675 | === modified file 'ubuntu_sso/utils/ui.py' |
| 676 | --- ubuntu_sso/utils/ui.py 2012-08-14 16:30:09 +0000 |
| 677 | +++ ubuntu_sso/utils/ui.py 2012-09-10 20:23:21 +0000 |
| 678 | @@ -64,6 +64,7 @@ |
| 679 | CONGRATULATIONS = _("Congratulations, {app_name} is installed!") |
| 680 | CONNECT_HELP_LABEL = _('To connect this computer to %(app_name)s enter your ' |
| 681 | 'details below.') |
| 682 | +CREATE_ACCOUNT_LABEL = _('Register with {app_name}.') |
| 683 | EMAIL_LABEL = EMAIL1_ENTRY = _('Email address') |
| 684 | EMAIL2_ENTRY = _('Re-type Email address') |
| 685 | EMAIL_INVALID = _('The email must be a valid email address.') |
| 686 | @@ -146,6 +147,7 @@ |
| 687 | SET_UP_ACCOUNT_BUTTON = _('Set Up Account') |
| 688 | SET_UP_ACCOUNT_CHOICE_BUTTON = _('I don\'t have an account yet - sign me up') |
| 689 | SIGN_IN_BUTTON = _('Sign In') |
| 690 | +SIGN_IN_LABEL = _('Log-in with my existing account.') |
| 691 | SSL_APPNAME_HELP = _('the appname whose ssl error we are going to show.') |
| 692 | SSL_CERT_DETAILS = _('Certificate details') |
| 693 | SSL_CONNECT_BUTTON = _('Connect') |
