RFR: 8349533: Refactor validator tests shell files to java [v4]

Weijun Wang weijun at openjdk.org
Mon Feb 24 17:32:55 UTC 2025


On Mon, 24 Feb 2025 16:47:32 GMT, Mikhail Yankelevich <duke at openjdk.org> wrote:

>> Changed shell files to be java tests:
>> * ./validator/certreplace.sh
>> * ./validator/samedn.sh
>
> Mikhail Yankelevich has updated the pull request incrementally with one additional commit since the last revision:
> 
>   othervm rm

test/jdk/sun/security/validator/CertReplace.java line 50:

> 48:  * @modules java.base/sun.security.validator
> 49:  *
> 50:  * @run main/othervm CertReplace certreplace.jks certreplace.certs

This one does not require `othervm` either.

test/jdk/sun/security/validator/CertReplace.java line 105:

> 103: 
> 104:         //putting the certificate in the keystore
> 105:         final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");

This is useless now.

test/jdk/sun/security/validator/CertReplace.java line 113:

> 111:                 )
> 112:         };
> 113:         certInputStream.close();

Usually we use `try (FileInputStream...)` but your style is also OK. Otherwise we will need to define `certs` outside. You choose.

test/jdk/sun/security/validator/CertReplace.java line 171:

> 169:                               "-genkeypair -alias user -dname CN=User -keyalg rsa");
> 170: 
> 171:         final KeyStore keyStore = KeyStoreUtils.loadKeyStore(SAMEDN_JKS, PASSWORD);

Although no change to behavior in this method, I'd prefer seeing this line right before the `deleteEntry` call.

test/jdk/sun/security/validator/CertReplace.java line 205:

> 203: 
> 204:         KeyStore ks = KeyStore.getInstance("JKS");
> 205:         ks.load(new FileInputStream(args[0]), "changeit".toCharArray());

You've defined `PASSWORD_CHAR_ARR` for this char array.

Also, close this `FileInputStream` to be safe, and the one in `createPath` method below.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23727#discussion_r1968085635
PR Review Comment: https://git.openjdk.org/jdk/pull/23727#discussion_r1968087893
PR Review Comment: https://git.openjdk.org/jdk/pull/23727#discussion_r1968083523
PR Review Comment: https://git.openjdk.org/jdk/pull/23727#discussion_r1968093230
PR Review Comment: https://git.openjdk.org/jdk/pull/23727#discussion_r1968095859


More information about the security-dev mailing list