RFR: 8262862: Harden tests sun/security/x509/URICertStore/ExtensionsWithLDAP.java and krb5/canonicalize/Test.java

Aleksei Efimov aefimov at openjdk.java.net
Thu Mar 4 13:51:41 UTC 2021


On Wed, 3 Mar 2021 12:23:00 GMT, Fernando Guallini <fguallini at openjdk.org> wrote:

> Certain JVM tools may access and initialise InetAddress class and its static fields during start up resulting in a NameService implementation being already set to the default **PlatformNameService**, causing intermittent failures in some tests that expect the use of **HostsFileNameService** instead by setting the system property jdk.net.hosts.file in the test main body, which has no effect in this scenario
> 
> By setting the property **jdk.net.hosts.file** in the @run tag, there is certainty that it will be properly configured at the time that a [NameService](https://github.com/openjdk/jdk/blob/382e38dd246596ec94a1f1ce0e0f9e87f53366c7/src/java.base/share/classes/java/net/InetAddress.java#L1155) is created

Hi Fernando,

Changes look good to me.
Have one minor suggestion to also move other system properties to jtreg header:

test/jdk/sun/security/krb5/canonicalize/Test.java line 37:

> 35:     public static void main(String[] args) throws Exception {
> 36:         // This config file is generated using Kerberos.app on a Mac
> 37:         System.setProperty("java.security.krb5.realm", "THIS.REALM");

Maybe, you can move setting of `java.security.krb5.realm` and `java.security.krb5.kdc` properties to the `jtreg` header to have consistent approach of setting properties needed for a test run.

test/jdk/sun/security/x509/URICertStore/ExtensionsWithLDAP.java line 135:

> 133: 
> 134:         // enable CRLDP and AIA extensions
> 135:         System.setProperty("com.sun.security.enableCRLDP", "true");

Same suggestion for `com.sun.security.enableCRLDP` and `com.sun.security.enableAIAcaIssuers` properties.

-------------

Marked as reviewed by aefimov (Committer).

PR: https://git.openjdk.java.net/jdk/pull/2809



More information about the security-dev mailing list