]> Git — Sourcephile - gargantext.git/blob - src-test/Utils/Crypto.hs
[nodeStory] sql upgrade scripts
[gargantext.git] / src-test / Utils / Crypto.hs
1
2 {-|
3 Module : Utils.Crypto
4 Description :
5 Copyright : (c) CNRS, 2017-Present
6 License : AGPL + CECILL v3
7 Maintainer : team@gargantext.org
8 Stability : experimental
9 Portability : POSIX
10
11 -}
12
13 module Utils.Crypto where
14
15 import Data.Text (Text)
16 import Test.Hspec
17
18 import Gargantext.Prelude
19 import Gargantext.Prelude.Crypto.Hash
20 import Gargantext.Prelude.Utils
21
22 -- | Crypto Hash tests
23 test :: IO ()
24 test = hspec $ do
25 describe "Hash String with frontend works" $ do
26 let text = "To hash with backend" :: Text
27 let hashed = "8a69a94d164279af2b7d1443ce08da6184b3d7e815406076e148159c284b53c3" :: Hash
28 -- ^ hash from fronted with text above
29 it "compare" $ do
30 hash text `shouldBe` hashed
31
32 describe "Hash List with backend works" $ do
33 let list = ["a","b"] :: [Text]
34 let hashed = "ab19ec537f09499b26f0f62eed7aefad46ab9f498e06a7328ce8e8ef90da6d86" :: Hash
35 -- ^ hash from frontend with text above
36 it "compare" $ do
37 hash list `shouldBe` hashed
38
39 ------------------------------------------------------------------------
40 -- | TODO property based tests
41 describe "Hash works with any order of list" $ do
42 let hash1 = hash (["a","b"] :: [Text])
43 let hash2 = hash (["b","a"] :: [Text])
44 it "compare" $ do
45 hash1 `shouldBe` hash2
46