aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJulien Tanguy <julien.tanguy@jhome.fr>2015-04-15 11:27:54 +0200
committerJulien Tanguy <julien.tanguy@jhome.fr>2015-04-15 11:27:54 +0200
commit46af385cc6f7c7e378ef7866a3da4ad9fb6e941c (patch)
tree1e78ef559d84875cb377ae2ff148d13cf35f0f1a
parentb1f77d7e6dcf03dd20c36e1a10429e1b2b9900b1 (diff)
downloadhmacaroons-46af385cc6f7c7e378ef7866a3da4ad9fb6e941c.tar.gz
hmacaroons-46af385cc6f7c7e378ef7866a3da4ad9fb6e941c.tar.zst
hmacaroons-46af385cc6f7c7e378ef7866a3da4ad9fb6e941c.zip
Extract sanity check
-rw-r--r--hmacaroons.cabal2
-rw-r--r--test/Sanity.hs (renamed from test/tests.hs)19
-rw-r--r--test/main.hs17
3 files changed, 24 insertions, 14 deletions
diff --git a/hmacaroons.cabal b/hmacaroons.cabal
index 9733a18..92d435d 100644
--- a/hmacaroons.cabal
+++ b/hmacaroons.cabal
@@ -53,7 +53,7 @@ test-suite test
53 default-language: Haskell2010 53 default-language: Haskell2010
54 type: exitcode-stdio-1.0 54 type: exitcode-stdio-1.0
55 hs-source-dirs: test 55 hs-source-dirs: test
56 main-is: tests.hs 56 main-is: main.hs
57 build-depends: base >= 4 && <5, 57 build-depends: base >= 4 && <5,
58 attoparsec >=0.12, 58 attoparsec >=0.12,
59 bytestring >=0.10, 59 bytestring >=0.10,
diff --git a/test/tests.hs b/test/Sanity.hs
index 85564f0..8def3ca 100644
--- a/test/tests.hs
+++ b/test/Sanity.hs
@@ -1,4 +1,5 @@
1{-#LANGUAGE OverloadedStrings#-} 1{-#LANGUAGE OverloadedStrings#-}
2module Sanity where
2 3
3import Crypto.Hash 4import Crypto.Hash
4import Data.ByteString (ByteString) 5import Data.ByteString (ByteString)
@@ -12,16 +13,8 @@ import Test.Tasty.HUnit
12import qualified Crypto.Macaroon.Tests 13import qualified Crypto.Macaroon.Tests
13import qualified Crypto.Macaroon.Serializer.Base64.Tests 14import qualified Crypto.Macaroon.Serializer.Base64.Tests
14 15
15main = defaultMain tests
16
17tests :: TestTree 16tests :: TestTree
18tests = testGroup "Tests" [ sanityCheck 17tests = testGroup "Python HMAC Sanity check" [ checkKey
19 , Crypto.Macaroon.Tests.tests
20 , Crypto.Macaroon.Serializer.Base64.Tests.tests
21 ]
22
23sanityCheck :: TestTree
24sanityCheck = testGroup "Python HMAC Sanity check" [ checkKey
25 , checkMac1 18 , checkMac1
26 , checkMac2 19 , checkMac2
27 , checkMac3 20 , checkMac3
@@ -39,16 +32,16 @@ key :: ByteString
39key = B.take 32 secret 32key = B.take 32 secret
40 33
41mac1 :: ByteString 34mac1 :: ByteString
42mac1 = toBytes $ (hmac key public :: HMAC SHA256) 35mac1 = toBytes (hmac key public :: HMAC SHA256)
43 36
44mac2 :: ByteString 37mac2 :: ByteString
45mac2 = toBytes $ (hmac mac1 "account = 3735928559" :: HMAC SHA256) 38mac2 = toBytes (hmac mac1 "account = 3735928559" :: HMAC SHA256)
46 39
47mac3 :: ByteString 40mac3 :: ByteString
48mac3 = toBytes $ (hmac mac2 "time < 2015-01-01T00:00" :: HMAC SHA256) 41mac3 = toBytes (hmac mac2 "time < 2015-01-01T00:00" :: HMAC SHA256)
49 42
50mac4 :: ByteString 43mac4 :: ByteString
51mac4 = toBytes $ (hmac mac3 "email = alice@example.org" :: HMAC SHA256) 44mac4 = toBytes (hmac mac3 "email = alice@example.org" :: HMAC SHA256)
52 45
53 46
54checkKey = testCase "Truncated key" $ 47checkKey = testCase "Truncated key" $
diff --git a/test/main.hs b/test/main.hs
new file mode 100644
index 0000000..48519b9
--- /dev/null
+++ b/test/main.hs
@@ -0,0 +1,17 @@
1module Main where
2
3import Test.Tasty
4import Test.Tasty.HUnit
5
6import qualified Sanity
7import qualified Crypto.Macaroon.Tests
8import qualified Crypto.Macaroon.Serializer.Base64.Tests
9
10main = defaultMain tests
11
12tests :: TestTree
13tests = testGroup "Tests" [ Sanity.tests
14 , Crypto.Macaroon.Tests.tests
15 , Crypto.Macaroon.Serializer.Base64.Tests.tests
16 ]
17