summaryrefslogtreecommitdiff
path: root/Command/TestRemote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-01 17:52:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-01 17:52:40 -0400
commitd0a8e3d6217f2924b864393d425b6d7582370d07 (patch)
treec74ab7f1e9bbf85a6f78c1290b867ecb56d42141 /Command/TestRemote.hs
parent7effa83470019f75931296c6a5d07a5932c69df8 (diff)
testremote now tests with and without encryption
Diffstat (limited to 'Command/TestRemote.hs')
-rw-r--r--Command/TestRemote.hs33
1 files changed, 23 insertions, 10 deletions
diff --git a/Command/TestRemote.hs b/Command/TestRemote.hs
index 186d067d6..29a2e809c 100644
--- a/Command/TestRemote.hs
+++ b/Command/TestRemote.hs
@@ -61,7 +61,8 @@ start basesz ws = do
showSideAction "generating test keys"
ks <- mapM randKey (keySizes basesz)
rs <- catMaybes <$> mapM (adjustChunkSize r) (chunkSizes basesz)
- next $ perform rs ks
+ rs' <- concat <$> mapM encryptionVariants rs
+ next $ perform rs' ks
perform :: [Remote] -> [Key] -> CommandPerform
perform rs ks = do
@@ -73,20 +74,32 @@ perform rs ks = do
Just act -> liftIO act
next $ cleanup rs ks ok
where
- desc r' k = unwords
- [ "key size"
- , show (keySize k)
- , "chunk size"
- , show (chunkConfig (Remote.config r'))
+ desc r' k = intercalate "; " $ map unwords
+ [ [ "key size", show (keySize k) ]
+ , [ show (chunkConfig (Remote.config r')) ]
+ , ["encryption", fromMaybe "none" (M.lookup "encryption" (Remote.config r'))]
]
--- To adjust a Remote to use a new chunk size, have to re-generate it with
--- a modified config.
adjustChunkSize :: Remote -> Int -> Annex (Maybe Remote)
-adjustChunkSize r chunksize = Remote.generate (Remote.remotetype r)
+adjustChunkSize r chunksize = adjustRemoteConfig r
+ (M.insert "chunk" (show chunksize))
+
+-- Variants of a remote with no encryption, and with simple shared
+-- encryption. Gpg key based encryption is not tested.
+encryptionVariants :: Remote -> Annex [Remote]
+encryptionVariants r = do
+ noenc <- adjustRemoteConfig r (M.insert "encryption" "none")
+ sharedenc <- adjustRemoteConfig r $
+ M.insert "encryption" "shared" .
+ M.insert "highRandomQuality" "false"
+ return $ catMaybes [noenc, sharedenc]
+
+-- Regenerate a remote with a modified config.
+adjustRemoteConfig :: Remote -> (Remote.RemoteConfig -> Remote.RemoteConfig) -> Annex (Maybe Remote)
+adjustRemoteConfig r adjustconfig = Remote.generate (Remote.remotetype r)
(Remote.repo r)
(Remote.uuid r)
- (M.insert "chunk" (show chunksize) (Remote.config r))
+ (adjustconfig (Remote.config r))
(Remote.gitconfig r)
test :: Annex.AnnexState -> Remote -> Key -> [TestTree]