From 970adc221cda06c53cf8b8df98e8c8bfc20c5326 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 18 Dec 2018 14:41:29 -0500 Subject: [PATCH] implemented newPWDatabase --- src/Password.hs | 6 +++++- test/Spec.hs | 4 +++- test/Spec/NewPWDatabase.hs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/Spec/NewPWDatabase.hs diff --git a/src/Password.hs b/src/Password.hs index d7e072e..2781c7b 100644 --- a/src/Password.hs +++ b/src/Password.hs @@ -34,7 +34,7 @@ module Password ( -- *** PWPolicy pwLength, pwUpper, pwLower, pwDigits, pwSpecial, -- ** Default Instances - newPWData, newPWPolicy, newPWSalt, + newPWDatabase, newPWData, newPWPolicy, newPWSalt, -- * Functions validatePWPolicy ) where @@ -83,6 +83,10 @@ type PWSalt = B.ByteString makeLenses ''PWPolicy makeLenses ''PWData +-- | default (empty) password database +newPWDatabase :: PWDatabase +newPWDatabase = M.empty + -- | builds a new @'PWData'@ newPWData :: RandomGen g diff --git a/test/Spec.hs b/test/Spec.hs index 91ecbbc..a6d8b78 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -27,6 +27,7 @@ import System.Exit (exitFailure) import Test.HUnit (errors, failures, runTestTT, Test(TestList)) import qualified Spec.NewPWData as NewPWData +import qualified Spec.NewPWDatabase as NewPWDatabase import qualified Spec.NewPWPolicy as NewPWPolicy import qualified Spec.NewPWSalt as NewPWSalt import qualified Spec.ValidatePWPolicy as ValidatePWPolicy @@ -37,7 +38,8 @@ main = do exitFailure tests = TestList - [ NewPWData.tests + [ NewPWDatabase.tests + , NewPWData.tests , NewPWPolicy.tests , NewPWSalt.tests , ValidatePWPolicy.tests diff --git a/test/Spec/NewPWDatabase.hs b/test/Spec/NewPWDatabase.hs new file mode 100644 index 0000000..2b13a77 --- /dev/null +++ b/test/Spec/NewPWDatabase.hs @@ -0,0 +1,32 @@ +{- + +passman +Copyright (C) 2018 Jonathan Lamothe + + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this program. If not, see +. + +-} + +module Spec.NewPWDatabase (tests) where + +import Test.HUnit (Test (..), (~?=)) + +import Password + +tests = TestLabel "newPWDatabase" $ + length newPWDatabase ~?= 0 + +--jl