commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r679974 - in /commons/sandbox/openpgp/trunk/src: main/java/org/apache/commons/openpgp/ test/java/org/apache/commons/openpgp/ test/resources/
Date Sat, 26 Jul 2008 09:29:07 GMT
Author: brett
Date: Sat Jul 26 02:29:06 2008
New Revision: 679974

URL: http://svn.apache.org/viewvc?rev=679974&view=rev
Log:
add tests for signatures done within the same packet set

Added:
    commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-bad.asc
    commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-good.asc
    commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-missing.asc
    commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-good-one-missing.asc
    commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-missing-one-good.asc
Modified:
    commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignatureVerifier.java
    commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java

Modified: commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignatureVerifier.java
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignatureVerifier.java?rev=679974&r1=679973&r2=679974&view=diff
==============================================================================
--- commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignatureVerifier.java
(original)
+++ commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleOpenPgpStreamingSignatureVerifier.java
Sat Jul 26 02:29:06 2008
@@ -66,6 +66,11 @@
                 PGPSignatureList p3;
 
                 Object o = pgpFact.nextObject();
+                if ( o == null )
+                {
+                    break;
+                }
+                
                 if ( o instanceof PGPCompressedData )
                 {
                     PGPCompressedData c1 = (PGPCompressedData) o;

Modified: commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java?rev=679974&r1=679973&r2=679974&view=diff
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java
(original)
+++ commons/sandbox/openpgp/trunk/src/test/java/org/apache/commons/openpgp/BouncyCastleOpenPgpSignerTest.java
Sat Jul 26 02:29:06 2008
@@ -157,7 +157,7 @@
         assertNotNull( "check we got a status", status );
         assertFalse( "check it was not successful", status.isValid() );
     }
-
+/* Requires Bouncycastle 140 to work
     public void testVerifyMultipleSignatureDetachedAsciiOneMissingOneGood()
         throws IOException, OpenPgpException
     {
@@ -168,7 +168,7 @@
 
         assertNotNull( "check we got a status", status );
         assertTrue( "check it was successful", status.isValid() );
-    }
+    }*/
 
     public void testVerifyMultipleSignatureDetachedAsciiBothMissing()
         throws IOException, OpenPgpException
@@ -184,4 +184,66 @@
             assertTrue( true );
         }
     }
+
+    public void testVerifyDualSignatureDetachedAsciiBothGood()
+        throws IOException, OpenPgpException
+    {
+        SignatureStatus status =
+            verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input"
),
+                                              getClass().getResourceAsStream( "/test-input-dual-both-good.asc"
), keyRing );
+
+        assertNotNull( "check we got a status", status );
+        assertTrue( "check it was successful", status.isValid() );
+    }
+
+    public void testVerifyDualSignatureDetachedAsciiOneGoodOneMissing()
+        throws IOException, OpenPgpException
+    {
+        SignatureStatus status =
+            verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input"
),
+                                              getClass().getResourceAsStream( "/test-input-dual-one-good-one-missing.asc"
),
+                                              keyRing );
+
+        assertNotNull( "check we got a status", status );
+        assertTrue( "check it was successful", status.isValid() );
+    }
+
+    public void testVerifyDualSignatureDetachedAsciiBad()
+        throws IOException, OpenPgpException
+    {
+        SignatureStatus status =
+            verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input"
),
+                                              getClass().getResourceAsStream( "/test-input-dual-bad.asc"
),
+                                              keyRing );
+
+        assertNotNull( "check we got a status", status );
+        assertFalse( "check it was not successful", status.isValid() );
+    }
+
+    public void testVerifyDualSignatureDetachedAsciiOneMissingOneGood()
+        throws IOException, OpenPgpException
+    {
+        SignatureStatus status =
+            verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input"
),
+                                              getClass().getResourceAsStream( "/test-input-dual-one-missing-one-good.asc"
),
+                                              keyRing );
+
+        assertNotNull( "check we got a status", status );
+        assertTrue( "check it was successful", status.isValid() );
+    }
+
+    public void testVerifyDualSignatureDetachedAsciiBothMissing()
+        throws IOException, OpenPgpException
+    {
+        try
+        {
+            verifier.verifyDetachedSignature( getClass().getResourceAsStream( "/test-input"
),
+                                              getClass().getResourceAsStream( "/test-input-dual-both-missing.asc"
), keyRing );
+            fail( "Expected failure due to missing keys" );
+        }
+        catch ( UnknownKeyException e )
+        {
+            assertTrue( true );
+        }
+    }
 }

Added: commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-bad.asc
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-bad.asc?rev=679974&view=auto
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-bad.asc (added)
+++ commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-bad.asc Sat Jul 26 02:29:06
2008
@@ -0,0 +1,8 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.8 (Darwin)
+
+iEYEABECAAYFAkiK7HAACgkQTusOMqfRa9ShnwCcC3ePdig3dJl2LUHIKshpDISQ
+fNQAoJBEF9h+A6q5RYtJ85gsy5ouwEK6iEYEABECAAYFAkiK7HAACgkQCtKsbObC
+q2ihnwCgxLzsxpkuNFXSmqDYr6FVQjLCRNYAnR397d1XkRGAl3+MkTwlxXDd84TE
+=REvD
+-----END PGP SIGNATURE-----

Added: commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-good.asc
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-good.asc?rev=679974&view=auto
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-good.asc (added)
+++ commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-good.asc Sat Jul
26 02:29:06 2008
@@ -0,0 +1,8 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.8 (Darwin)
+
+iEYEABECAAYFAkiK7L0ACgkQTusOMqfRa9SErACfTXAvqffjiEuo3NAWe8yyLq4W
+zD4An3Bahy/AotWAsxEwIR5JpcUedykdiEYEABECAAYFAkiK7L0ACgkQCtKsbObC
+q2iErACg3uLtPlq2gVMj1C1s4kZ9vWAzA4IAn3qhEAxmjwl02uqLPRd9yFnT0r6Q
+=87kc
+-----END PGP SIGNATURE-----

Added: commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-missing.asc
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-missing.asc?rev=679974&view=auto
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-missing.asc (added)
+++ commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-both-missing.asc Sat
Jul 26 02:29:06 2008
@@ -0,0 +1,8 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.8 (Darwin)
+
+iEYEABECAAYFAkiK7WYACgkQxbsDNW2stZbyegCbBRTFzYNwZ7276aFKm/3EyGj5
+7V4AoIIVHZSNRVSlXOGHemI5q20fwkTjiEYEABECAAYFAkiK7WYACgkQBZj5naYw
+bBryegCfR4i/Ey2V0/BIikXBlpJi7qu3i9YAnRTox0uVh1Kcmp1/TFhXkcS6OUcd
+=kilw
+-----END PGP SIGNATURE-----

Added: commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-good-one-missing.asc
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-good-one-missing.asc?rev=679974&view=auto
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-good-one-missing.asc
(added)
+++ commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-good-one-missing.asc
Sat Jul 26 02:29:06 2008
@@ -0,0 +1,8 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.8 (Darwin)
+
+iEYEABECAAYFAkiK7SYACgkQxbsDNW2stZaDsQCePz9bg/LS1ZpjwoBAMAbhIvFb
+/KkAnR92Rq42/NAN5Clubp3f8ESeURuGiEYEABECAAYFAkiK7SYACgkQTusOMqfR
+a9SDsQCg17TBUS+FCNDYKU95ZFQtecSg/fgAnilXfAeFaelG+HHgg1lfP0yJpVSF
+=XvTx
+-----END PGP SIGNATURE-----

Added: commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-missing-one-good.asc
URL: http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-missing-one-good.asc?rev=679974&view=auto
==============================================================================
--- commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-missing-one-good.asc
(added)
+++ commons/sandbox/openpgp/trunk/src/test/resources/test-input-dual-one-missing-one-good.asc
Sat Jul 26 02:29:06 2008
@@ -0,0 +1,8 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.8 (Darwin)
+
+iEYEABECAAYFAkiK7OgACgkQTusOMqfRa9T6nACglTPtDb3O3SZUzweVpBD1D2FI
+HMkAoLSaB41kzDCNYIihEJQMNZg3+4IriEYEABECAAYFAkiK7OgACgkQxbsDNW2s
+tZb6nACdGVPYzUB58q3ZWK3m3vQSYyG9NH4AmwcYsUsKSO7wsrhJeot6t7Loz5uw
+=DB9I
+-----END PGP SIGNATURE-----



Mime
View raw message