8206258: [Test Error] sun/security/pkcs11 tests fail if NSS libs not found
Improve the logics on skipping test Reviewed-by: valeriep
This commit is contained in:
parent
d2b2780859
commit
126394f271
@ -154,7 +154,15 @@ public abstract class PKCS11Test {
|
||||
|
||||
public abstract void main(Provider p) throws Exception;
|
||||
|
||||
protected boolean skipTest(Provider p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void premain(Provider p) throws Exception {
|
||||
if (skipTest(p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set a security manager and policy before a test case runs,
|
||||
// and disable them after the test case finished
|
||||
try {
|
||||
@ -327,9 +335,10 @@ public abstract class PKCS11Test {
|
||||
}
|
||||
|
||||
static boolean isBadNSSVersion(Provider p) {
|
||||
if (isNSS(p) && badNSSVersion) {
|
||||
double nssVersion = getNSSVersion();
|
||||
if (isNSS(p) && nssVersion >= 3.11 && nssVersion < 3.12) {
|
||||
System.out.println("NSS 3.11 has a DER issue that recent " +
|
||||
"version do not.");
|
||||
"version do not, skipping");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -667,9 +676,6 @@ public abstract class PKCS11Test {
|
||||
|
||||
private final static char[] hexDigits = "0123456789abcdef".toCharArray();
|
||||
|
||||
static final boolean badNSSVersion =
|
||||
getNSSVersion() >= 3.11 && getNSSVersion() < 3.12;
|
||||
|
||||
private static final String distro = distro();
|
||||
|
||||
static final boolean badSolarisSparc =
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
|
||||
* Copyright (c) 2017, 2018, Red Hat, Inc. and/or its affiliates.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -66,7 +66,9 @@ public final class TestNssDbSqlite extends SecmodTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
initialize();
|
||||
if (!initialize()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (enableDebug) {
|
||||
System.out.println("SunPKCS11 provider: " +
|
||||
@ -108,14 +110,15 @@ public final class TestNssDbSqlite extends SecmodTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static void initialize() throws Exception {
|
||||
initializeProvider();
|
||||
private static boolean initialize() throws Exception {
|
||||
return initializeProvider();
|
||||
}
|
||||
|
||||
private static void initializeProvider () throws Exception {
|
||||
private static boolean initializeProvider() throws Exception {
|
||||
useSqlite(true);
|
||||
if (!initSecmod()) {
|
||||
return;
|
||||
System.out.println("Cannot init security module database, skipping");
|
||||
return false;
|
||||
}
|
||||
|
||||
sunPKCS11NSSProvider = getSunPKCS11(BASE + SEP + "nss-sqlite.cfg");
|
||||
@ -132,5 +135,7 @@ public final class TestNssDbSqlite extends SecmodTest {
|
||||
gen.generate(2048);
|
||||
privateKey = gen.getPrivateKey();
|
||||
certificate = gen.getSelfCertificate(new X500Name("CN=Me"), 365);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2018, 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
|
||||
@ -47,12 +47,17 @@ public class TestDSAKeyLength extends PKCS11Test {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider provider) throws Exception {
|
||||
protected boolean skipTest(Provider provider) {
|
||||
if (isNSS(provider) && getNSSVersion() >= 3.14) {
|
||||
System.out.println("Skip testing NSS " + getNSSVersion());
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider provider) throws Exception {
|
||||
/*
|
||||
* Use Solaris SPARC 11.2 or later to avoid an intermittent failure
|
||||
* when running SunPKCS11-Solaris (8044554)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2018, 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
|
||||
@ -51,20 +51,21 @@ public class TestCurves extends PKCS11Test {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider p) throws Exception {
|
||||
protected boolean skipTest(Provider p) {
|
||||
if (p.getService("KeyAgreement", "ECDH") == null) {
|
||||
System.out.println("Not supported by provider, skipping");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBadNSSVersion(p)) {
|
||||
return;
|
||||
if (isBadNSSVersion(p) || isBadSolarisSparc(p)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBadSolarisSparc(p)) {
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider p) throws Exception {
|
||||
// Check if this is sparc for later failure avoidance.
|
||||
boolean sparc = false;
|
||||
if (props.getProperty("os.arch").equals("sparcv9")) {
|
||||
|
@ -91,17 +91,22 @@ public class TestECDH extends PKCS11Test {
|
||||
private final static String privBrainpoolP512r1b = "3062020100301406072a8648ce3d020106092b240303020801010d044730450201010440230e18e1bcc88a362fa54e4ea3902009292f7f8033624fd471b5d8ace49d12cfabbc19963dab8e2f1eba00bffb29e4d72d13f2224562f405cb80503666b25429";
|
||||
private final static String secretBrainpoolP512r1 = "a7927098655f1f9976fa50a9d566865dc530331846381c87256baf3226244b76d36403c024d7bbf0aa0803eaff405d3d24f11a9b5c0bef679fe1454b21c4cd1f";
|
||||
|
||||
@Override public void main(Provider p) throws Exception {
|
||||
@Override
|
||||
protected boolean skipTest(Provider p) {
|
||||
if (p.getService("KeyAgreement", "ECDH") == null) {
|
||||
System.out.println("Provider does not support ECDH, skipping");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isNSS(p) && getNSSECC() == ECCState.Basic) {
|
||||
System.out.println("NSS only supports Basic ECC. Skipping..");
|
||||
return;
|
||||
System.out.println("NSS only supports Basic ECC, skipping");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public void main(Provider p) throws Exception {
|
||||
/*
|
||||
* PKCS11Test.main will remove this provider if needed
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2018, 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
|
||||
@ -111,16 +111,21 @@ public class TestECDH2 extends PKCS11Test {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider provider) throws Exception {
|
||||
protected boolean skipTest(Provider provider) {
|
||||
if (provider.getService("KeyAgreement", "ECDH") == null) {
|
||||
System.out.println("ECDH not supported, skipping");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBadNSSVersion(provider)) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider provider) throws Exception {
|
||||
kf = KeyFactory.getInstance("EC", provider);
|
||||
kpg = KeyPairGenerator.getInstance("EC", provider);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2018, 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
|
||||
@ -120,21 +120,22 @@ public class TestECDSA extends PKCS11Test {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider provider) throws Exception {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
protected boolean skipTest(Provider provider) {
|
||||
if (provider.getService("Signature", "SHA1withECDSA") == null) {
|
||||
System.out.println("ECDSA not supported, skipping");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBadNSSVersion(provider)) {
|
||||
return;
|
||||
if (isBadNSSVersion(provider) || isBadSolarisSparc(provider)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBadSolarisSparc(provider)) {
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider provider) throws Exception {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
/*
|
||||
* PKCS11Test.main will remove this provider if needed
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2018, 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
|
||||
@ -101,6 +101,26 @@ public class TestECDSA2 extends PKCS11Test {
|
||||
main(new TestECDSA2(), args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean skipTest(Provider provider) {
|
||||
boolean testP256 =
|
||||
provider.getService("Signature", "SHA256withECDSA") != null;
|
||||
|
||||
boolean testP384 =
|
||||
provider.getService("Signature", "SHA384withECDSA") != null;
|
||||
|
||||
if (!testP256 && !testP384) {
|
||||
System.out.println("ECDSA not supported, skipping");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBadNSSVersion(provider)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider provider) throws Exception {
|
||||
boolean testP256 =
|
||||
@ -109,15 +129,6 @@ public class TestECDSA2 extends PKCS11Test {
|
||||
boolean testP384 =
|
||||
(provider.getService("Signature", "SHA384withECDSA") != null);
|
||||
|
||||
if (!testP256 && !testP384) {
|
||||
System.out.println("ECDSA not supported, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBadNSSVersion(provider)) {
|
||||
return;
|
||||
}
|
||||
|
||||
kf = KeyFactory.getInstance("EC", provider);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2018, 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
|
||||
@ -47,16 +47,21 @@ public class TestECGenSpec extends PKCS11Test {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider p) throws Exception {
|
||||
protected boolean skipTest(Provider p) {
|
||||
if (p.getService("Signature", "SHA1withECDSA") == null) {
|
||||
System.out.println("Provider does not support ECDSA, skipping...");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBadNSSVersion(p)) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void main(Provider p) throws Exception {
|
||||
String[] names = { "secp256r1", "NIST P-192", "sect163k1", "1.3.132.0.26",
|
||||
"X9.62 c2tnb239v1"};
|
||||
int curves = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user