annotate test/sun/security/mscapi/KeytoolChangeAlias.sh @ 11258:44a6aa58f7b2

8139436: sun.security.mscapi.KeyStore might load incomplete data Reviewed-by: vinnie, weijun
author clanger
date Fri, 18 Dec 2015 08:25:27 +0800
parents d64f9348c7ca
children
rev   line source
duke@0 1 #!/bin/sh
duke@0 2
duke@0 3 #
clanger@11258 4 # Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
duke@0 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 6 #
duke@0 7 # This code is free software; you can redistribute it and/or modify it
duke@0 8 # under the terms of the GNU General Public License version 2 only, as
duke@0 9 # published by the Free Software Foundation.
duke@0 10 #
duke@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 14 # version 2 for more details (a copy is included in the LICENSE file that
duke@0 15 # accompanied this code).
duke@0 16 #
duke@0 17 # You should have received a copy of the GNU General Public License version
duke@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
duke@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 20 #
ohair@2362 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@2362 22 # or visit www.oracle.com if you need additional information or have any
ohair@2362 23 # questions.
duke@0 24 #
duke@0 25
duke@0 26
duke@0 27 # @test
vinnie@4122 28 # @bug 6415696 6931562
clanger@11258 29 # @requires os.family == "windows"
duke@0 30 # @run shell KeytoolChangeAlias.sh
duke@0 31 # @summary Test "keytool -changealias" using the Microsoft CryptoAPI provider.
duke@0 32
duke@0 33 # set a few environment variables so that the shell-script can run stand-alone
duke@0 34 # in the source directory
duke@0 35 if [ "${TESTSRC}" = "" ] ; then
duke@0 36 TESTSRC="."
duke@0 37 fi
duke@0 38
duke@0 39 if [ "${TESTCLASSES}" = "" ] ; then
duke@0 40 TESTCLASSES="."
duke@0 41 fi
duke@0 42
duke@0 43 if [ "${TESTJAVA}" = "" ] ; then
duke@0 44 echo "TESTJAVA not set. Test cannot execute."
duke@0 45 echo "FAILED!!!"
duke@0 46 exit 1
duke@0 47 fi
duke@0 48
duke@0 49 OS=`uname -s`
duke@0 50 case "$OS" in
duke@0 51 Windows* | CYGWIN* )
duke@0 52
duke@0 53 # 'uname -m' does not give us enough information -
duke@0 54 # should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk),
duke@0 55 # but JTREG does not pass this env variable when executing a shell script.
duke@0 56 #
duke@0 57 # execute test program - rely on it to exit if platform unsupported
duke@0 58
duke@0 59 echo "Creating the alias '246810' in the Windows-My store..."
duke@0 60 ${TESTJAVA}/bin/keytool \
duke@0 61 -import \
duke@0 62 -storetype Windows-My \
duke@0 63 -file ${TESTSRC}/246810.cer \
duke@0 64 -alias 246810 \
duke@0 65 -noprompt
duke@0 66
duke@0 67 if [ $? -ne 0 ] ; then
duke@0 68 exit $?
duke@0 69 fi
duke@0 70
duke@0 71 echo "Removing the alias '13579', if it is already present..."
duke@0 72 ${TESTJAVA}/bin/keytool \
duke@0 73 -list \
duke@0 74 -storetype Windows-My \
duke@0 75 -alias 13579 > /dev/null 2>&1
duke@0 76
duke@0 77 if [ $? ] ; then
duke@0 78 ${TESTJAVA}/bin/keytool \
duke@0 79 -delete \
duke@0 80 -storetype Windows-My \
duke@0 81 -alias 13579 \
duke@0 82 -noprompt
duke@0 83 fi
duke@0 84
duke@0 85 echo "Counting the entries in the store..."
duke@0 86 count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
duke@0 87 before=$count
duke@0 88
duke@0 89 echo "Changing the alias name from '246810' to '13579'..."
duke@0 90
duke@0 91 ${TESTJAVA}/bin/keytool \
duke@0 92 -changealias \
duke@0 93 -storetype Windows-My \
duke@0 94 -alias 246810 \
duke@0 95 -destalias 13579
duke@0 96
duke@0 97 if [ $? -ne 0 ] ; then
duke@0 98 exit $?
duke@0 99 fi
duke@0 100
duke@0 101 echo "Re-counting the entries in the store..."
duke@0 102 count=`${TESTJAVA}/bin/keytool -list -storetype Windows-My | wc -l`
duke@0 103 after=$count
duke@0 104
duke@0 105 if [ ! $before = $after ]; then
duke@0 106 echo "error: unexpected number of entries in the Windows-MY store"
duke@0 107 exit 101
duke@0 108 fi
duke@0 109
duke@0 110 echo "Confirming that the new alias is present..."
duke@0 111 ${TESTJAVA}/bin/keytool \
duke@0 112 -list \
duke@0 113 -storetype Windows-My \
duke@0 114 -alias 13579 > /dev/null 2>&1
duke@0 115
duke@0 116 if [ $? -ne 0 ] ; then
duke@0 117 echo "error: cannot find the new alias name in the Windows-MY store"
duke@0 118 exit 102
duke@0 119 fi
duke@0 120
duke@0 121 echo "Removing the new alias '13579'..."
duke@0 122 ${TESTJAVA}/bin/keytool \
duke@0 123 -delete \
duke@0 124 -storetype Windows-My \
duke@0 125 -alias 13579 > /dev/null 2>&1
duke@0 126
duke@0 127 echo done.
duke@0 128 exit 0
duke@0 129 ;;
duke@0 130
duke@0 131 * )
duke@0 132 echo "This test is not intended for '$OS' - passing test"
duke@0 133 exit 0
duke@0 134 ;;
duke@0 135 esac
duke@0 136
duke@0 137
duke@0 138