]> git.immae.eu Git - github/fretlink/hmacaroons.git/commitdiff
Extract sanity check
authorJulien Tanguy <julien.tanguy@jhome.fr>
Wed, 15 Apr 2015 09:27:54 +0000 (11:27 +0200)
committerJulien Tanguy <julien.tanguy@jhome.fr>
Wed, 15 Apr 2015 09:27:54 +0000 (11:27 +0200)
hmacaroons.cabal
test/Sanity.hs [moved from test/tests.hs with 69% similarity]
test/main.hs [new file with mode: 0644]

index 9733a1815a77c1ee519e418e44bc60ef5da5321f..92d435d3ea8ae8b7a2308430eec27ed12fe71b17 100644 (file)
@@ -53,7 +53,7 @@ test-suite test
   default-language: Haskell2010
   type: exitcode-stdio-1.0
   hs-source-dirs: test
-  main-is: tests.hs
+  main-is: main.hs
   build-depends:  base >= 4 && <5,
                   attoparsec >=0.12,
                   bytestring >=0.10,
similarity index 69%
rename from test/tests.hs
rename to test/Sanity.hs
index 85564f08ee8e988a8ffd7623c646acb04665c495..8def3ca193f59c8dc33bf0e8c3635edfa218b1d2 100644 (file)
@@ -1,4 +1,5 @@
 {-#LANGUAGE OverloadedStrings#-}
+module Sanity where
 
 import           Crypto.Hash
 import Data.ByteString (ByteString)
@@ -12,16 +13,8 @@ import Test.Tasty.HUnit
 import qualified Crypto.Macaroon.Tests
 import qualified Crypto.Macaroon.Serializer.Base64.Tests
 
-main = defaultMain tests
-
 tests :: TestTree
-tests = testGroup "Tests" [ sanityCheck
-                          , Crypto.Macaroon.Tests.tests
-                          , Crypto.Macaroon.Serializer.Base64.Tests.tests
-                          ]
-
-sanityCheck :: TestTree
-sanityCheck = testGroup "Python HMAC Sanity check" [ checkKey
+tests = testGroup "Python HMAC Sanity check" [ checkKey
     , checkMac1
     , checkMac2
     , checkMac3
@@ -39,16 +32,16 @@ key :: ByteString
 key = B.take 32 secret
 
 mac1 :: ByteString
-mac1 = toBytes (hmac key public :: HMAC SHA256)
+mac1 = toBytes (hmac key public :: HMAC SHA256)
 
 mac2 :: ByteString
-mac2 = toBytes (hmac mac1 "account = 3735928559" :: HMAC SHA256)
+mac2 = toBytes (hmac mac1 "account = 3735928559" :: HMAC SHA256)
 
 mac3 :: ByteString
-mac3 = toBytes (hmac mac2 "time < 2015-01-01T00:00" :: HMAC SHA256)
+mac3 = toBytes (hmac mac2 "time < 2015-01-01T00:00" :: HMAC SHA256)
 
 mac4 :: ByteString
-mac4 = toBytes (hmac mac3 "email = alice@example.org" :: HMAC SHA256)
+mac4 = toBytes (hmac mac3 "email = alice@example.org" :: HMAC SHA256)
 
 
 checkKey = testCase "Truncated key" $ 
diff --git a/test/main.hs b/test/main.hs
new file mode 100644 (file)
index 0000000..48519b9
--- /dev/null
@@ -0,0 +1,17 @@
+module Main where
+
+import Test.Tasty
+import Test.Tasty.HUnit
+
+import qualified Sanity
+import qualified Crypto.Macaroon.Tests
+import qualified Crypto.Macaroon.Serializer.Base64.Tests
+
+main = defaultMain tests
+
+tests :: TestTree
+tests = testGroup "Tests" [ Sanity.tests
+                          , Crypto.Macaroon.Tests.tests
+                          , Crypto.Macaroon.Serializer.Base64.Tests.tests
+                          ]
+