Merge lp:~mandel/ubuntu-sso-client/ssl-checkbox into lp:ubuntu-sso-client

Proposed by Manuel de la Peña on 2012-03-15
Status: Rejected
Rejected by: Manuel de la Peña on 2012-04-02
Proposed branch: lp:~mandel/ubuntu-sso-client/ssl-checkbox
Merge into: lp:ubuntu-sso-client
Prerequisite: lp:~mandel/ubuntu-sso-client/pinned-certs
Diff against target: 151 lines (+46/-7)
5 files modified
ubuntu_sso/__init__.py (+1/-0)
ubuntu_sso/qt/ssl_dialog.py (+6/-2)
ubuntu_sso/qt/tests/test_ssl_dialog.py (+10/-1)
ubuntu_sso/utils/webclient/common.py (+5/-3)
ubuntu_sso/utils/webclient/tests/test_webclient.py (+24/-1)
To merge this branch: bzr merge lp:~mandel/ubuntu-sso-client/ssl-checkbox
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Disapprove on 2012-04-02
dobey (community) Needs Fixing on 2012-03-16
Roberto Alsina (community) 2012-03-15 Approve on 2012-03-15
Review via email: mp+97619@code.launchpad.net

Commit Message

- Added the required changes in the ssl dialog and in the common webclient code to only store pinned certificates when the user has checked the box in the ui (LP: #955831).

Description of the Change

- Added the required changes in the ssl dialog and in the common webclient code to only store pinned certificates when the user has checked the box in the ui (LP: #955831).

To post a comment you must log in.
953. By Manuel de la Peña on 2012-03-15

Merged pinned-certs into ssl-checkbox.

Roberto Alsina (ralsina) wrote :

Looks good!

review: Approve
dobey (dobey) wrote :

This generally looks good to me. However, I would prefer if REMEMBER_SETTINGS were renamed to STORE_SSL_CERT or something more apropos to what it's actually doing.

review: Needs Fixing
Manuel de la Peña (mandel) wrote :

We will not use this code atm.

review: Disapprove

Unmerged revisions

953. By Manuel de la Peña on 2012-03-15

Merged pinned-certs into ssl-checkbox.

952. By Manuel de la Peña on 2012-03-15

Ensured that the fact that the user checked the box to remember the ssl certificate is taken into account.

951. By Manuel de la Peña on 2012-03-15

Merged libsoup-ssl-dialog into pinned-certs.

950. By Manuel de la Peña on 2012-03-14

Merged libsoup-ssl-dialog into pinned-certs.

949. By Manuel de la Peña on 2012-03-14

Added the required code to store the pinned certificates in order to not promp the ssl dialog constantly.

948. By Manuel de la Peña on 2012-03-13

Pass the cert pem from the child WebClient implementations to the base class.

947. By Manuel de la Peña on 2012-03-12

Reduced diff size.

946. By Manuel de la Peña on 2012-03-12

Reduced diff size.

945. By Manuel de la Peña on 2012-03-12

Merged with trunk.

944. By Manuel de la Peña on 2012-03-12

Added the required code to let the libsoup webclient implementation deal with ssl cert errors.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/__init__.py'
2--- ubuntu_sso/__init__.py 2012-03-08 12:35:25 +0000
3+++ ubuntu_sso/__init__.py 2012-03-15 11:43:20 +0000
4@@ -30,6 +30,7 @@
5 USER_SUCCESS = 0
6 USER_CANCELLATION = 10
7 EXCEPTION_RAISED = 11
8+REMEMBER_SETTINGS = 12
9
10 # available UIs
11 UI_EXECUTABLE_GTK = 'ubuntu-sso-login-gtk'
12
13=== modified file 'ubuntu_sso/qt/ssl_dialog.py'
14--- ubuntu_sso/qt/ssl_dialog.py 2012-03-15 11:43:20 +0000
15+++ ubuntu_sso/qt/ssl_dialog.py 2012-03-15 11:43:20 +0000
16@@ -18,6 +18,7 @@
17 import argparse
18 import sys
19
20+from PyQt4.QtCore import Qt
21 from PyQt4.QtGui import (
22 QApplication,
23 QDialog,
24@@ -26,7 +27,7 @@
25 QTextEdit,
26 )
27
28-from ubuntu_sso import USER_CANCELLATION, USER_SUCCESS
29+from ubuntu_sso import REMEMBER_SETTINGS, USER_CANCELLATION, USER_SUCCESS
30 from ubuntu_sso.logger import setup_gui_logging
31 # Unused import resources_rc, pylint: disable=W0611
32 from ubuntu_sso.qt.ui import resources_rc
33@@ -108,7 +109,10 @@
34 def _on_connect_clicked(self):
35 """Connect was clicked."""
36 logger.debug('User accepted the ssl certificate.')
37- self.done(USER_SUCCESS)
38+ result = USER_SUCCESS
39+ if self.ui.remember_checkbox.checkState() == Qt.Checked:
40+ result = REMEMBER_SETTINGS
41+ self.done(result)
42
43 def _set_buttons(self):
44 """Set the labels of the buttons."""
45
46=== modified file 'ubuntu_sso/qt/tests/test_ssl_dialog.py'
47--- ubuntu_sso/qt/tests/test_ssl_dialog.py 2012-03-12 19:47:07 +0000
48+++ ubuntu_sso/qt/tests/test_ssl_dialog.py 2012-03-15 11:43:20 +0000
49@@ -16,11 +16,12 @@
50
51 """Test the ssl dialog."""
52
53+from PyQt4.QtCore import Qt
54 from PyQt4.QtGui import QStyle
55 from twisted.internet import defer
56 from twisted.trial.unittest import TestCase
57
58-from ubuntu_sso import USER_CANCELLATION, USER_SUCCESS
59+from ubuntu_sso import REMEMBER_SETTINGS, USER_CANCELLATION, USER_SUCCESS
60 from ubuntu_sso.qt import ssl_dialog
61 from ubuntu_sso.utils.ui import (
62 CANCEL_BUTTON,
63@@ -103,6 +104,14 @@
64 """Test the connect action."""
65 self.dialog._on_connect_clicked()
66 self.assertEqual(USER_SUCCESS, self.return_code)
67+ self.assertEqual(Qt.Unchecked,
68+ self.dialog.ui.remember_checkbox.checkState())
69+
70+ def test_on_connect_clicked_remember(self):
71+ """Test the connect action."""
72+ self.dialog.ui.remember_checkbox.setCheckState(Qt.Checked)
73+ self.dialog._on_connect_clicked()
74+ self.assertEqual(REMEMBER_SETTINGS, self.return_code)
75
76 def test_set_buttons(self):
77 """Test that the buttons are correctly set up."""
78
79=== modified file 'ubuntu_sso/utils/webclient/common.py'
80--- ubuntu_sso/utils/webclient/common.py 2012-03-15 11:43:20 +0000
81+++ ubuntu_sso/utils/webclient/common.py 2012-03-15 11:43:20 +0000
82@@ -25,7 +25,7 @@
83 from twisted.internet import defer
84 from urlparse import urlparse
85
86-from ubuntu_sso import USER_SUCCESS, UI_PROXY_CREDS_DIALOG
87+from ubuntu_sso import REMEMBER_SETTINGS, USER_SUCCESS, UI_PROXY_CREDS_DIALOG
88 from ubuntu_sso.logger import setup_logging
89 from ubuntu_sso.utils.runner import spawn_program
90 from ubuntu_sso.utils.ui import SSL_DETAILS_TEMPLATE
91@@ -275,6 +275,8 @@
92 return_code = yield self._launch_ssl_dialog(
93 subject_details['common_name'],
94 details)
95- if return_code == USER_SUCCESS:
96+ if return_code == REMEMBER_SETTINGS:
97 self.ssl_vault.store_certificate(cert)
98- defer.returnValue(return_code == USER_SUCCESS)
99+ result = (return_code == USER_SUCCESS
100+ or return_code == REMEMBER_SETTINGS)
101+ defer.returnValue(result)
102
103=== modified file 'ubuntu_sso/utils/webclient/tests/test_webclient.py'
104--- ubuntu_sso/utils/webclient/tests/test_webclient.py 2012-03-15 11:43:20 +0000
105+++ ubuntu_sso/utils/webclient/tests/test_webclient.py 2012-03-15 11:43:20 +0000
106@@ -33,6 +33,7 @@
107 from ubuntu_sso import (
108 keyring,
109 EXCEPTION_RAISED,
110+ REMEMBER_SETTINGS,
111 USER_SUCCESS,
112 USER_CANCELLATION,
113 )
114@@ -1012,7 +1013,7 @@
115 details = SSL_DETAILS_TEMPLATE % self.cert_details
116 self.assertIn(('_launch_ssl_dialog', gethostname(), details),
117 self.called)
118- self.assertTrue(self.wc.ssl_vault.is_certificate_pinned(
119+ self.assertFalse(self.wc.ssl_vault.is_certificate_pinned(
120 self.ssl_settings['cert_info']))
121
122 def test_ssl_fail_dialog_user_accepts(self):
123@@ -1033,6 +1034,28 @@
124 self.ssl_settings['cert_info']))
125
126 @defer.inlineCallbacks
127+ def _assert_ssl_fail_user_remembers(self, proxy_settings=None):
128+ """Assert the dialog is shown in an ssl fail and remember the cert."""
129+ self.return_code = REMEMBER_SETTINGS
130+ if proxy_settings:
131+ self.wc.force_use_proxy(proxy_settings)
132+ yield self.wc.request(self.base_ssl_iri + SIMPLERESOURCE)
133+ details = SSL_DETAILS_TEMPLATE % self.cert_details
134+ self.assertIn(('_launch_ssl_dialog', gethostname(), details),
135+ self.called)
136+ self.assertTrue(self.wc.ssl_vault.is_certificate_pinned(
137+ self.ssl_settings['cert_info']))
138+
139+ def test_ssl_fail_dialog_user_remembers(self):
140+ """Test showing the dialog, accepting and remember the settings."""
141+ return self._assert_ssl_fail_user_remembers()
142+
143+ def test_ssl_fail_dialog_user_remembers_via_proxy(self):
144+ """Test showing the dialog, accepting and remember the settings."""
145+ return self._assert_ssl_fail_user_remembers(
146+ self.get_nonauth_proxy_settings())
147+
148+ @defer.inlineCallbacks
149 def test_ssl_fail_pinned_cert(self):
150 """Test when the cert is pinned."""
151 self.patch(self.wc.ssl_vault, 'is_certificate_pinned', lambda _: True)

Subscribers

People subscribed via source and target branches