diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-24 16:49:31 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-24 16:49:31 -0500 |
commit | 180158e2dfee55bbe3a098f394f0fbbab8c17208 (patch) | |
tree | 8e25198dbe1c6201cbf4f0655179fd3393097e75 | |
parent | 5167ba7b28b56e91aac9ec36d4dc3d344aa60032 (diff) |
test fingerprint generation
-rw-r--r-- | tests/suite.hs | 13 |
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) | |||
7 | import Data.Word | 7 | import Data.Word |
8 | import Data.Binary | 8 | import Data.Binary |
9 | import qualified Data.OpenPGP as OpenPGP | 9 | import qualified Data.OpenPGP as OpenPGP |
10 | import qualified Data.OpenPGP.Crypto as OpenPGP | ||
10 | import qualified Data.ByteString.Lazy as LZ | 11 | import qualified Data.ByteString.Lazy as LZ |
11 | 12 | ||
12 | testSerialization :: FilePath -> Assertion | 13 | testSerialization :: 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 | ||
26 | testFingerprint :: FilePath -> String -> Assertion | ||
27 | testFingerprint 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 | |||
25 | prop_s2k_count :: Word8 -> Bool | 32 | prop_s2k_count :: Word8 -> Bool |
26 | prop_s2k_count c = | 33 | prop_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 | ] |