Skip to content

Commit 4eeb1c9

Browse files
committed
8180266: Convert sun/security/provider/KeyStore/DKSTest.sh to Java Jtreg Test
Backport-of: 7f313b0cef7d0e9732beed6c61298815306531e0
1 parent f45578e commit 4eeb1c9

File tree

3 files changed

+25
-83
lines changed

3 files changed

+25
-83
lines changed

test/jdk/ProblemList.txt

-2
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,6 @@ sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-
641641

642642
javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64
643643

644-
sun/security/provider/KeyStore/DKSTest.sh 8180266 windows-all
645-
646644
sun/security/smartcardio/TestChannel.java 8039280 generic-all
647645
sun/security/smartcardio/TestConnect.java 8039280 generic-all
648646
sun/security/smartcardio/TestConnectAgain.java 8039280 generic-all

test/jdk/sun/security/provider/KeyStore/DKSTest.java

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,25 +22,33 @@
2222
*/
2323

2424
/*
25-
* see ./DKSTest.sh
25+
* @test
26+
* @bug 8007755
27+
* @library /test/lib
28+
* @summary Support the logical grouping of keystores
2629
*/
2730

2831
import java.io.*;
2932
import java.net.*;
33+
import java.nio.file.Paths;
3034
import java.security.*;
3135
import java.security.KeyStore;
3236
import java.security.cert.*;
3337
import java.security.cert.Certificate;
3438
import java.util.*;
39+
import jdk.test.lib.process.ProcessTools;
40+
import jdk.test.lib.process.OutputAnalyzer;
3541

3642
// Load and store entries in domain keystores
3743

3844
public class DKSTest {
3945

4046
private static final String TEST_SRC = System.getProperty("test.src");
41-
private static final String USER_DIR = System.getProperty("user.dir");
42-
private static final String CERT = TEST_SRC + "/../../pkcs12/trusted.pem";
43-
private static final String CONFIG = "file://" + TEST_SRC + "/domains.cfg";
47+
private static final String USER_DIR = System.getProperty("user.dir", ".");
48+
private static final String CERT = Paths.get(
49+
TEST_SRC, "..", "..", "pkcs12", "trusted.pem").toAbsolutePath().toString();
50+
private static final String CONFIG = Paths.get(
51+
TEST_SRC, "domains.cfg").toUri().toString();
4452
private static final Map<String, KeyStore.ProtectionParameter> PASSWORDS =
4553
new HashMap<String, KeyStore.ProtectionParameter>() {{
4654
put("keystore",
@@ -70,6 +78,18 @@ public class DKSTest {
7078
}};
7179

7280
public static void main(String[] args) throws Exception {
81+
if (args.length == 0) {
82+
// Environment variable and system properties referred in domains.cfg used by this Test.
83+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(List.of(
84+
"-Dtest.src=" + TEST_SRC , "-Duser.dir=" + USER_DIR, "DKSTest", "run"));
85+
pb.environment().putAll(System.getenv());
86+
pb.environment().put("KEYSTORE_PWD", "test12");
87+
pb.environment().put("TRUSTSTORE_PWD", "changeit");
88+
OutputAnalyzer output = ProcessTools.executeProcess(pb);
89+
output.shouldHaveExitValue(0);
90+
output.outputTo(System.out);
91+
return;
92+
}
7393
/*
7494
* domain keystore: keystores with wrong passwords
7595
*/

test/jdk/sun/security/provider/KeyStore/DKSTest.sh

-76
This file was deleted.

0 commit comments

Comments
 (0)