Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed Aug 8, 2023
1 parent 7e4bd57 commit 6653a99
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sel/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import LibSodium.Bindings.Main (sodiumInit)
import qualified Test.Hashing as Hashing
import qualified Test.Hashing.Password as Password
import qualified Test.Hashing.SHA2 as SHA2
import qualified Test.Hashing.Short as Short
import qualified Test.PublicKey.Cipher as PublicKey.Cipher
import qualified Test.PublicKey.Seal as PublicKey.Seal
import qualified Test.PublicKey.Signature as PublicKey.Signature
Expand All @@ -20,6 +21,7 @@ specs :: [TestTree]
specs =
[ Hashing.spec
, Password.spec
, Short.spec
, PublicKey.Signature.spec
, PublicKey.Cipher.spec
, PublicKey.Seal.spec
Expand Down
26 changes: 26 additions & 0 deletions sel/test/Test/Hashing/Short.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE OverloadedStrings #-}

module Test.Hashing.Short where

import Data.Maybe (fromJust)
import Data.Text (Text)
import qualified Sel.Hashing.Short as Short
import Test.Tasty
import Test.Tasty.HUnit

spec :: TestTree
spec =
testGroup
"Password hashing tests"
[ testCase "Hash a short string with a known salt" testHashPassword
]

testHashPassword :: Assertion
testHashPassword = do
let key = fromJust $ Short.hexTextToShortHashKey "9301a3c5eedf2d783b72dc41fb907964"
let input = "kwak kwak" :: Text
hash <- Short.hashText key input
assertEqual
"input hashing is consistent"
(Short.shortHashToHexText hash)
"d50bb18bee915f21a30e6ea555c34546"

0 comments on commit 6653a99

Please sign in to comment.