summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-04-24 16:49:31 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-04-24 16:49:31 -0500
commit180158e2dfee55bbe3a098f394f0fbbab8c17208 (patch)
tree8e25198dbe1c6201cbf4f0655179fd3393097e75 /tests
parent5167ba7b28b56e91aac9ec36d4dc3d344aa60032 (diff)
test fingerprint generation
Diffstat (limited to 'tests')
-rw-r--r--tests/suite.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/suite.hs b/tests/suite.hs
index cd02bff..59b9c03 100644
--- a/tests/suite.hs
+++ b/tests/suite.hs
@@ -7,6 +7,7 @@ import Test.HUnit hiding (Test)
7import Data.Word 7import Data.Word
8import Data.Binary 8import Data.Binary
9import qualified Data.OpenPGP as OpenPGP 9import qualified Data.OpenPGP as OpenPGP
10import qualified Data.OpenPGP.Crypto as OpenPGP
10import qualified Data.ByteString.Lazy as LZ 11import qualified Data.ByteString.Lazy as LZ
11 12
12testSerialization :: FilePath -> Assertion 13testSerialization :: FilePath -> Assertion
@@ -22,6 +23,12 @@ testSerialization fp = do
22 assertFailure $ pass ++ " pass of " ++ fp ++ " decoded to nothing." 23 assertFailure $ pass ++ " pass of " ++ fp ++ " decoded to nothing."
23 nullShield _ m f = f m 24 nullShield _ m f = f m
24 25
26testFingerprint :: FilePath -> String -> Assertion
27testFingerprint fp kf = do
28 bs <- LZ.readFile $ "tests/data/" ++ fp
29 let (OpenPGP.Message [packet]) = decode bs
30 assertEqual ("for " ++ fp) kf (OpenPGP.fingerprint packet)
31
25prop_s2k_count :: Word8 -> Bool 32prop_s2k_count :: Word8 -> Bool
26prop_s2k_count c = 33prop_s2k_count c =
27 c == OpenPGP.encode_s2k_count (OpenPGP.decode_s2k_count c) 34 c == OpenPGP.encode_s2k_count (OpenPGP.decode_s2k_count c)
@@ -117,6 +124,12 @@ tests =
117 -- Issue #11 -- testCase "uncompressed-ops-dsa.gpg" (testSerialization "uncompressed-ops-dsa.gpg"), 124 -- Issue #11 -- testCase "uncompressed-ops-dsa.gpg" (testSerialization "uncompressed-ops-dsa.gpg"),
118 -- Issue #11 -- testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg"), 125 -- Issue #11 -- testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg"),
119 ], 126 ],
127 testGroup "Fingerprint group" [
128 testCase "000001-006.public_key" (testFingerprint "000001-006.public_key" "421F28FEAAD222F856C8FFD5D4D54EA16F87040E"),
129 testCase "000016-006.public_key" (testFingerprint "000016-006.public_key" "AF95E4D7BAC521EE9740BED75E9F1523413262DC"),
130 testCase "000027-006.public_key" (testFingerprint "000027-006.public_key" "1EB20B2F5A5CC3BEAFD6E5CB7732CF988A63EA86"),
131 testCase "000035-006.public_key" (testFingerprint "000035-006.public_key" "CB7933459F59C70DF1C3FBEEDEDC3ECF689AF56D")
132 ],
120 testGroup "S2K count" [ 133 testGroup "S2K count" [
121 testProperty "S2K count encode reverses decode" prop_s2k_count 134 testProperty "S2K count encode reverses decode" prop_s2k_count
122 ] 135 ]