add test for CRCRLF armored files

This is an incorrect format that has been generated by GPG4USB (any
possibly GPG4WIN) for a long time. We better be compatible :(
This commit is contained in:
Vincent Breitmoser
2017-04-02 22:09:07 +02:00
parent 201a4f351f
commit 7caf02a4e6
4 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package org.sufficientlysecure.keychain;
import java.io.InputStream;
import org.bouncycastle.bcpg.ArmoredInputStream;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.sufficientlysecure.keychain.pgp.UncachedKeyringTest;
import org.sufficientlysecure.keychain.support.TestDataUtil;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@RunWith(KeychainTestRunner.class)
public class ArmoredInputStreamTest {
@Test
public void armoredInputStream__withDifferentLineEndings() throws Exception {
// these are generated by GPG4USB, see https://github.com/gpg4usb/gpg4usb/issues/25
ArmoredInputStream stream1 = new ArmoredInputStream(UncachedKeyringTest.class.getResourceAsStream("/armored_crcrlf.asc"));
ArmoredInputStream stream2 = new ArmoredInputStream(UncachedKeyringTest.class.getResourceAsStream("/armored_crlf.asc"));
ArmoredInputStream stream3 = new ArmoredInputStream(UncachedKeyringTest.class.getResourceAsStream("/armored_lf.asc"));
assertEquals(1, stream1.getArmorHeaders().length);
assertEquals("Comment: comment content", stream1.getArmorHeaders()[0]);
assertEquals(1, stream2.getArmorHeaders().length);
assertEquals("Comment: comment content", stream2.getArmorHeaders()[0]);
assertEquals(1, stream3.getArmorHeaders().length);
assertEquals("Comment: comment content", stream3.getArmorHeaders()[0]);
byte[] data1 = TestDataUtil.readFully(stream1);
byte[] data2 = TestDataUtil.readFully(stream2);
byte[] data3 = TestDataUtil.readFully(stream3);
assertArrayEquals(data1, data2);
assertArrayEquals(data1, data3);
}
}

View File

@@ -0,0 +1,7 @@
-----BEGIN PGP ARMORED FILE-----
Comment: comment content
bWkgY21hbHUgY21heGknYSwgdGhpcyBkdW1teSB0ZXh0IG11c3QgYmUgbG9uZyBl

View File

@@ -0,0 +1,7 @@
-----BEGIN PGP ARMORED FILE-----
Comment: comment content
bWkgY21hbHUgY21heGknYSwgdGhpcyBkdW1teSB0ZXh0IG11c3QgYmUgbG9uZyBl
bm91Z2ggZm9yIG11bHRpcGxlIGxpbmVzIG9mIGFybW9yZWQgdGV4dH4K
=Amd+
-----END PGP ARMORED FILE-----

View File

@@ -0,0 +1,7 @@
-----BEGIN PGP ARMORED FILE-----
Comment: comment content
bWkgY21hbHUgY21heGknYSwgdGhpcyBkdW1teSB0ZXh0IG11c3QgYmUgbG9uZyBl
bm91Z2ggZm9yIG11bHRpcGxlIGxpbmVzIG9mIGFybW9yZWQgdGV4dH4K
=Amd+
-----END PGP ARMORED FILE-----