[java-opensaml] branch main updated: JSPT-103 Review use of Java version helper methods and deprecate
Rod Widdowson
rdw at steadingsoftware.com
Tue Feb 16 13:50:25 UTC 2021
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=5e4ddc34603b8f8737709cf574ad2552ee164e82
The following commit(s) were added to refs/heads/main by this push:
new 5e4ddc346 JSPT-103 Review use of Java version helper methods and deprecate
5e4ddc346 is described below
commit 5e4ddc34603b8f8737709cf574ad2552ee164e82
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Feb 16 13:47:23 2021 +0000
JSPT-103 Review use of Java version helper methods and deprecate
Remove Java 8 tests
https://issues.shibboleth.net/jira/browse/JSPT-103
---
.../resolver/filter/impl/ScriptedFunctionTest.java | 29 ++--------
.../saml/metadata/resolver/filter/impl/script.js | 4 --
.../xmlsec/algorithm/AlgorithmRegistryTest.java | 65 +++++++---------------
.../AlgorithmRuntimeSupportedPredicateTest.java | 49 ++++------------
4 files changed, 37 insertions(+), 110 deletions(-)
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ScriptedFunctionTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ScriptedFunctionTest.java
index 51f16a7eb..b87e9482d 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ScriptedFunctionTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/filter/impl/ScriptedFunctionTest.java
@@ -23,10 +23,6 @@ import java.util.Set;
import javax.script.ScriptException;
-import net.shibboleth.ext.spring.resource.ResourceHelper;
-import net.shibboleth.utilities.java.support.resource.Resource;
-import net.shibboleth.utilities.java.support.testing.TestSupport;
-
import org.opensaml.core.testing.XMLObjectBaseTestCase;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
@@ -36,29 +32,17 @@ import org.springframework.core.io.ClassPathResource;
import org.testng.Assert;
import org.testng.annotations.Test;
+import net.shibboleth.ext.spring.resource.ResourceHelper;
+import net.shibboleth.utilities.java.support.resource.Resource;
+
/**
*
*/
+ at SuppressWarnings("javadoc")
public class ScriptedFunctionTest extends XMLObjectBaseTestCase {
- static final String SCRIPT_7 = "s = new java.lang.String(\"String\");set = new java.util.HashSet();set.add(s);set";
static final String SCRIPT_8 = "JavaString=Java.type(\"java.lang.String\"); JavaSet = Java.type(\"java.util.HashSet\");set = new JavaSet();set.add(new JavaString(\"String\"));set";
- static final String FILE_7 = "/org/opensaml/saml/metadata/resolver/filter/impl/script.js";
static final String FILE_8 = "/org/opensaml/saml/metadata/resolver/filter/impl/script8.js";
-
- private String script() {
- if (TestSupport.isJavaV8OrLater()) {
- return SCRIPT_8;
- }
- return SCRIPT_7;
- }
-
- private String file() {
- if (TestSupport.isJavaV8OrLater()) {
- return FILE_8;
- }
- return FILE_7;
- }
private XMLObject makeObject() {
final SAMLObjectBuilder<EntityDescriptor> builder = (SAMLObjectBuilder<EntityDescriptor>)
@@ -67,17 +51,16 @@ public class ScriptedFunctionTest extends XMLObjectBaseTestCase {
return builder.buildObject();
}
-
@Test public void inlineScript() throws ScriptException {
- final Set<String> s = ScriptedTrustedNamesFunction.inlineScript(script()).apply(makeObject());
+ final Set<String> s = ScriptedTrustedNamesFunction.inlineScript(SCRIPT_8).apply(makeObject());
Assert.assertEquals(s.size(), 1);
Assert.assertTrue(s.contains("String"));
}
@Test public void fileScript() throws ScriptException, IOException {
- final Resource r = ResourceHelper.of(new ClassPathResource(file()));
+ final Resource r = ResourceHelper.of(new ClassPathResource(FILE_8));
final Set<String> result = ScriptedTrustedNamesFunction.resourceScript(r).apply(makeObject());
Assert.assertEquals(result.size(), 1);
diff --git a/opensaml-saml-impl/src/test/resources/org/opensaml/saml/metadata/resolver/filter/impl/script.js b/opensaml-saml-impl/src/test/resources/org/opensaml/saml/metadata/resolver/filter/impl/script.js
deleted file mode 100644
index b85270561..000000000
--- a/opensaml-saml-impl/src/test/resources/org/opensaml/saml/metadata/resolver/filter/impl/script.js
+++ /dev/null
@@ -1,4 +0,0 @@
-s = new java.lang.String("String");
-set = new java.util.HashSet();
-set.add(s);
-set
\ No newline at end of file
diff --git a/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java b/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
index 902a00fd7..e97a32495 100644
--- a/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
+++ b/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
@@ -35,11 +35,10 @@ import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import net.shibboleth.utilities.java.support.testing.TestSupport;
-
/**
* Tests for the AlgorithmRegistry.
*/
+ at SuppressWarnings("javadoc")
public class AlgorithmRegistryTest extends OpenSAMLInitBaseTestCase {
private SecurityProviderTestSupport providerSupport;
@@ -79,21 +78,21 @@ public class AlgorithmRegistryTest extends OpenSAMLInitBaseTestCase {
@Test
public void testTypeIndexing() {
AlgorithmRegistry registry = new AlgorithmRegistry();
-
+
Assert.assertNull(registry.get(SignatureConstants.ALGO_ID_DIGEST_SHA256));
-
+
Assert.assertTrue(registry.getRegisteredURIsByType(AlgorithmType.MessageDigest).isEmpty());
Assert.assertTrue(registry.getRegisteredByType(AlgorithmType.MessageDigest).isEmpty());
-
+
registry.register(new DigestSHA256());
-
+
Assert.assertEquals(registry.getRegisteredURIsByType(AlgorithmType.MessageDigest).size(), 1);
Assert.assertTrue(registry.getRegisteredURIsByType(AlgorithmType.MessageDigest).contains(SignatureConstants.ALGO_ID_DIGEST_SHA256));
Assert.assertEquals(registry.getRegisteredByType(AlgorithmType.MessageDigest).size(), 1);
Assert.assertTrue(DigestSHA256.class.isInstance(registry.getRegisteredByType(AlgorithmType.MessageDigest).iterator().next()));
-
+
registry.deregister(new DigestSHA256());
-
+
Assert.assertTrue(registry.getRegisteredURIsByType(AlgorithmType.MessageDigest).isEmpty());
Assert.assertTrue(registry.getRegisteredByType(AlgorithmType.MessageDigest).isEmpty());
}
@@ -325,8 +324,6 @@ public class AlgorithmRegistryTest extends OpenSAMLInitBaseTestCase {
Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_KEYWRAP_AES256));
Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_KEYWRAP_TRIPLEDES));
-
-
// Conditional environment tests
if (providerSupport.haveSunEC() || providerSupport.haveBC()) {
@@ -335,9 +332,7 @@ public class AlgorithmRegistryTest extends OpenSAMLInitBaseTestCase {
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA384));
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
- if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
- }
+ Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
} else {
Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA1));
Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
@@ -345,40 +340,18 @@ public class AlgorithmRegistryTest extends OpenSAMLInitBaseTestCase {
Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA384));
Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
}
+
+ Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA224));
+ Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
+ Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
- if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA224));
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
-
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
-
- Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128_GCM));
- Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192_GCM));
- Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM));
-
- Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP11));
- } else {
- if (providerSupport.isOpenJDK()) {
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA224));
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
-
- Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
- } else {
- Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA224));
- Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
- Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
-
- Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
- }
-
- Assert.assertFalse(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128_GCM));
- Assert.assertFalse(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192_GCM));
- Assert.assertFalse(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM));
-
- Assert.assertFalse(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP11));
- }
+ Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
+
+ Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128_GCM));
+ Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192_GCM));
+ Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM));
+
+ Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP11));
if (providerSupport.haveBC()) {
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_RIPEMD160));
diff --git a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java
index 88362ed24..9f97447ed 100644
--- a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java
+++ b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java
@@ -31,8 +31,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import net.shibboleth.utilities.java.support.testing.TestSupport;
-
+ at SuppressWarnings("javadoc")
public class AlgorithmRuntimeSupportedPredicateTest extends OpenSAMLInitBaseTestCase {
private AlgorithmRuntimeSupportedPredicate predicate;
@@ -113,9 +112,7 @@ public class AlgorithmRuntimeSupportedPredicateTest extends OpenSAMLInitBaseTest
Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA384));
Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
- if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
- }
+ Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
} else {
Assert.assertFalse(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA1));
Assert.assertFalse(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
@@ -124,38 +121,16 @@ public class AlgorithmRuntimeSupportedPredicateTest extends OpenSAMLInitBaseTest
Assert.assertFalse(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
}
- if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_DIGEST_SHA224));
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
-
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
-
- Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128_GCM));
- Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192_GCM));
- Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM));
- Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP11));
- } else {
- if (providerSupport.isOpenJDK()) {
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_DIGEST_SHA224));
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
-
- Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
- } else {
- Assert.assertFalse(predicate.test(SignatureConstants.ALGO_ID_DIGEST_SHA224));
- Assert.assertFalse(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
- Assert.assertFalse(predicate.test(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
-
- Assert.assertFalse(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
- }
-
- Assert.assertFalse(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128_GCM));
- Assert.assertFalse(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192_GCM));
- Assert.assertFalse(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM));
-
- Assert.assertFalse(predicate.test(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP11));
- }
+ Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_DIGEST_SHA224));
+ Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
+ Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
+
+ Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA256));
+
+ Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128_GCM));
+ Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192_GCM));
+ Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM));
+ Assert.assertTrue(predicate.test(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP11));
if (providerSupport.haveBC()) {
Assert.assertTrue(predicate.test(SignatureConstants.ALGO_ID_DIGEST_RIPEMD160));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list