Skip to content

Commit

Permalink
8258855: Two tests sun/security/krb5/auto/ReplayCacheTestProc.java an…
Browse files Browse the repository at this point in the history
…d ReplayCacheTestProcWithMD5.java failed on OL8.3

Reviewed-by: mdoerr
Backport-of: d70fd7b
  • Loading branch information
GoeLin committed Sep 28, 2021
1 parent d655d00 commit 8d78072
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
44 changes: 22 additions & 22 deletions test/jdk/sun/security/krb5/auto/ReplayCacheTestProc.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
* @build jdk.test.lib.Platform
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
* @run main/othervm/timeout=300 -Djdk.net.hosts.file=TestHosts
* ReplayCacheTestProc
* -Dtest.libs=J ReplayCacheTestProc
* @run main/othervm/timeout=300 -Djdk.net.hosts.file=TestHosts
* -Dtest.libs=N ReplayCacheTestProc
*/

import java.io.*;
Expand All @@ -45,6 +47,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jdk.test.lib.Asserts;
import jdk.test.lib.Platform;
import sun.security.jgss.GSSUtil;
import sun.security.krb5.internal.rcache.AuthTime;
Expand All @@ -53,9 +56,8 @@
* This test runs multiple acceptor Procs to mimic AP-REQ replays.
* These system properties are supported:
*
* - test.libs on what types of acceptors to use
* - test.libs on what types of acceptors to use. Cannot be null.
* Format: CSV of (J|N|N<suffix>=<libname>|J<suffix>=<launcher>)
* Default: J,N on Solaris and Linux where N is available, or J
* Example: J,N,N14=/krb5-1.14/lib/libgssapi_krb5.so,J8=/java8/bin/java
*
* - test.runs on manual runs. If empty, a iterate through all pattern
Expand Down Expand Up @@ -125,6 +127,16 @@ public static void main0(String[] args) throws Exception {
Ex[] result;
int numPerType = 2; // number of acceptors per type

// User-provided libs
String userLibs = System.getProperty("test.libs");
Asserts.assertNotNull(userLibs, "test.libs property must be provided");
libs = userLibs.split(",");
if (Arrays.asList(libs).contains("N") && !isNativeLibAvailable()) {
// Skip test when native GSS libs are not available in running platform
System.out.println("Native mode not available - skipped");
return;
}

KDC kdc = KDC.create(OneKDC.REALM, HOST, 0, true);
for (int i=0; i<nc; i++) {
kdc.addPrincipal(client(i), OneKDC.PASS);
Expand All @@ -142,25 +154,6 @@ public static void main0(String[] args) throws Exception {
// Write KTAB after krb5.conf so it contains no aes-sha2 keys
kdc.writeKtab(OneKDC.KTAB);

// User-provided libs
String userLibs = System.getProperty("test.libs");

if (userLibs != null) {
libs = userLibs.split(",");
} else {
if (Platform.isOSX() || Platform.isWindows()) {
// macOS uses Heimdal and Windows has no native lib
libs = new String[]{"J"};
} else {
if (acceptor("N", "sanity").waitFor() != 0) {
Proc.d("Native mode sanity check failed, only java");
libs = new String[]{"J"};
} else {
libs = new String[]{"J", "N"};
}
}
}

pi = Proc.create("ReplayCacheTestProc").debug("C")
.inheritProp("jdk.net.hosts.file")
.args("initiator")
Expand Down Expand Up @@ -337,6 +330,13 @@ public static void main(String[] args) throws Exception {
}
}

// returns true if native lib is available in running platform
// macOS uses Heimdal and Windows has no native lib
private static boolean isNativeLibAvailable() throws Exception {
return !Platform.isOSX() && !Platform.isWindows()
&& acceptor("N", "sanity").waitFor() == 0;
}

// returns the client name
private static String client(int p) {
return "client" + p;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
* @run main/othervm/timeout=300 -Djdk.krb5.rcache.useMD5=true
* -Djdk.net.hosts.file=TestHosts
* -Dtest.service=host ReplayCacheTestProc
* -Dtest.service=host
* -Dtest.libs=J ReplayCacheTestProc
*/

1 comment on commit 8d78072

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.