Skip to content

Commit

Permalink
8180266: Convert sun/security/provider/KeyStore/DKSTest.sh to Java Jt…
Browse files Browse the repository at this point in the history
…reg Test

Backport-of: 7f313b0cef7d0e9732beed6c61298815306531e0
  • Loading branch information
Amos Shi authored and Paul Hohensee committed Dec 18, 2023
1 parent 9505906 commit 3212030
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 83 deletions.
2 changes: 0 additions & 2 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,6 @@ javax/net/ssl/DTLS/PacketLossRetransmission.java 8169086 macosx-x
javax/net/ssl/DTLS/RespondToRetransmit.java 8169086 macosx-all
javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64

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
Expand Down
30 changes: 25 additions & 5 deletions test/jdk/sun/security/provider/KeyStore/DKSTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, 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
Expand All @@ -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",
Expand Down Expand Up @@ -74,6 +82,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
*/
Expand Down
76 changes: 0 additions & 76 deletions test/jdk/sun/security/provider/KeyStore/DKSTest.sh

This file was deleted.

0 comments on commit 3212030

Please sign in to comment.