Merge lp:~rodrigo-moya/ubuntu-sso-client/clear-token-api into lp:ubuntu-sso-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: Natalia Bidart
Approved revision: 587
Merged at revision: 582
Proposed branch: lp:~rodrigo-moya/ubuntu-sso-client/clear-token-api
Merge into: lp:ubuntu-sso-client
Diff against target: 69 lines (+40/-1)
2 files modified
ubuntu_sso/main.py (+15/-0)
ubuntu_sso/tests/test_main.py (+25/-1)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntu-sso-client/clear-token-api
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+33431@code.launchpad.net

Commit message

Add clear_token DBus API (LP: #622833).

Description of the change

Add clear_token DBus API

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Tests please! :-)

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) :
review: Needs Fixing
582. By Rodrigo Moya

Added tests for new DBus API

583. By Rodrigo Moya

Merge from trunk

584. By Rodrigo Moya

Fixed docstring

585. By Rodrigo Moya

Make mr pep8 happy

586. By Rodrigo Moya

Fix logger.exception call

587. By Rodrigo Moya

Fix test

Revision history for this message
Natalia Bidart (nataliabidart) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks perfect.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntu_sso/main.py'
--- ubuntu_sso/main.py 2010-08-23 19:23:40 +0000
+++ ubuntu_sso/main.py 2010-08-24 13:07:56 +0000
@@ -559,6 +559,21 @@
559 logger.exception(msg)559 logger.exception(msg)
560 self.CredentialsError(app_name, msg, traceback.format_exc())560 self.CredentialsError(app_name, msg, traceback.format_exc())
561561
562 @dbus.service.method(dbus_interface=DBUS_IFACE_CRED_NAME,
563 in_signature='s', out_signature='')
564 def clear_token(self, app_name):
565 """Clear the token for an application from the keyring.
566
567 'app_name' is the name of the application.
568 """
569 try:
570 creds = Keyring(app_name)
571 creds.delete_ubuntusso_attr()
572 except Exception:
573 logger.exception(
574 "problem removing credentials from keyring for %s",
575 app_name)
576
562577
563class LoginProcessor:578class LoginProcessor:
564 """Actually do the work of processing passed parameters."""579 """Actually do the work of processing passed parameters."""
565580
=== modified file 'ubuntu_sso/tests/test_main.py'
--- ubuntu_sso/tests/test_main.py 2010-08-23 19:23:40 +0000
+++ ubuntu_sso/tests/test_main.py 2010-08-24 13:07:56 +0000
@@ -26,7 +26,7 @@
26import gobject26import gobject
2727
28from lazr.restfulclient.errors import HTTPError28from lazr.restfulclient.errors import HTTPError
29from mocker import Mocker, MockerTestCase, ARGS, KWARGS29from mocker import Mocker, MockerTestCase, ARGS, KWARGS, ANY
30from twisted.internet.defer import Deferred30from twisted.internet.defer import Deferred
31from twisted.trial.unittest import TestCase31from twisted.trial.unittest import TestCase
3232
@@ -959,6 +959,30 @@
959 client.login_to_get_credentials(*LOGIN_ONLY_ARGS)959 client.login_to_get_credentials(*LOGIN_ONLY_ARGS)
960 return d960 return d
961961
962 def test_clear_token(self):
963 """Check that clear_token tries removing the correct token."""
964 mockKeyringClass = self.mocker.replace("ubuntu_sso.keyring.Keyring")
965 mockKeyringClass(APP_NAME)
966 mockKeyring = self.mocker.mock()
967 self.mocker.result(mockKeyring)
968 mockKeyring.delete_ubuntusso_attr()
969 self.mocker.replay()
970
971 client = SSOCredentials(self.mocker.mock())
972 client.clear_token(APP_NAME)
973
974 def test_clear_token_failed(self):
975 """Check that clear_token fails correctly."""
976 mockKeyringClass = self.mocker.replace("ubuntu_sso.keyring.Keyring")
977 mockKeyringClass(APP_NAME)
978 self.mocker.throw(self.mocker.mock())
979 fake_logger = self.mocker.replace("ubuntu_sso.main.logger")
980 fake_logger.exception(ANY, APP_NAME)
981 self.mocker.replay()
982
983 client = SSOCredentials(self.mocker.mock())
984 client.clear_token(APP_NAME)
985
962 def test_login_error_cb(self):986 def test_login_error_cb(self):
963 """The login error callback should throw the signal."""987 """The login error callback should throw the signal."""
964 d = Deferred()988 d = Deferred()

Subscribers

People subscribed via source and target branches