Make webkit-patch try harder to find keychain credentials
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jan 2015 21:20:57 +0000 (21:20 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jan 2015 21:20:57 +0000 (21:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140170

Reviewed by Ryosuke Niwa.

When the user manually enters a password into webkit-patch, we hand that off to the
Keyring Python module. However, that module creates a generic password entry instead
of an internet password entry. We should look for both kinds.

* Scripts/webkitpy/common/net/credentials.py:
(Credentials._run_security_tool):
(Credentials._credentials_from_keychain):
* Scripts/webkitpy/common/net/credentials_unittest.py:
(test_security_output_parse_entry_not_found):
(_assert_security_call):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178049 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/net/credentials.py
Tools/Scripts/webkitpy/common/net/credentials_unittest.py

index 76607c41ca6044364a19e35ea6853c543e8e816d..097eb6662ff707e8fe678ff480ff4de156dcfb56 100644 (file)
@@ -1,3 +1,21 @@
+2015-01-07  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Make webkit-patch try harder to find keychain credentials
+        https://bugs.webkit.org/show_bug.cgi?id=140170
+
+        Reviewed by Ryosuke Niwa.
+
+        When the user manually enters a password into webkit-patch, we hand that off to the
+        Keyring Python module. However, that module creates a generic password entry instead
+        of an internet password entry. We should look for both kinds.
+
+        * Scripts/webkitpy/common/net/credentials.py:
+        (Credentials._run_security_tool):
+        (Credentials._credentials_from_keychain):
+        * Scripts/webkitpy/common/net/credentials_unittest.py:
+        (test_security_output_parse_entry_not_found):
+        (_assert_security_call):
+
 2015-01-06  Anders Carlsson  <andersca@apple.com>
 
         Try to fix the Mountain Lion build.
index 7038b7e3cdbf683c8a9887460782784d3dca80b2..626934c8188c81e7af8b091ca026c661c3c3f918 100644 (file)
@@ -89,10 +89,10 @@ class Credentials(object):
                                                    security_output)
         return [username, password]
 
-    def _run_security_tool(self, username=None):
+    def _run_security_tool(self, command, username=None):
         security_command = [
             "/usr/bin/security",
-            "find-internet-password",
+            command,
             "-g",
             "-s",
             self.host,
@@ -115,11 +115,15 @@ class Credentials(object):
         if not self._is_mac_os_x():
             return [username, None]
 
-        security_output = self._run_security_tool(username)
+        security_output = self._run_security_tool("find-internet-password", username)
+        if security_output:
+            parsed_output = self._parse_security_tool_output(security_output)
+            if any(parsed_output):
+                return parsed_output
+        security_output = self._run_security_tool("find-generic-password", username)
         if security_output:
             return self._parse_security_tool_output(security_output)
-        else:
-            return [None, None]
+        return [None, None]
 
     def _read_environ(self, key):
         environ_key = self._environ_prefix + key
index 818b3d712776f58799344e574ce3879d4caf85c5..1b4fd7eae9fa04514517f9b32157db6ecd164baf 100644 (file)
@@ -110,7 +110,7 @@ password: "SECRETSAUCE"
         # by the test case CredentialsTest._assert_security_call (below).
         outputCapture = OutputCapture()
         outputCapture.capture_output()
-        self.assertIsNone(credentials._run_security_tool())
+        self.assertIsNone(credentials._run_security_tool("find-internet-password"))
         outputCapture.restore_output()
 
     def _assert_security_call(self, username=None):
@@ -118,7 +118,7 @@ password: "SECRETSAUCE"
         credentials = MockedCredentials("example.com", executive=executive_mock)
 
         expected_logs = "Reading Keychain for example.com account and password.  Click \"Allow\" to continue...\n"
-        OutputCapture().assert_outputs(self, credentials._run_security_tool, [username], expected_logs=expected_logs)
+        OutputCapture().assert_outputs(self, credentials._run_security_tool, ["find-internet-password", username], expected_logs=expected_logs)
 
         security_args = ["/usr/bin/security", "find-internet-password", "-g", "-s", "example.com"]
         if username: