8180266: Convert sun/security/provider/KeyStore/DKSTest.sh to Java Jtreg Test
Reviewed-by: rhalade
This commit is contained in:
parent
3ad6aef149
commit
7f313b0cef
test/jdk
@ -589,8 +589,6 @@ sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-a
|
||||
javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all
|
||||
javax/net/ssl/SSLEngine/CheckStatus.java 8298872 generic-all
|
||||
|
||||
sun/security/provider/KeyStore/DKSTest.sh 8180266 windows-all
|
||||
|
||||
sun/security/smartcardio/TestChannel.java 8039280 generic-all
|
||||
sun/security/smartcardio/TestConnect.java 8039280 generic-all
|
||||
sun/security/smartcardio/TestConnectAgain.java 8039280 generic-all
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, 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,25 +22,33 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* see ./DKSTest.sh
|
||||
* @test
|
||||
* @bug 8007755
|
||||
* @library /test/lib
|
||||
* @summary Support the logical grouping of keystores
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.*;
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.*;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.*;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
// Load and store entries in domain keystores
|
||||
|
||||
public class DKSTest {
|
||||
|
||||
private static final String TEST_SRC = System.getProperty("test.src");
|
||||
private static final String USER_DIR = System.getProperty("user.dir");
|
||||
private static final String CERT = TEST_SRC + "/../../pkcs12/trusted.pem";
|
||||
private static final String CONFIG = "file://" + TEST_SRC + "/domains.cfg";
|
||||
private static final String USER_DIR = System.getProperty("user.dir", ".");
|
||||
private static final String CERT = Paths.get(
|
||||
TEST_SRC, "..", "..", "pkcs12", "trusted.pem").toAbsolutePath().toString();
|
||||
private static final String CONFIG = Paths.get(
|
||||
TEST_SRC, "domains.cfg").toUri().toString();
|
||||
private static final Map<String, KeyStore.ProtectionParameter> PASSWORDS =
|
||||
new HashMap<String, KeyStore.ProtectionParameter>() {{
|
||||
put("keystore",
|
||||
@ -70,6 +78,18 @@ public class DKSTest {
|
||||
}};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
// Environment variable and system properties referred in domains.cfg used by this Test.
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(List.of(
|
||||
"-Dtest.src=" + TEST_SRC , "-Duser.dir=" + USER_DIR, "DKSTest", "run"));
|
||||
pb.environment().putAll(System.getenv());
|
||||
pb.environment().put("KEYSTORE_PWD", "test12");
|
||||
pb.environment().put("TRUSTSTORE_PWD", "changeit");
|
||||
OutputAnalyzer output = ProcessTools.executeProcess(pb);
|
||||
output.shouldHaveExitValue(0);
|
||||
output.outputTo(System.out);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* domain keystore: keystores with wrong passwords
|
||||
*/
|
||||
|
@ -1,76 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2013, 2020, 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
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 8007755
|
||||
# @summary Support the logical grouping of keystores
|
||||
|
||||
# set a few environment variables so that the shell-script can run stand-alone
|
||||
# in the source directory
|
||||
if [ "${TESTSRC}" = "" ] ; then
|
||||
TESTSRC="."
|
||||
fi
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ] ; then
|
||||
TESTCLASSES="."
|
||||
fi
|
||||
|
||||
if [ "${TESTJAVA}" = "" ] ; then
|
||||
echo "TESTJAVA not set. Test cannot execute."
|
||||
echo "FAILED!!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${COMPILEJAVA}" = "" ]; then
|
||||
COMPILEJAVA="${TESTJAVA}"
|
||||
fi
|
||||
|
||||
# set platform-dependent variables
|
||||
OS=`uname -s`
|
||||
case "$OS" in
|
||||
Linux | Darwin | AIX)
|
||||
PS=":"
|
||||
FS="/"
|
||||
;;
|
||||
CYGWIN* )
|
||||
PS=";"
|
||||
FS="/"
|
||||
;;
|
||||
Windows* )
|
||||
PS=";"
|
||||
FS="\\"
|
||||
;;
|
||||
* )
|
||||
echo "Unrecognized system!"
|
||||
exit 1;
|
||||
;;
|
||||
esac
|
||||
|
||||
${COMPILEJAVA}${FS}bin${FS}javac -d . ${TESTSRC}${FS}DKSTest.java
|
||||
|
||||
KEYSTORE_PWD=test12 TRUSTSTORE_PWD=changeit \
|
||||
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Dtest.src=${TESTSRC} DKSTest
|
||||
|
||||
exit $status
|
Loading…
x
Reference in New Issue
Block a user