Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: tools/telemetry/telemetry/util/mac/keychain_helper.py

Issue 809473004: Make Telemetry tests check the configuration of the OSX Keychain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove gyp targets. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/util/mac/determine_if_keychain_is_locked.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/util/mac/keychain_helper.py
diff --git a/tools/telemetry/telemetry/util/mac/keychain_helper.py b/tools/telemetry/telemetry/util/mac/keychain_helper.py
new file mode 100644
index 0000000000000000000000000000000000000000..00f6033564021b9e2d854af0065e790560deeb1e
--- /dev/null
+++ b/tools/telemetry/telemetry/util/mac/keychain_helper.py
@@ -0,0 +1,64 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import subprocess
+
+from telemetry.core import platform
+from telemetry.util import support_binaries
+
+def _PathForExecutable(executable_name):
+ """Fetches the executable from cloud storage, and returns its path."""
+ arch_name = platform.GetHostPlatform().GetArchName()
+ return support_binaries.FindPath(executable_name, arch_name, 'mac')
+
+def IsKeychainLocked():
+ """
+ Returns True if the keychain is locked, or if there is an error determining
+ the keychain state.
+ """
+ path = _PathForExecutable('determine_if_keychain_is_locked')
+
+ child = subprocess.Popen(path, stdout=subprocess.PIPE)
+ child.communicate()
+ return child.returncode != 0
+
+def DoesKeychainHaveTimeout():
+ """
+ Returns True if the keychain will lock itself have a period of time.
+
+ This method will trigger a blocking, modal dialog if the keychain is
+ locked.
+ """
+ command = ("/usr/bin/security", "show-keychain-info")
+ child = subprocess.Popen(command, stderr=subprocess.PIPE)
+ stderr = child.communicate()[1]
+ return "no-timeout" not in stderr
+
+def _IsKeychainConfiguredForBots(service_name, account_name):
+ """
+ Returns True if the keychain entry associated with |service_name| and
+ |account_name| is correctly configured for running telemetry tests on bots.
+
+ This method will trigger a blocking, modal dialog if the keychain is
+ locked.
+ """
+ # The executable requires OSX 10.7+ APIs.
+ if (platform.GetHostPlatform().GetOSVersionName() <
+ platform.platform_backend.LION):
+ return False
+
+ path = _PathForExecutable('determine_if_keychain_entry_is_decryptable')
+
+ command = (path, service_name, account_name)
+ child = subprocess.Popen(command)
+ child.communicate()
+ return child.returncode == 0
+
+def IsKeychainConfiguredForBotsWithChrome():
+ return _IsKeychainConfiguredForBots("Chrome Safe Storage",
+ "Chrome")
+
+def IsKeychainConfiguredForBotsWithChromium():
+ return _IsKeychainConfiguredForBots("Chromium Safe Storage",
+ "Chromium")
« no previous file with comments | « tools/telemetry/telemetry/util/mac/determine_if_keychain_is_locked.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698