Skip to content

Commit e1cad97

Browse files
fgualliniAlekseiEfimov
authored andcommitted
8262862: Harden tests sun/security/x509/URICertStore/ExtensionsWithLDAP.java and krb5/canonicalize/Test.java
Reviewed-by: aefimov, michaelm
1 parent 2c0507e commit e1cad97

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

test/jdk/sun/security/krb5/canonicalize/Test.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2021, 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
@@ -25,21 +25,16 @@
2525
* @bug 6682516 8149521
2626
* @summary SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
2727
* @modules java.security.jgss/sun.security.krb5
28-
* @run main/othervm -Djava.security.krb5.conf=krb5.conf Test
28+
* @run main/othervm -Djdk.net.hosts.file=${test.src}/TestHosts
29+
* -Djava.security.krb5.realm=THIS.REALM
30+
* -Djava.security.krb5.kdc=localhost
31+
* -Djava.security.krb5.conf=krb5.conf Test
2932
*/
3033

31-
import java.net.InetAddress;
32-
import java.net.UnknownHostException;
3334
import sun.security.krb5.PrincipalName;
3435

3536
public class Test {
3637
public static void main(String[] args) throws Exception {
37-
// This config file is generated using Kerberos.app on a Mac
38-
String hostsFileName = System.getProperty("test.src", ".") + "/TestHosts";
39-
System.setProperty("jdk.net.hosts.file", hostsFileName);
40-
System.setProperty("java.security.krb5.realm", "THIS.REALM");
41-
System.setProperty("java.security.krb5.kdc", "localhost");
42-
4338
// add using canonicalized name
4439
check("c1", "c1.this.domain");
4540
check("c1.this", "c1.this.domain");

test/jdk/sun/security/x509/URICertStore/ExtensionsWithLDAP.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, 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
@@ -27,18 +27,19 @@
2727
* @test
2828
* @bug 8134708
2929
* @summary Check if LDAP resources from CRLDP and AIA extensions can be loaded
30-
* @run main/othervm ExtensionsWithLDAP CRLDP ldap.host.for.crldp
30+
* @run main/othervm -Djdk.net.hosts.file=${test.src}/CRLDP
31+
* -Dcom.sun.security.enableCRLDP=true
32+
* ExtensionsWithLDAP CRLDP ldap.host.for.crldp
3133
* @modules jdk.security.auth
32-
* @run main/othervm ExtensionsWithLDAP AIA ldap.host.for.aia
34+
* @run main/othervm -Djdk.net.hosts.file=${test.src}/AIA
35+
* -Dcom.sun.security.enableAIAcaIssuers=true
36+
* ExtensionsWithLDAP AIA ldap.host.for.aia
3337
*/
3438

3539
import java.io.ByteArrayInputStream;
36-
import java.io.File;
3740
import java.io.IOException;
3841
import java.net.InetSocketAddress;
3942
import java.net.Socket;
40-
import java.nio.file.Path;
41-
import java.nio.file.Paths;
4243
import java.security.cert.CertPath;
4344
import java.security.cert.CertPathValidator;
4445
import java.security.cert.CertPathValidatorException;
@@ -132,15 +133,6 @@ public static void main(String[] args) throws Exception {
132133
String extension = args[0];
133134
String targetHost = args[1];
134135

135-
// enable CRLDP and AIA extensions
136-
System.setProperty("com.sun.security.enableCRLDP", "true");
137-
System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
138-
139-
Path hostsFilePath = Paths.get(System.getProperty("test.src", ".")
140-
+ File.separator + extension);
141-
System.setProperty("jdk.net.hosts.file",
142-
hostsFilePath.toFile().getAbsolutePath());
143-
144136
X509Certificate trustedCert = loadCertificate(CA_CERT);
145137
X509Certificate eeCert = loadCertificate(EE_CERT);
146138

0 commit comments

Comments
 (0)