Merge lp:~nataliabidart/ubuntu/natty/ubuntu-sso-client/ubuntu-sso-client-1.1.10 into lp:ubuntu/natty/ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Merged at revision: 25
Proposed branch: lp:~nataliabidart/ubuntu/natty/ubuntu-sso-client/ubuntu-sso-client-1.1.10
Merge into: lp:ubuntu/natty/ubuntu-sso-client
Diff against target: 235 lines (+108/-15)
5 files modified
PKG-INFO (+1/-1)
debian/changelog (+12/-0)
setup.py (+1/-1)
ubuntu_sso/main.py (+11/-3)
ubuntu_sso/tests/test_main.py (+83/-10)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu/natty/ubuntu-sso-client/ubuntu-sso-client-1.1.10
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Pending
Review via email: mp+47831@code.launchpad.net

Description of the change

  * New upstream release:

    [ Natalia B. Bidart <email address hidden> ]
      - The service is not shutdown if ref count is not zero, even if the
        shutdown_func was queued (LP: #709200).
      - Test failures (caused by a buggy test) fixed (LP: #704941).

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 2011-01-25 13:56:41 +0000
3+++ PKG-INFO 2011-01-28 16:47:53 +0000
4@@ -1,6 +1,6 @@
5 Metadata-Version: 1.1
6 Name: ubuntu-sso-client
7-Version: 1.1.9
8+Version: 1.1.10
9 Summary: Ubuntu Single Sign-On client
10 Home-page: https://launchpad.net/ubuntu-sso-client
11 Author: Natalia Bidart
12
13=== modified file 'debian/changelog'
14--- debian/changelog 2011-01-25 15:02:18 +0000
15+++ debian/changelog 2011-01-28 16:47:53 +0000
16@@ -1,3 +1,15 @@
17+ubuntu-sso-client (1.1.10-0ubuntu1) UNRELEASED; urgency=low
18+
19+ * New upstream release:
20+
21+ [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
22+ - The service is not shutdown if ref count is not zero, even if the
23+    shutdown_func was queued (LP: #709200).
24+ - Test failures (caused by a buggy test) fixed (LP: #704941).
25+
26+
27+ -- Natalia Bidart (nessita) <nataliabidart@gmail.com> Fri, 28 Jan 2011 13:38:28 -0300
28+
29 ubuntu-sso-client (1.1.9-0ubuntu1) natty; urgency=low
30
31 * New upstream release:
32
33=== modified file 'setup.py'
34--- setup.py 2011-01-25 13:56:41 +0000
35+++ setup.py 2011-01-28 16:47:53 +0000
36@@ -86,7 +86,7 @@
37
38 DistUtilsExtra.auto.setup(
39 name='ubuntu-sso-client',
40- version='1.1.9',
41+ version='1.1.10',
42 license='GPL v3',
43 author='Natalia Bidart',
44 author_email='natalia.bidart@canonical.com',
45
46=== modified file 'ubuntu_sso/main.py'
47--- ubuntu_sso/main.py 2011-01-12 18:56:56 +0000
48+++ ubuntu_sso/main.py 2011-01-28 16:47:53 +0000
49@@ -50,7 +50,7 @@
50
51 logger = setup_logging("ubuntu_sso.main")
52 U1_PING_URL = "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/"
53-TIMEOUT_INTERVAL = 500
54+TIMEOUT_INTERVAL = 10000 # 10 seconds
55
56
57 class SSOLoginProcessor(Account):
58@@ -449,7 +449,6 @@
59
60 def _get_ref_count(self):
61 """Get value of ref_count."""
62- logger.debug('ref_count is %r.', self._ref_count)
63 return self._ref_count
64
65 def _set_ref_count(self, new_value):
66@@ -464,10 +463,19 @@
67 self._ref_count = new_value
68
69 if self._ref_count == 0:
70- self.timeout_func(TIMEOUT_INTERVAL, self.shutdown_func)
71+ logger.debug('Setting up timer with %r (%r, %r).',
72+ self.timeout_func, TIMEOUT_INTERVAL, self.shutdown)
73+ self.timeout_func(TIMEOUT_INTERVAL, self.shutdown)
74
75 ref_count = property(fget=_get_ref_count, fset=_set_ref_count)
76
77+ def shutdown(self):
78+ """If no ongoing requests, call self.shutdown_func."""
79+ logger.debug('shutdown!, ref_count is %r.', self._ref_count)
80+ if self._ref_count == 0:
81+ logger.info('Shutting down, calling %r.', self.shutdown_func)
82+ self.shutdown_func()
83+
84 @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='s')
85 def AuthorizationDenied(self, app_name):
86 """Signal thrown when the user denies the authorization."""
87
88=== modified file 'ubuntu_sso/tests/test_main.py'
89--- ubuntu_sso/tests/test_main.py 2011-01-12 18:56:56 +0000
90+++ ubuntu_sso/tests/test_main.py 2011-01-28 16:47:53 +0000
91@@ -749,30 +749,68 @@
92 self.assertIsInstance(self.client, ubuntu_sso.main.dbus.service.Object)
93
94
95+class FakeCredentials(object):
96+ """A very dummy Credentials object."""
97+
98+ def __init__(self, *a, **kw):
99+ self.find_credentials = lambda *a: defer.succeed(TOKEN)
100+ self.clear_credentials = lambda *a: defer.succeed(None)
101+ self.store_credentials = lambda *a: defer.succeed(None)
102+ self.login = self.register = lambda *a: None
103+
104+
105 class CredentialsManagementRefCountingTestCase(CredentialsManagementTestCase):
106 """Tests for the CredentialsManagement ref counting."""
107
108+ def setUp(self):
109+ super(CredentialsManagementRefCountingTestCase, self).setUp()
110+ self.patch(ubuntu_sso.main, 'Credentials', FakeCredentials)
111+
112 def test_ref_counting(self):
113 """Ref counting is in place."""
114 self.assertEqual(self.client.ref_count, 0)
115
116 def test_find_credentials(self):
117 """Keep proper track of on going requests."""
118+ d = Deferred()
119+
120+ def verify(*args):
121+ """Make the check."""
122+ self.assertEqual(self.client.ref_count, 1)
123+ d.callback(True)
124+
125+ self.patch(self.client, 'CredentialsFound', verify)
126 self.client.find_credentials(APP_NAME, self.args)
127
128- self.assertEqual(self.client.ref_count, 1)
129+ return d
130
131 def test_clear_credentials(self):
132 """Keep proper track of on going requests."""
133+ d = Deferred()
134+
135+ def verify(*args):
136+ """Make the check."""
137+ self.assertEqual(self.client.ref_count, 1)
138+ d.callback(True)
139+
140+ self.patch(self.client, 'CredentialsCleared', verify)
141 self.client.clear_credentials(APP_NAME, self.args)
142
143- self.assertEqual(self.client.ref_count, 1)
144+ return d
145
146 def test_store_credentials(self):
147 """Keep proper track of on going requests."""
148+ d = Deferred()
149+
150+ def verify(*args):
151+ """Make the check."""
152+ self.assertEqual(self.client.ref_count, 1)
153+ d.callback(True)
154+
155+ self.patch(self.client, 'CredentialsStored', verify)
156 self.client.store_credentials(APP_NAME, self.args)
157
158- self.assertEqual(self.client.ref_count, 1)
159+ return d
160
161 def test_register(self):
162 """Keep proper track of on going requests."""
163@@ -789,10 +827,10 @@
164 def test_several_requests(self):
165 """Requests can be nested."""
166 self.client.login(APP_NAME, self.args)
167- self.client.clear_credentials(APP_NAME, self.args)
168- self.client.find_credentials(APP_NAME, self.args)
169- self.client.register(APP_NAME, self.args)
170- self.client.store_credentials(APP_NAME, self.args)
171+ self.client.register(APP_NAME, self.args)
172+ self.client.login(APP_NAME, self.args)
173+ self.client.register(APP_NAME, self.args)
174+ self.client.register(APP_NAME, self.args)
175
176 self.assertEqual(self.client.ref_count, 5)
177
178@@ -895,19 +933,54 @@
179 def test_on_zero_ref_count_shutdown(self):
180 """When ref count reaches 0, queue shutdown op."""
181 self.client.timeout_func = self._set_called
182- self.client.find_credentials(APP_NAME, self.args)
183+ self.client.login(APP_NAME, self.args)
184 self.client.CredentialsFound(APP_NAME, TOKEN)
185
186 self.assertEqual(self._called,
187- ((TIMEOUT_INTERVAL, self.client.shutdown_func), {}))
188+ ((TIMEOUT_INTERVAL, self.client.shutdown), {}))
189
190 def test_on_non_zero_ref_count_do_not_shutdown(self):
191 """If ref count is not 0, do not queue shutdown op."""
192 self.client.timeout_func = self._set_called
193- self.client.find_credentials(APP_NAME, self.args)
194+ self.client.login(APP_NAME, self.args)
195
196 self.assertEqual(self._called, False)
197
198+ def test_on_non_zero_ref_count_after_zero_do_not_shutdown(self):
199+ """If the shutdown was queued, do not quit if counter is not zero."""
200+
201+ def fake_timeout_func(interval, func):
202+ """Start a new request when the timer is started."""
203+ self.client.register(APP_NAME, self.args)
204+ assert self.client.ref_count > 0
205+ func()
206+
207+ self.client.timeout_func = fake_timeout_func
208+ self.client.shutdown_func = self._set_called
209+
210+ self.client.login(APP_NAME, self.args)
211+ self.client.CredentialsFound(APP_NAME, TOKEN)
212+ # counter reached 0, timeout_func was called
213+
214+ self.assertEqual(self._called, False, 'shutdown_func was not called')
215+
216+ def test_zero_ref_count_after_zero_do_shutdown(self):
217+ """If the shutdown was queued, do quit if counter is zero."""
218+
219+ def fake_timeout_func(interval, func):
220+ """Start a new request when the timer is started."""
221+ assert self.client.ref_count == 0
222+ func()
223+
224+ self.client.timeout_func = fake_timeout_func
225+ self.client.shutdown_func = self._set_called
226+
227+ self.client.login(APP_NAME, self.args)
228+ self.client.CredentialsFound(APP_NAME, TOKEN)
229+ # counter reached 0, timeout_func was called
230+
231+ self.assertEqual(self._called, ((), {}), 'shutdown_func was called')
232+
233
234 class CredentialsManagementFindTestCase(CredentialsManagementTestCase):
235 """Tests for the CredentialsManagement find method."""

Subscribers

People subscribed via source and target branches