RESOLVED FIXED 92532
webkit-patch: system keyring is not used to read my password
https://bugs.webkit.org/show_bug.cgi?id=92532
Summary webkit-patch: system keyring is not used to read my password
arno.
Reported 2012-07-27 12:14:16 PDT
Hi, I'm using ubuntu. I haven't set username and password in git options, neither in environment. when I upload a patch to bugzilla (with webkit-patch upload), I'm asked if I want to store my username and password in the system keyring. I say yes, and the credentials are stored. But those credentials are not used next time I use webkit-patch upload.
Attachments
patch proposal (1.83 KB, patch)
2012-07-27 12:23 PDT, arno.
no flags
updated patch with test (5.21 KB, patch)
2012-07-30 12:21 PDT, arno.
no flags
same patch; typo fixed (5.33 KB, patch)
2012-07-30 15:31 PDT, arno.
no flags
arno.
Comment 1 2012-07-27 12:20:58 PDT
That's because in Credentials.read_credentials, we try to read password from keyring before prompting for username. Instead, if username was not read from environment, git, or keychain, we could prompt for username, and try to read password from keyring after.
arno.
Comment 2 2012-07-27 12:23:04 PDT
Created attachment 155020 [details] patch proposal
Dirk Pranke
Comment 3 2012-07-27 12:52:04 PDT
Comment on attachment 155020 [details] patch proposal Seems reasonable to me. Is it possible to write a test for this?
arno.
Comment 4 2012-07-30 09:51:41 PDT
(In reply to comment #3) > (From update of attachment 155020 [details]) > Seems reasonable to me. Is it possible to write a test for this? I don't really known how to write a test for that: if we want to create unittest, at some point, the User.prompt() method will block them. Is there a way to override User.prompt() with a mock object ?
Adam Barth
Comment 5 2012-07-30 09:59:56 PDT
Yes. If you use a MockHost object, the User object will be mocked out for you by default.
Adam Barth
Comment 6 2012-07-30 10:01:10 PDT
You can grep for "MockUser" to see how it gets used. Many existing tests use it.
arno.
Comment 7 2012-07-30 12:21:17 PDT
Created attachment 155337 [details] updated patch with test
Dirk Pranke
Comment 8 2012-07-30 12:27:42 PDT
Comment on attachment 155337 [details] updated patch with test View in context: https://bugs.webkit.org/attachment.cgi?id=155337&action=review > Tools/Scripts/webkitpy/common/net/credentials.py:136 > + def read_credentials(self, User=User): the host has a user field, so you should be able to just say self.host.user.prompt(), and then down in your test you can create a credentials object, pass it a mock host, and override the prompt method. That should cut down on the scaffolding a fair amount.
arno.
Comment 9 2012-07-30 12:44:22 PDT
(In reply to comment #8) > (From update of attachment 155337 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=155337&action=review > > > Tools/Scripts/webkitpy/common/net/credentials.py:136 > > + def read_credentials(self, User=User): > > the host has a user field, so you should be able to just say self.host.user.prompt(), and then down in your test you can create a credentials object, pass it a mock host, and override the prompt method. That should cut down on the scaffolding a fair amount. In Credentials, host is just a string
Dirk Pranke
Comment 10 2012-07-30 12:58:57 PDT
Comment on attachment 155337 [details] updated patch with test View in context: https://bugs.webkit.org/attachment.cgi?id=155337&action=review >>> Tools/Scripts/webkitpy/common/net/credentials.py:136 >>> + def read_credentials(self, User=User): >> >> the host has a user field, so you should be able to just say self.host.user.prompt(), and then down in your test you can create a credentials object, pass it a mock host, and override the prompt method. That should cut down on the scaffolding a fair amount. > > In Credentials, host is just a string ugh, you're right. Okay, your approach is fine for now until we can clean that up. this object shouldn't be creating executives and users directly. one nit: parameters should be lowercased, so user=User.
arno.
Comment 11 2012-07-30 15:31:16 PDT
Created attachment 155383 [details] same patch; typo fixed
Dirk Pranke
Comment 12 2012-07-30 15:54:51 PDT
Comment on attachment 155383 [details] same patch; typo fixed thanks!
WebKit Review Bot
Comment 13 2012-07-30 18:46:00 PDT
Comment on attachment 155383 [details] same patch; typo fixed Clearing flags on attachment: 155383 Committed r124140: <http://trac.webkit.org/changeset/124140>
WebKit Review Bot
Comment 14 2012-07-30 18:46:04 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.