diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Sanity.hs (renamed from test/tests.hs) | 19 | ||||
-rw-r--r-- | test/main.hs | 17 |
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#-} |
2 | module Sanity where | ||
2 | 3 | ||
3 | import Crypto.Hash | 4 | import Crypto.Hash |
4 | import Data.ByteString (ByteString) | 5 | import Data.ByteString (ByteString) |
@@ -12,16 +13,8 @@ import Test.Tasty.HUnit | |||
12 | import qualified Crypto.Macaroon.Tests | 13 | import qualified Crypto.Macaroon.Tests |
13 | import qualified Crypto.Macaroon.Serializer.Base64.Tests | 14 | import qualified Crypto.Macaroon.Serializer.Base64.Tests |
14 | 15 | ||
15 | main = defaultMain tests | ||
16 | |||
17 | tests :: TestTree | 16 | tests :: TestTree |
18 | tests = testGroup "Tests" [ sanityCheck | 17 | tests = testGroup "Python HMAC Sanity check" [ checkKey |
19 | , Crypto.Macaroon.Tests.tests | ||
20 | , Crypto.Macaroon.Serializer.Base64.Tests.tests | ||
21 | ] | ||
22 | |||
23 | sanityCheck :: TestTree | ||
24 | sanityCheck = testGroup "Python HMAC Sanity check" [ checkKey | ||
25 | , checkMac1 | 18 | , checkMac1 |
26 | , checkMac2 | 19 | , checkMac2 |
27 | , checkMac3 | 20 | , checkMac3 |
@@ -39,16 +32,16 @@ key :: ByteString | |||
39 | key = B.take 32 secret | 32 | key = B.take 32 secret |
40 | 33 | ||
41 | mac1 :: ByteString | 34 | mac1 :: ByteString |
42 | mac1 = toBytes $ (hmac key public :: HMAC SHA256) | 35 | mac1 = toBytes (hmac key public :: HMAC SHA256) |
43 | 36 | ||
44 | mac2 :: ByteString | 37 | mac2 :: ByteString |
45 | mac2 = toBytes $ (hmac mac1 "account = 3735928559" :: HMAC SHA256) | 38 | mac2 = toBytes (hmac mac1 "account = 3735928559" :: HMAC SHA256) |
46 | 39 | ||
47 | mac3 :: ByteString | 40 | mac3 :: ByteString |
48 | mac3 = toBytes $ (hmac mac2 "time < 2015-01-01T00:00" :: HMAC SHA256) | 41 | mac3 = toBytes (hmac mac2 "time < 2015-01-01T00:00" :: HMAC SHA256) |
49 | 42 | ||
50 | mac4 :: ByteString | 43 | mac4 :: ByteString |
51 | mac4 = toBytes $ (hmac mac3 "email = alice@example.org" :: HMAC SHA256) | 44 | mac4 = toBytes (hmac mac3 "email = alice@example.org" :: HMAC SHA256) |
52 | 45 | ||
53 | 46 | ||
54 | checkKey = testCase "Truncated key" $ | 47 | checkKey = 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 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Test.Tasty | ||
4 | import Test.Tasty.HUnit | ||
5 | |||
6 | import qualified Sanity | ||
7 | import qualified Crypto.Macaroon.Tests | ||
8 | import qualified Crypto.Macaroon.Serializer.Base64.Tests | ||
9 | |||
10 | main = defaultMain tests | ||
11 | |||
12 | tests :: TestTree | ||
13 | tests = testGroup "Tests" [ Sanity.tests | ||
14 | , Crypto.Macaroon.Tests.tests | ||
15 | , Crypto.Macaroon.Serializer.Base64.Tests.tests | ||
16 | ] | ||
17 | |||