8041740: Test sun/security/tools/keytool/ListKeychainStore.sh fails on Mac
authorvinnie
Sun, 05 Oct 2014 14:24:44 +0100
changeset 26957 663b14c9b66f
parent 26904 9618201c5df2
child 26958 cb5cbde6e7a4
8041740: Test sun/security/tools/keytool/ListKeychainStore.sh fails on Mac Reviewed-by: mullan
jdk/test/sun/security/tools/keytool/ListKeychainStore.sh
--- a/jdk/test/sun/security/tools/keytool/ListKeychainStore.sh	Wed Jul 05 20:03:24 2017 +0200
+++ b/jdk/test/sun/security/tools/keytool/ListKeychainStore.sh	Sun Oct 05 14:24:44 2014 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
 #
 
 # @test
-# @bug 7133495
+# @bug 7133495 8041740
 # @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry
 
 if [ "${TESTJAVA}" = "" ] ; then
@@ -49,8 +49,10 @@
 KEYTOOL="${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -storetype KeychainStore -keystore NONE -storepass $PWD"
 TEMPORARY_P12="$TESTCLASSES/7133495.p12"
 TEMPORARY_KC="$TESTCLASSES/7133495.keychain"
+TEMPORARY_LIST="$TESTCLASSES/7133495.tmp"
 CLEANUP_P12="rm -f $TEMPORARY_P12"
 CLEANUP_KC="security delete-keychain $TEMPORARY_KC"
+CLEANUP_LIST="rm -f $TEMPORARY_LIST"
 
 # Count the number of private key entries in the Keychain keystores
 
@@ -115,6 +117,15 @@
 fi
 echo "Imported keypairs from PKCS12 keystore into the keychain"
 
+# Adjust the keychain search order
+
+echo "\"$TEMPORARY_KC\"" > $TEMPORARY_LIST
+security list-keychains >> $TEMPORARY_LIST
+security list-keychains -s `xargs < ${TEMPORARY_LIST}`
+`$CLEANUP_LIST`
+echo "Temporary keychain search order:"
+security list-keychains
+
 # Recount the number of private key entries in the Keychain keystores
 
 COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`