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
1=== modified file 'ubuntu_sso/main.py'
2--- ubuntu_sso/main.py 2010-08-23 19:23:40 +0000
3+++ ubuntu_sso/main.py 2010-08-24 13:07:56 +0000
4@@ -559,6 +559,21 @@
5 logger.exception(msg)
6 self.CredentialsError(app_name, msg, traceback.format_exc())
7
8+ @dbus.service.method(dbus_interface=DBUS_IFACE_CRED_NAME,
9+ in_signature='s', out_signature='')
10+ def clear_token(self, app_name):
11+ """Clear the token for an application from the keyring.
12+
13+ 'app_name' is the name of the application.
14+ """
15+ try:
16+ creds = Keyring(app_name)
17+ creds.delete_ubuntusso_attr()
18+ except Exception:
19+ logger.exception(
20+ "problem removing credentials from keyring for %s",
21+ app_name)
22+
23
24 class LoginProcessor:
25 """Actually do the work of processing passed parameters."""
26
27=== modified file 'ubuntu_sso/tests/test_main.py'
28--- ubuntu_sso/tests/test_main.py 2010-08-23 19:23:40 +0000
29+++ ubuntu_sso/tests/test_main.py 2010-08-24 13:07:56 +0000
30@@ -26,7 +26,7 @@
31 import gobject
32
33 from lazr.restfulclient.errors import HTTPError
34-from mocker import Mocker, MockerTestCase, ARGS, KWARGS
35+from mocker import Mocker, MockerTestCase, ARGS, KWARGS, ANY
36 from twisted.internet.defer import Deferred
37 from twisted.trial.unittest import TestCase
38
39@@ -959,6 +959,30 @@
40 client.login_to_get_credentials(*LOGIN_ONLY_ARGS)
41 return d
42
43+ def test_clear_token(self):
44+ """Check that clear_token tries removing the correct token."""
45+ mockKeyringClass = self.mocker.replace("ubuntu_sso.keyring.Keyring")
46+ mockKeyringClass(APP_NAME)
47+ mockKeyring = self.mocker.mock()
48+ self.mocker.result(mockKeyring)
49+ mockKeyring.delete_ubuntusso_attr()
50+ self.mocker.replay()
51+
52+ client = SSOCredentials(self.mocker.mock())
53+ client.clear_token(APP_NAME)
54+
55+ def test_clear_token_failed(self):
56+ """Check that clear_token fails correctly."""
57+ mockKeyringClass = self.mocker.replace("ubuntu_sso.keyring.Keyring")
58+ mockKeyringClass(APP_NAME)
59+ self.mocker.throw(self.mocker.mock())
60+ fake_logger = self.mocker.replace("ubuntu_sso.main.logger")
61+ fake_logger.exception(ANY, APP_NAME)
62+ self.mocker.replay()
63+
64+ client = SSOCredentials(self.mocker.mock())
65+ client.clear_token(APP_NAME)
66+
67 def test_login_error_cb(self):
68 """The login error callback should throw the signal."""
69 d = Deferred()

Subscribers

People subscribed via source and target branches