summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClint Adams <clint@debian.org>2012-04-25 22:26:57 -0400
committerClint Adams <clint@debian.org>2012-04-25 22:26:57 -0400
commitd17ea2bb11255f7e6ae9069d3b58e8f06d5946a5 (patch)
tree60c0cebd5ae6be14f293ca96e9756351581fa497 /tests
parent83f494d1c3dbf75054284334bc30e8a1b9825146 (diff)
Add multipartMerge
Diffstat (limited to 'tests')
-rw-r--r--tests/data/msg2.asc13
-rw-r--r--tests/data/msg2.pgpbin0 -> 126 bytes
-rw-r--r--tests/suite.hs15
3 files changed, 26 insertions, 2 deletions
diff --git a/tests/data/msg2.asc b/tests/data/msg2.asc
new file mode 100644
index 0000000..7e5a287
--- /dev/null
+++ b/tests/data/msg2.asc
@@ -0,0 +1,13 @@
1-----BEGIN PGP MESSAGE, PART 01/02-----
2Version: ClosedPrivacy 0.99
3
4pgAAAHnw/J+O5ibiYizWTVDTrl/FUe926aD7lhNS+qjFNASGRmSSvWqWyubVcW0Z
5YnVtKfpv03Y+zIUQv+TATmWcwpkzhQ9QeTk70ZBFFmNXsuM12dTQGkY8IDRsmUT9
6=H7u4
7-----END PGP MESSAGE, PART 01/02-----
8
9-----BEGIN PGP MESSAGE, PART 02/02-----
10
11m+f4GTQ2FwJzO0GeazzBV4ywKLqSnCQVFBNKhDnw
12=hLwC
13-----END PGP MESSAGE, PART 02/02-----
diff --git a/tests/data/msg2.pgp b/tests/data/msg2.pgp
new file mode 100644
index 0000000..46c4db7
--- /dev/null
+++ b/tests/data/msg2.pgp
Binary files differ
diff --git a/tests/suite.hs b/tests/suite.hs
index a843664..6fdd816 100644
--- a/tests/suite.hs
+++ b/tests/suite.hs
@@ -3,7 +3,7 @@ import Test.Framework.Providers.HUnit
3 3
4import Test.HUnit 4import Test.HUnit
5 5
6import Codec.Encryption.OpenPGP.ASCIIArmor (encode, decode) 6import Codec.Encryption.OpenPGP.ASCIIArmor (encode, decode, multipartMerge)
7import Codec.Encryption.OpenPGP.ASCIIArmor.Types 7import Codec.Encryption.OpenPGP.ASCIIArmor.Types
8 8
9import Data.ByteString (ByteString) 9import Data.ByteString (ByteString)
@@ -21,7 +21,17 @@ testArmorDecode fp targets = do
21 tbss <- mapM (\target -> B.readFile $ "tests/data/" ++ target) targets 21 tbss <- mapM (\target -> B.readFile $ "tests/data/" ++ target) targets
22 case decode bs of 22 case decode bs of
23 Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp 23 Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp
24 Right as -> do assertEqual ("for " ++ fp) tbss (map getPayload as) 24 Right as -> assertEqual ("for " ++ fp) tbss (map getPayload as)
25 where
26 getPayload (Armor _ _ pl) = pl
27
28testArmorMultipartDecode :: FilePath -> FilePath -> Assertion
29testArmorMultipartDecode fp target = do
30 bs <- B.readFile $ "tests/data/" ++ fp
31 tbs <- B.readFile $ "tests/data/" ++ target
32 case decode bs of
33 Left e -> assertFailure $ "Decode failed (" ++ e ++ ") on " ++ fp
34 Right as -> assertEqual ("for " ++ fp) tbs (getPayload (multipartMerge as))
25 where 35 where
26 getPayload (Armor _ _ pl) = pl 36 getPayload (Armor _ _ pl) = pl
27 37
@@ -41,6 +51,7 @@ tests = [
41 testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"]) 51 testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"])
42 , testCase "Decode sample armor with cruft" (testArmorDecode "msg1a.asc" ["msg1.gpg"]) 52 , testCase "Decode sample armor with cruft" (testArmorDecode "msg1a.asc" ["msg1.gpg"])
43 , testCase "Decode multiple sample armors" (testArmorDecode "msg1b.asc" ["msg1.gpg","msg1.gpg","msg1.gpg"]) 53 , testCase "Decode multiple sample armors" (testArmorDecode "msg1b.asc" ["msg1.gpg","msg1.gpg","msg1.gpg"])
54 , testCase "Decode multi-part armor" (testArmorMultipartDecode "msg2.asc" "msg2.pgp")
44 , testCase "Encode sample armor" (testArmorEncode ["msg1.gpg"] "msg1.asc") 55 , testCase "Encode sample armor" (testArmorEncode ["msg1.gpg"] "msg1.asc")
45 , testCase "Encode multiple sample armors" (testArmorEncode ["msg1.gpg","msg1.gpg","msg1.gpg"] "msg1c.asc") 56 , testCase "Encode multiple sample armors" (testArmorEncode ["msg1.gpg","msg1.gpg","msg1.gpg"] "msg1c.asc")
46 ] 57 ]