Add Utils tests
This commit is contained in:
parent
c38b22a818
commit
b9a6664fcf
@ -8,7 +8,7 @@ import qualified Data.Text as T
|
|||||||
|
|
||||||
import qualified Database as Db
|
import qualified Database as Db
|
||||||
|
|
||||||
data MasterPasswordValidationCases = Empty | TooShort | DoNotMatch | NotValid | Valid String deriving (Show)
|
data MasterPasswordValidationCases = Empty | TooShort | DoNotMatch | Valid String deriving (Eq, Show)
|
||||||
|
|
||||||
data ActionChoice = ListAllEntries | CopyEntryPassword | AddNewEntry | DeleteEntry | UpdateEntry | ChangeMasterPassword | Exit | InvalidAction deriving (Show)
|
data ActionChoice = ListAllEntries | CopyEntryPassword | AddNewEntry | DeleteEntry | UpdateEntry | ChangeMasterPassword | Exit | InvalidAction deriving (Show)
|
||||||
|
|
||||||
|
29
test/Spec.hs
29
test/Spec.hs
@ -1,5 +1,6 @@
|
|||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import qualified Crypto as Cr
|
import qualified Crypto as Cr
|
||||||
|
import qualified Utils as Ut
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = hspec $ do
|
main = hspec $ do
|
||||||
@ -10,3 +11,31 @@ main = hspec $ do
|
|||||||
encryptedMessage = Cr.encrypt' masterPassword originalMessage
|
encryptedMessage = Cr.encrypt' masterPassword originalMessage
|
||||||
decryptedMessage = Cr.decrypt' masterPassword encryptedMessage
|
decryptedMessage = Cr.decrypt' masterPassword encryptedMessage
|
||||||
decryptedMessage `shouldBe` originalMessage
|
decryptedMessage `shouldBe` originalMessage
|
||||||
|
|
||||||
|
describe "Utils Valid password" $ do
|
||||||
|
it "should result in Valid for master password validation with valid input" $ do
|
||||||
|
let password1 = "mysecretpassword"
|
||||||
|
password2 = "mysecretpassword"
|
||||||
|
result = Ut.validate_password password1 password2
|
||||||
|
result `shouldBe` Ut.Valid password1
|
||||||
|
|
||||||
|
describe "Utils DoNotMatch password" $ do
|
||||||
|
it "should result in DoNotMatch for master password validation with non-matching input" $ do
|
||||||
|
let password1 = "mysecretpassword"
|
||||||
|
password2 = "nonmatchingpassword"
|
||||||
|
result = Ut.validate_password password1 password2
|
||||||
|
result `shouldBe` Ut.DoNotMatch
|
||||||
|
|
||||||
|
describe "Utils Empty password" $ do
|
||||||
|
it "should result in Empty for master password validation with empty input" $ do
|
||||||
|
let password1 = ""
|
||||||
|
password2 = ""
|
||||||
|
result = Ut.validate_password password1 password2
|
||||||
|
result `shouldBe` Ut.Empty
|
||||||
|
|
||||||
|
describe "Utils TooShort password" $ do
|
||||||
|
it "should result in TooShort for master password validation with too short input" $ do
|
||||||
|
let password1 = "short"
|
||||||
|
password2 = "short"
|
||||||
|
result = Ut.validate_password password1 password2
|
||||||
|
result `shouldBe` Ut.TooShort
|
||||||
|
Loading…
Reference in New Issue
Block a user