[java-opensaml COMMIT] in /trunk: opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTe...

noreply at shibboleth.net noreply at shibboleth.net
Thu Sep 25 18:01:08 EDT 2014


Author: putmanb
Date: Thu Sep 25 18:00:56 2014
New Revision: 4072

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4072&view=rev
Log:
Use TestNG @DataProvider to run some tests both with and without BouncyCastle loaded. 

Modified:
    trunk/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
    trunk/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java

Modified: trunk/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java?rev=4072&r1=4071&r2=4072&view=diff
==============================================================================
--- trunk/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java (original)
+++ trunk/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java Thu Sep 25 18:00:56 2014
@@ -18,13 +18,17 @@
 package org.opensaml.xmlsec.algorithm;
 
 import org.opensaml.core.OpenSAMLInitBaseTestCase;
+import org.opensaml.core.config.ConfigurationService;
+import org.opensaml.core.config.InitializationException;
 import org.opensaml.security.SecurityProviderTestSupport;
 import org.opensaml.security.crypto.JCAConstants;
 import org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256;
 import org.opensaml.xmlsec.algorithm.descriptors.SignatureRSASHA256;
+import org.opensaml.xmlsec.config.GlobalAlgorithmRegistryInitializer;
 import org.opensaml.xmlsec.encryption.support.EncryptionConstants;
 import org.opensaml.xmlsec.signature.support.SignatureConstants;
 import org.testng.Assert;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
@@ -36,6 +40,14 @@
     
     public AlgorithmRegistryTest() {
         providerSupport = new SecurityProviderTestSupport();
+    }
+    
+    @DataProvider
+    public Object[][] loadBCTestData() {
+        return new Object[][] {
+                new Object[] {Boolean.FALSE},
+                new Object[] {Boolean.TRUE},
+        };
     }
     
     @Test
@@ -153,117 +165,122 @@
         
     }
     
-    @Test
-    public void testGlobalRegistryRuntimeSupported() {
-        AlgorithmRegistry registry = AlgorithmSupport.getGlobalAlgorithmRegistry();
+    @Test(dataProvider = "loadBCTestData")
+    public void testGlobalRegistryRuntimeSupported(boolean loadBC) throws InitializationException {
+        AlgorithmRegistry originalRegistry = AlgorithmSupport.getGlobalAlgorithmRegistry();
+        Assert.assertNotNull(originalRegistry);
+        AlgorithmRegistry registry = originalRegistry;
+        
+        if (loadBC) {
+            providerSupport.loadBC();
+            new GlobalAlgorithmRegistryInitializer().init();
+            registry = AlgorithmSupport.getGlobalAlgorithmRegistry();
+        }
+        
         Assert.assertNotNull(registry);
         
-        // First test all default algos expected to be supported unconditionally on 
-        // vanilla Java 7+ with no additional security providers
-        
-        // BlockEncryption
-        Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128));
-        Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192));
-        Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256));
-        Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_BLOCKCIPHER_TRIPLEDES));
-        
-        // Digest
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA1));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA256));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA384));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA512));
-        
-        // HMAC
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA1));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA256));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA384));
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA512));
-        
-        // KeyTransport
-        Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15));
-        Assert.assertTrue(registry.isRuntimeSupported(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP));
-        
-        // Signature
-        Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_DSA_SHA1));

[... 405 lines stripped ...]


More information about the commits mailing list