summaryrefslogtreecommitdiff
path: root/Test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-09-04 22:18:33 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-09-04 22:18:33 -0400
commit4c96f460a7ad615f344d1b2e88d037d7a0259776 (patch)
tree1c24b37d33946d6d5079156271c8ef8b5a3eb712 /Test.hs
parent17a5f70ed26b14a15a50d237f47eb68eb9c2753d (diff)
replace an over-explained Bool with a data type
This also highlights several places where a Read/Show or similar for the new data type could avoid redundant strings.
Diffstat (limited to 'Test.hs')
-rw-r--r--Test.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/Test.hs b/Test.hs
index d9d1f066b..7ac87af5b 100644
--- a/Test.hs
+++ b/Test.hs
@@ -920,26 +920,26 @@ test_crypto env = "git-annex crypto" ~: TestList $ flip map ["shared","hybrid","
- that all keys are encrypted properly on the given directory remote. -}
testEncryptedRemote scheme ks c keys = case Remote.Helper.Encryptable.extractCipher c of
Just cip@Crypto.SharedCipher{} | scheme == "shared" && isNothing ks ->
- checkKeys cip True
- Just cip@(Crypto.EncryptedCipher encipher sym ks')
- | checkScheme sym && keysMatch ks' ->
- checkKeys cip sym <&&> checkCipher encipher ks'
+ checkKeys cip Nothing
+ Just cip@(Crypto.EncryptedCipher encipher v ks')
+ | checkScheme v && keysMatch ks' ->
+ checkKeys cip (Just v) <&&> checkCipher encipher ks'
_ -> return False
where
keysMatch (Utility.Gpg.KeyIds ks') =
maybe False (\(Utility.Gpg.KeyIds ks2) ->
sort (nub ks2) == sort (nub ks')) ks
checkCipher encipher = Utility.Gpg.checkEncryptionStream encipher . Just
- checkScheme True = scheme == "hybrid"
- checkScheme False = scheme == "pubkey"
- checkKeys cip sym = do
+ checkScheme Types.Crypto.HybridCipher = scheme == "hybrid"
+ checkScheme Types.Crypto.PubKeyCipher = scheme == "pubkey"
+ checkKeys cip mvariant = do
cipher <- Crypto.decryptCipher cip
files <- filterM doesFileExist $
map ("dir" </>) $ concatMap (key2files cipher) keys
- return (not $ null files) <&&> allM (checkFile sym) files
- checkFile sym filename =
+ return (not $ null files) <&&> allM (checkFile mvariant) files
+ checkFile mvariant filename =
Utility.Gpg.checkEncryptionFile filename $
- if sym then Nothing else ks
+ if mvariant == Just Types.Crypto.PubKeyCipher then ks else Nothing
key2files cipher = Locations.keyPaths .
Crypto.encryptKey Types.Crypto.HmacSha1 cipher
#else