aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Sanity.hs (renamed from test/tests.hs)19
-rw-r--r--test/main.hs17
2 files changed, 23 insertions, 13 deletions
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