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
=== modified file 'PKG-INFO'
--- PKG-INFO 2011-01-25 13:56:41 +0000
+++ PKG-INFO 2011-01-28 16:47:53 +0000
@@ -1,6 +1,6 @@
1Metadata-Version: 1.11Metadata-Version: 1.1
2Name: ubuntu-sso-client2Name: ubuntu-sso-client
3Version: 1.1.93Version: 1.1.10
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 'debian/changelog'
--- debian/changelog 2011-01-25 15:02:18 +0000
+++ debian/changelog 2011-01-28 16:47:53 +0000
@@ -1,3 +1,15 @@
1ubuntu-sso-client (1.1.10-0ubuntu1) UNRELEASED; urgency=low
2
3 * New upstream release:
4
5 [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
6 - The service is not shutdown if ref count is not zero, even if the
7    shutdown_func was queued (LP: #709200).
8 - Test failures (caused by a buggy test) fixed (LP: #704941).
9
10
11 -- Natalia Bidart (nessita) <nataliabidart@gmail.com> Fri, 28 Jan 2011 13:38:28 -0300
12
1ubuntu-sso-client (1.1.9-0ubuntu1) natty; urgency=low13ubuntu-sso-client (1.1.9-0ubuntu1) natty; urgency=low
214
3 * New upstream release:15 * New upstream release:
416
=== modified file 'setup.py'
--- setup.py 2011-01-25 13:56:41 +0000
+++ setup.py 2011-01-28 16:47:53 +0000
@@ -86,7 +86,7 @@
8686
87DistUtilsExtra.auto.setup(87DistUtilsExtra.auto.setup(
88 name='ubuntu-sso-client',88 name='ubuntu-sso-client',
89 version='1.1.9',89 version='1.1.10',
90 license='GPL v3',90 license='GPL v3',
91 author='Natalia Bidart',91 author='Natalia Bidart',
92 author_email='natalia.bidart@canonical.com',92 author_email='natalia.bidart@canonical.com',
9393
=== modified file 'ubuntu_sso/main.py'
--- ubuntu_sso/main.py 2011-01-12 18:56:56 +0000
+++ ubuntu_sso/main.py 2011-01-28 16:47:53 +0000
@@ -50,7 +50,7 @@
5050
51logger = setup_logging("ubuntu_sso.main")51logger = setup_logging("ubuntu_sso.main")
52U1_PING_URL = "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/"52U1_PING_URL = "https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/"
53TIMEOUT_INTERVAL = 50053TIMEOUT_INTERVAL = 10000 # 10 seconds
5454
5555
56class SSOLoginProcessor(Account):56class SSOLoginProcessor(Account):
@@ -449,7 +449,6 @@
449449
450 def _get_ref_count(self):450 def _get_ref_count(self):
451 """Get value of ref_count."""451 """Get value of ref_count."""
452 logger.debug('ref_count is %r.', self._ref_count)
453 return self._ref_count452 return self._ref_count
454453
455 def _set_ref_count(self, new_value):454 def _set_ref_count(self, new_value):
@@ -464,10 +463,19 @@
464 self._ref_count = new_value463 self._ref_count = new_value
465464
466 if self._ref_count == 0:465 if self._ref_count == 0:
467 self.timeout_func(TIMEOUT_INTERVAL, self.shutdown_func)466 logger.debug('Setting up timer with %r (%r, %r).',
467 self.timeout_func, TIMEOUT_INTERVAL, self.shutdown)
468 self.timeout_func(TIMEOUT_INTERVAL, self.shutdown)
468469
469 ref_count = property(fget=_get_ref_count, fset=_set_ref_count)470 ref_count = property(fget=_get_ref_count, fset=_set_ref_count)
470471
472 def shutdown(self):
473 """If no ongoing requests, call self.shutdown_func."""
474 logger.debug('shutdown!, ref_count is %r.', self._ref_count)
475 if self._ref_count == 0:
476 logger.info('Shutting down, calling %r.', self.shutdown_func)
477 self.shutdown_func()
478
471 @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='s')479 @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='s')
472 def AuthorizationDenied(self, app_name):480 def AuthorizationDenied(self, app_name):
473 """Signal thrown when the user denies the authorization."""481 """Signal thrown when the user denies the authorization."""
474482
=== modified file 'ubuntu_sso/tests/test_main.py'
--- ubuntu_sso/tests/test_main.py 2011-01-12 18:56:56 +0000
+++ ubuntu_sso/tests/test_main.py 2011-01-28 16:47:53 +0000
@@ -749,30 +749,68 @@
749 self.assertIsInstance(self.client, ubuntu_sso.main.dbus.service.Object)749 self.assertIsInstance(self.client, ubuntu_sso.main.dbus.service.Object)
750750
751751
752class FakeCredentials(object):
753 """A very dummy Credentials object."""
754
755 def __init__(self, *a, **kw):
756 self.find_credentials = lambda *a: defer.succeed(TOKEN)
757 self.clear_credentials = lambda *a: defer.succeed(None)
758 self.store_credentials = lambda *a: defer.succeed(None)
759 self.login = self.register = lambda *a: None
760
761
752class CredentialsManagementRefCountingTestCase(CredentialsManagementTestCase):762class CredentialsManagementRefCountingTestCase(CredentialsManagementTestCase):
753 """Tests for the CredentialsManagement ref counting."""763 """Tests for the CredentialsManagement ref counting."""
754764
765 def setUp(self):
766 super(CredentialsManagementRefCountingTestCase, self).setUp()
767 self.patch(ubuntu_sso.main, 'Credentials', FakeCredentials)
768
755 def test_ref_counting(self):769 def test_ref_counting(self):
756 """Ref counting is in place."""770 """Ref counting is in place."""
757 self.assertEqual(self.client.ref_count, 0)771 self.assertEqual(self.client.ref_count, 0)
758772
759 def test_find_credentials(self):773 def test_find_credentials(self):
760 """Keep proper track of on going requests."""774 """Keep proper track of on going requests."""
775 d = Deferred()
776
777 def verify(*args):
778 """Make the check."""
779 self.assertEqual(self.client.ref_count, 1)
780 d.callback(True)
781
782 self.patch(self.client, 'CredentialsFound', verify)
761 self.client.find_credentials(APP_NAME, self.args)783 self.client.find_credentials(APP_NAME, self.args)
762784
763 self.assertEqual(self.client.ref_count, 1)785 return d
764786
765 def test_clear_credentials(self):787 def test_clear_credentials(self):
766 """Keep proper track of on going requests."""788 """Keep proper track of on going requests."""
789 d = Deferred()
790
791 def verify(*args):
792 """Make the check."""
793 self.assertEqual(self.client.ref_count, 1)
794 d.callback(True)
795
796 self.patch(self.client, 'CredentialsCleared', verify)
767 self.client.clear_credentials(APP_NAME, self.args)797 self.client.clear_credentials(APP_NAME, self.args)
768798
769 self.assertEqual(self.client.ref_count, 1)799 return d
770800
771 def test_store_credentials(self):801 def test_store_credentials(self):
772 """Keep proper track of on going requests."""802 """Keep proper track of on going requests."""
803 d = Deferred()
804
805 def verify(*args):
806 """Make the check."""
807 self.assertEqual(self.client.ref_count, 1)
808 d.callback(True)
809
810 self.patch(self.client, 'CredentialsStored', verify)
773 self.client.store_credentials(APP_NAME, self.args)811 self.client.store_credentials(APP_NAME, self.args)
774812
775 self.assertEqual(self.client.ref_count, 1)813 return d
776814
777 def test_register(self):815 def test_register(self):
778 """Keep proper track of on going requests."""816 """Keep proper track of on going requests."""
@@ -789,10 +827,10 @@
789 def test_several_requests(self):827 def test_several_requests(self):
790 """Requests can be nested."""828 """Requests can be nested."""
791 self.client.login(APP_NAME, self.args)829 self.client.login(APP_NAME, self.args)
792 self.client.clear_credentials(APP_NAME, self.args)830 self.client.register(APP_NAME, self.args)
793 self.client.find_credentials(APP_NAME, self.args)831 self.client.login(APP_NAME, self.args)
794 self.client.register(APP_NAME, self.args)832 self.client.register(APP_NAME, self.args)
795 self.client.store_credentials(APP_NAME, self.args)833 self.client.register(APP_NAME, self.args)
796834
797 self.assertEqual(self.client.ref_count, 5)835 self.assertEqual(self.client.ref_count, 5)
798836
@@ -895,19 +933,54 @@
895 def test_on_zero_ref_count_shutdown(self):933 def test_on_zero_ref_count_shutdown(self):
896 """When ref count reaches 0, queue shutdown op."""934 """When ref count reaches 0, queue shutdown op."""
897 self.client.timeout_func = self._set_called935 self.client.timeout_func = self._set_called
898 self.client.find_credentials(APP_NAME, self.args)936 self.client.login(APP_NAME, self.args)
899 self.client.CredentialsFound(APP_NAME, TOKEN)937 self.client.CredentialsFound(APP_NAME, TOKEN)
900938
901 self.assertEqual(self._called,939 self.assertEqual(self._called,
902 ((TIMEOUT_INTERVAL, self.client.shutdown_func), {}))940 ((TIMEOUT_INTERVAL, self.client.shutdown), {}))
903941
904 def test_on_non_zero_ref_count_do_not_shutdown(self):942 def test_on_non_zero_ref_count_do_not_shutdown(self):
905 """If ref count is not 0, do not queue shutdown op."""943 """If ref count is not 0, do not queue shutdown op."""
906 self.client.timeout_func = self._set_called944 self.client.timeout_func = self._set_called
907 self.client.find_credentials(APP_NAME, self.args)945 self.client.login(APP_NAME, self.args)
908946
909 self.assertEqual(self._called, False)947 self.assertEqual(self._called, False)
910948
949 def test_on_non_zero_ref_count_after_zero_do_not_shutdown(self):
950 """If the shutdown was queued, do not quit if counter is not zero."""
951
952 def fake_timeout_func(interval, func):
953 """Start a new request when the timer is started."""
954 self.client.register(APP_NAME, self.args)
955 assert self.client.ref_count > 0
956 func()
957
958 self.client.timeout_func = fake_timeout_func
959 self.client.shutdown_func = self._set_called
960
961 self.client.login(APP_NAME, self.args)
962 self.client.CredentialsFound(APP_NAME, TOKEN)
963 # counter reached 0, timeout_func was called
964
965 self.assertEqual(self._called, False, 'shutdown_func was not called')
966
967 def test_zero_ref_count_after_zero_do_shutdown(self):
968 """If the shutdown was queued, do quit if counter is zero."""
969
970 def fake_timeout_func(interval, func):
971 """Start a new request when the timer is started."""
972 assert self.client.ref_count == 0
973 func()
974
975 self.client.timeout_func = fake_timeout_func
976 self.client.shutdown_func = self._set_called
977
978 self.client.login(APP_NAME, self.args)
979 self.client.CredentialsFound(APP_NAME, TOKEN)
980 # counter reached 0, timeout_func was called
981
982 self.assertEqual(self._called, ((), {}), 'shutdown_func was called')
983
911984
912class CredentialsManagementFindTestCase(CredentialsManagementTestCase):985class CredentialsManagementFindTestCase(CredentialsManagementTestCase):
913 """Tests for the CredentialsManagement find method."""986 """Tests for the CredentialsManagement find method."""

Subscribers

People subscribed via source and target branches