add hash tests
This commit is contained in:
parent
b9a6664fcf
commit
b05899bc9d
19
test/Spec.hs
19
test/Spec.hs
@ -1,10 +1,11 @@
|
||||
import Test.Hspec
|
||||
import qualified Crypto as Cr
|
||||
import Data.ByteString.UTF8 (fromString)
|
||||
import qualified Utils as Ut
|
||||
|
||||
main :: IO ()
|
||||
main = hspec $ do
|
||||
describe "Crypto" $ do
|
||||
describe "Crypto Encryption & Decryption" $ do
|
||||
it "should encrypt and decrypt a message correctly" $ do
|
||||
let originalMessage = "Hello, World!"
|
||||
masterPassword = "mysecretpassword"
|
||||
@ -12,6 +13,22 @@ main = hspec $ do
|
||||
decryptedMessage = Cr.decrypt' masterPassword encryptedMessage
|
||||
decryptedMessage `shouldBe` originalMessage
|
||||
|
||||
describe "Crypto Hash Identical" $ do
|
||||
it "should hash identical ByteString's to the same output" $ do
|
||||
let input1 = "Hello, World!"
|
||||
input2 = "Hello, World!"
|
||||
hash1 = Cr.hash' $ fromString input1
|
||||
hash2 = Cr.hash' $ fromString input2
|
||||
hash1 `shouldBe` hash2
|
||||
|
||||
describe "Crypto Hash Different" $ do
|
||||
it "should hash different ByteString's to different output" $ do
|
||||
let input1 = "Hello, World!"
|
||||
input2 = "Hello, World"
|
||||
hash1 = Cr.hash' $ fromString input1
|
||||
hash2 = Cr.hash' $ fromString input2
|
||||
hash1 `shouldNotBe` hash2
|
||||
|
||||
describe "Utils Valid password" $ do
|
||||
it "should result in Valid for master password validation with valid input" $ do
|
||||
let password1 = "mysecretpassword"
|
||||
|
Loading…
Reference in New Issue
Block a user