From 46af385cc6f7c7e378ef7866a3da4ad9fb6e941c Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Wed, 15 Apr 2015 11:27:54 +0200 Subject: [PATCH] Extract sanity check --- hmacaroons.cabal | 2 +- test/{tests.hs => Sanity.hs} | 19 ++++++------------- test/main.hs | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 14 deletions(-) rename test/{tests.hs => Sanity.hs} (69%) create mode 100644 test/main.hs 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 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, diff --git a/test/tests.hs b/test/Sanity.hs similarity index 69% rename from test/tests.hs rename to test/Sanity.hs index 85564f0..8def3ca 100644 --- a/test/tests.hs +++ b/test/Sanity.hs @@ -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 index 0000000..48519b9 --- /dev/null +++ b/test/main.hs @@ -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 + ] + -- 2.41.0