passman-core 0.2.0.0 → 0.2.0.1
raw patch · 5 files changed
+55/−51 lines, 5 filesdep +quickcheck-instancesdep −conduit-extradep −resourcetdep ~QuickCheckdep ~conduitPVP ok
version bump matches the API change (PVP)
Dependencies added: quickcheck-instances
Dependencies removed: conduit-extra, resourcet
Dependency ranges changed: QuickCheck, conduit
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−0
- passman-core.cabal +21/−19
- src/Passman/Core/Entry.hs +14/−16
- test/precomputed.hs +1/−2
- test/properties.hs +14/−14
ChangeLog.md view
@@ -1,3 +1,8 @@+## 0.2.0.1++* Switch to conduit 1.3+* Allow testing with QuickCheck 2.10, 2.11 and 2.12+ ## 0.2.0.0 * Export version number in Passman.Core.Version
passman-core.cabal view
@@ -1,5 +1,5 @@ name: passman-core-version: 0.2.0.0+version: 0.2.0.1 synopsis: Deterministic password generator core description: Generates unique passwords deterministically from a single master password.@@ -18,8 +18,11 @@ build-type: Simple extra-source-files: README.md , ChangeLog.md-cabal-version: >=2.0-tested-with: GHC >= 8.0.1 && <= 8.2.2+cabal-version: 2.0+tested-with: GHC == 8.0.2+ , GHC == 8.2.2+ , GHC == 8.4.3+ , GHC == 8.6.1 library hs-source-dirs: src@@ -35,24 +38,22 @@ autogen-modules: Paths_passman_core ghc-options: -Wall build-depends: passman-core-internal- , base >= 4.9 && < 4.11- , aeson >= 0.7 && < 1.3+ , base >= 4.9 && < 4.13+ , aeson >= 0.7 && < 1.5 , bcrypt ^>= 0.0.10 , bytestring ^>= 0.10.8.1- , conduit ^>= 1.2.11- , conduit-extra >= 1.1.5 && < 1.3- , containers ^>= 0.5.7.1+ , conduit ^>= 1.3.0+ , containers >= 0.5.7.1 && < 0.7 , cryptohash-md5 ^>= 0.11.100.1- , csv-conduit ^>= 0.6.7+ , csv-conduit >= 0.6.7 && < 0.8 , data-ordlist ^>= 0.4.7.0- , directory >= 1.2.3 && < 1.4+ , directory >= 1.2.3 && < 1.4 , filepath ^>= 1.4.1.0- , int-cast ^>= 0.1.2.0+ , int-cast >= 0.1.2.0 && < 0.3 , memory ^>= 0.14.6- , resourcet ^>= 1.1.9 , text ^>= 1.2.2.2- , unix-compat >= 0.4.3.1 && < 0.6- , yaml ^>= 0.8.23.3+ , unix-compat >= 0.4.3.1 && < 0.6+ , yaml >= 0.8.23.3 && < 0.11 default-language: Haskell2010 other-extensions: GeneralizedNewtypeDeriving OverloadedStrings@@ -94,11 +95,12 @@ , filepath , text - , async ^>= 2.1.0- , QuickCheck ^>= 2.9.2- , quickcheck-unicode ^>= 1.0.1.0- , template-haskell >= 2.11 && < 2.13- , temporary ^>= 1.2.0.3+ , async >= 2.1.0 && < 2.3+ , QuickCheck >= 2.9.2 && < 2.13+ , quickcheck-instances ^>= 0.3.13+ , quickcheck-unicode ^>= 1.0.1.0+ , template-haskell >= 2.11 && < 2.15+ , temporary >= 1.2.0.3 && < 1.4 default-language: Haskell2010 other-extensions: TemplateHaskell TemplateHaskellQuotes
src/Passman/Core/Entry.hs view
@@ -39,14 +39,12 @@ , entryToCsv ) where -import Control.Monad.Trans.Resource (MonadResource, MonadThrow,- throwM)+import Conduit (MonadResource, MonadThrow, throwM, ConduitT, (.|),+ mapC, mapMC, sourceFile, sinkFile, sinkIOHandle,+ decodeUtf8C, encodeUtf8C)+ import Control.Monad (mfilter) -import Data.Conduit (ConduitM, (.|))-import qualified Data.Conduit.List as C-import Data.Conduit.Binary (sourceFile, sinkFile, sinkIOHandle)-import Data.Conduit.Text (decodeUtf8, encodeUtf8) import Data.CSV.Conduit (intoCSV, fromCSV, defCSVSettings) import Numeric.Natural (Natural)@@ -92,12 +90,12 @@ deriving (Show, Eq) -- | Load `Entry`s from the specified file.-load :: MonadResource m => FilePath -> ConduitM i Entry m ()-load f = sourceFile f .| decodeUtf8 .| textToEntry+load :: (MonadThrow m, MonadResource m) => FilePath -> ConduitT i Entry m ()+load f = sourceFile f .| decodeUtf8C .| textToEntry -- | Convert `Text` into `Entry`s.-textToEntry :: MonadThrow m => ConduitM Text Entry m ()-textToEntry = intoCSV defCSVSettings .| C.mapM csvToEntry+textToEntry :: MonadThrow m => ConduitT Text Entry m ()+textToEntry = intoCSV defCSVSettings .| mapMC csvToEntry -- | Attempt to convert CSV fields into an `Entry`. csvToEntry :: MonadThrow m => [Text] -> m Entry@@ -108,17 +106,17 @@ csvToEntry _ = failM "too many columns" -- | Save `Entry`s to the specified file.-save :: MonadResource m => FilePath -> ConduitM Entry o m ()-save f = entryToText .| encodeUtf8 .| sinkFile f+save :: MonadResource m => FilePath -> ConduitT Entry o m ()+save f = entryToText .| encodeUtf8C .| sinkFile f -- | Append `Entry`s to the specified file.-append :: MonadResource m => FilePath -> ConduitM Entry o m ()-append fp = entryToText .| encodeUtf8 .| sinkIOHandle+append :: MonadResource m => FilePath -> ConduitT Entry o m ()+append fp = entryToText .| encodeUtf8C .| sinkIOHandle (openBinaryFile fp AppendMode) -- | Convert an `Entry` into `Text` for saving to file.-entryToText :: Monad m => ConduitM Entry Text m ()-entryToText = C.map entryToCsv .| fromCSV defCSVSettings+entryToText :: Monad m => ConduitT Entry Text m ()+entryToText = mapC entryToCsv .| fromCSV defCSVSettings -- | Convert an `Entry` into CSV fields. entryToCsv :: Entry -> [Text]
test/precomputed.hs view
@@ -19,8 +19,7 @@ import Data.Functor.Identity (Identity (Identity)) -import Data.Conduit ((.|), yield, sourceToList)-import Data.Conduit.Lift (runCatchC)+import Conduit ((.|), yield, sourceToList, runCatchC) import Data.Maybe (fromJust) import Data.Yaml (decode)
test/properties.hs view
@@ -31,21 +31,21 @@ import Data.Maybe (fromJust, isJust) import qualified Data.Text as T -import Data.Conduit ((.|), sourceToList, runConduitRes)-import Data.Conduit.List (sourceList, consume)-import Data.Conduit.Lift (runCatchC)+import Conduit ((.|), runConduitRes, runResourceT, runCatchC,+ sourceToList, yieldMany) import System.IO.Temp (withSystemTempDirectory) import System.FilePath ((</>)) import System.Exit (exitFailure) -import Test.QuickCheck (Arbitrary (arbitrary, shrink), Gen,- Result, Property, suchThat,- arbitraryBoundedEnum)-import Test.QuickCheck.Monadic (PropertyM, assert, run, monadicIO,- pre)-import Test.QuickCheck.Test (isSuccess, output)-import qualified Test.QuickCheck.Unicode as U+import Test.QuickCheck (Arbitrary (arbitrary, shrink), Gen,+ Result, Property, suchThat,+ arbitraryBoundedEnum)+import Test.QuickCheck.Monadic (PropertyM, assert, run, monadicIO,+ pre)+import Test.QuickCheck.Test (isSuccess, output)+import qualified Test.QuickCheck.Unicode as U+import Test.QuickCheck.Instances () import Passman.Core.Mode (SingletonMode, Mode (Mode), validModes, readMode, characterCode)@@ -126,16 +126,16 @@ prop_showReadEntry :: [Entry] -> Bool prop_showReadEntry xs = xs == xs' where- Identity xs' = sourceToList (sourceList xs .| entryToText .| textToEntry')+ Identity xs' = sourceToList (yieldMany xs .| entryToText .| textToEntry') textToEntry' = runCatchC textToEntry >>= either (fail . show) pure prop_saveAppendLoadEntry :: [Entry] -> [Entry] -> Property prop_saveAppendLoadEntry xs ys = monadicIO $ do zs <- run $ withSystemTempDirectory "passman-testcase" $ \dir -> do let fp = dir </> "list.txt"- runConduitRes $ sourceList xs .| save fp- runConduitRes $ sourceList ys .| append fp- runConduitRes $ load fp .| consume+ runConduitRes $ yieldMany xs .| save fp+ runConduitRes $ yieldMany ys .| append fp+ runResourceT $ sourceToList $ load fp assert $ (xs ++ ys) == zs prop_toFromBase :: Natural -> Natural -> Bool