Merge lp:~alecu/ubuntuone-client/dont-log-tokens into lp:ubuntuone-client

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Natalia Bidart
Approved revision: 1135
Merged at revision: 1135
Proposed branch: lp:~alecu/ubuntuone-client/dont-log-tokens
Merge into: lp:ubuntuone-client
Diff against target: 59 lines (+21/-2)
2 files modified
tests/platform/windows/test_credentials.py (+19/-0)
ubuntuone/platform/credentials/windows.py (+2/-2)
To merge this branch: bzr merge lp:~alecu/ubuntuone-client/dont-log-tokens
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+75244@code.launchpad.net

Commit message

Don't log the credentials (LP: #848988)

Description of the change

Don't log the credentials (LP: #848988)

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/windows/test_credentials.py'
2--- tests/platform/windows/test_credentials.py 2011-08-24 14:25:35 +0000
3+++ tests/platform/windows/test_credentials.py 2011-09-13 19:39:19 +0000
4@@ -17,14 +17,18 @@
5 # with this program. If not, see <http://www.gnu.org/licenses/>.
6 """Tests for the Ubuntu One credentials management IPC service."""
7
8+import logging
9+
10 from twisted.internet import defer
11 from twisted.trial.unittest import TestCase
12
13 from contrib.testing.testcase import FAKED_CREDENTIALS
14+from ubuntuone.devtools.handlers import MementoHandler
15 from ubuntuone.platform.credentials import APP_NAME
16 from ubuntuone.platform.credentials.windows import (
17 CredentialsManagement,
18 RemovableSignal,
19+ logger,
20 )
21
22 TEST_APP_NAME = "test application"
23@@ -110,6 +114,21 @@
24 rs(APP_NAME, expected)
25 self.assertEqual(sample_store, [expected])
26
27+ def test_callable_does_not_log_args(self):
28+ """__call__ does not log its arguments."""
29+ self.handler = MementoHandler()
30+ self.handler.setLevel(logging.DEBUG)
31+ logger.addHandler(self.handler)
32+ self.addCleanup(logger.removeHandler, self.handler)
33+
34+ secret_token = "secret token!"
35+ test_cb = lambda _: None
36+ rs = RemovableSignal(self.proxy, "on_credentials_found_cb", test_cb)
37+
38+ rs(APP_NAME, {"secret": secret_token})
39+ for record in self.handler.records:
40+ self.assertNotIn(secret_token, record.message)
41+
42 def test_dunder_filters_other_apps(self):
43 """__call__ filters by app_name."""
44 sample_store = []
45
46=== modified file 'ubuntuone/platform/credentials/windows.py'
47--- ubuntuone/platform/credentials/windows.py 2011-08-24 15:13:25 +0000
48+++ ubuntuone/platform/credentials/windows.py 2011-09-13 19:39:19 +0000
49@@ -62,8 +62,8 @@
50 if self.callback is not None:
51 # drop the app name, callers do not care about it
52 args = args[1:]
53- logger.debug('Calling %r with args %r and kwargs %r.',
54- self.callback, args, kwargs)
55+ logger.debug('Calling %r with %d args and %d kwargs.',
56+ self.callback, len(args), len(kwargs))
57 return self.callback(*args, **kwargs)
58
59 def remove(self):

Subscribers

People subscribed via source and target branches