summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClint Adams <clint@debian.org>2012-04-25 19:26:58 -0400
committerClint Adams <clint@debian.org>2012-04-25 19:27:26 -0400
commit4a0bb47803be6be43b8bb5c62f302019a25f9fd1 (patch)
tree53c0f2ae494136395401d6dc73f4409cba4f0637 /tests
parentf06c3f713f99c9ea09a76728ffce2c6e1c957070 (diff)
Encode multiple Armors into one ByteString.
Diffstat (limited to 'tests')
-rw-r--r--tests/data/msg1c.asc21
-rw-r--r--tests/suite.hs13
2 files changed, 28 insertions, 6 deletions
diff --git a/tests/data/msg1c.asc b/tests/data/msg1c.asc
new file mode 100644
index 0000000..c7ac785
--- /dev/null
+++ b/tests/data/msg1c.asc
@@ -0,0 +1,21 @@
1-----BEGIN PGP MESSAGE-----
2Version: OpenPrivacy 0.99
3
4yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
5vBSFjNSiVHsuAA==
6=njUN
7-----END PGP MESSAGE-----
8-----BEGIN PGP MESSAGE-----
9Version: OpenPrivacy 0.99
10
11yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
12vBSFjNSiVHsuAA==
13=njUN
14-----END PGP MESSAGE-----
15-----BEGIN PGP MESSAGE-----
16Version: OpenPrivacy 0.99
17
18yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
19vBSFjNSiVHsuAA==
20=njUN
21-----END PGP MESSAGE-----
diff --git a/tests/suite.hs b/tests/suite.hs
index 45a2fb2..a843664 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 (armor, decode) 6import Codec.Encryption.OpenPGP.ASCIIArmor (encode, decode)
7import Codec.Encryption.OpenPGP.ASCIIArmor.Types 7import Codec.Encryption.OpenPGP.ASCIIArmor.Types
8 8
9import Data.ByteString (ByteString) 9import Data.ByteString (ByteString)
@@ -25,11 +25,11 @@ testArmorDecode fp targets = do
25 where 25 where
26 getPayload (Armor _ _ pl) = pl 26 getPayload (Armor _ _ pl) = pl
27 27
28testArmorEncode :: FilePath -> FilePath -> Assertion 28testArmorEncode :: [FilePath] -> FilePath -> Assertion
29testArmorEncode fp target = do 29testArmorEncode fps target = do
30 bs <- B.readFile $ "tests/data/" ++ fp 30 bss <- mapM (\fp -> B.readFile $ "tests/data/" ++ fp) fps
31 tbs <- B.readFile $ "tests/data/" ++ target 31 tbs <- B.readFile $ "tests/data/" ++ target
32 assertEqual ("literaldata") (armor (Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs)) tbs 32 assertEqual ("literaldata") (encode (map (\bs -> Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs) bss)) tbs
33 33
34tests = [ 34tests = [
35 testGroup "CRC24" [ 35 testGroup "CRC24" [
@@ -41,7 +41,8 @@ tests = [
41 testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"]) 41 testCase "Decode sample armor" (testArmorDecode "msg1.asc" ["msg1.gpg"])
42 , testCase "Decode sample armor with cruft" (testArmorDecode "msg1a.asc" ["msg1.gpg"]) 42 , 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"]) 43 , testCase "Decode multiple sample armors" (testArmorDecode "msg1b.asc" ["msg1.gpg","msg1.gpg","msg1.gpg"])
44 , testCase "Encode sample armor" (testArmorEncode "msg1.gpg" "msg1.asc") 44 , testCase "Encode sample armor" (testArmorEncode ["msg1.gpg"] "msg1.asc")
45 , testCase "Encode multiple sample armors" (testArmorEncode ["msg1.gpg","msg1.gpg","msg1.gpg"] "msg1c.asc")
45 ] 46 ]
46 ] 47 ]
47 48