1 {-# LANGUAGE OverloadedStrings #-}
3 Copyright : (c) 2015 Julien Tanguy
6 Maintainer : julien.tanguy@jhome.fr
9 This test suite is based on the pymacaroons test suite:
10 <https://github.com/ecordell/pymacaroons>
12 module Crypto.Macaroon.Verifier.Tests where
16 import qualified Data.ByteString.Char8 as B8
18 -- import Test.Tasty.HUnit
19 import Test.Tasty.QuickCheck hiding (Success, Failure)
22 import Crypto.Macaroon
23 import Crypto.Macaroon.Verifier
25 import Crypto.Macaroon.Instances
28 tests = testGroup "Crypto.Macaroon.Verifier" [ sigs
34 sec = B8.pack "this is our super secret key; only we should know it"
37 m = create sec key loc
39 key = B8.pack "we used our sec key"
40 loc = B8.pack "http://mybank/"
43 m2 = addFirstPartyCaveat "test = caveat" m
46 m3 = addFirstPartyCaveat "value = 42" m2
48 -- exTC = verifyExact "test" "caveat" (many' letter_ascii)
49 -- exTZ = verifyExact "test" "bleh" (many' letter_ascii)
50 -- exV42 = verifyExact "value" 42 decimal
51 -- exV43 = verifyExact "value" 43 decimal
53 -- funTCPre = verifyFun "test" (string "test = " *> many' letter_ascii)
54 -- (\e -> if "cav" `isPrefixOf` e then Right e else Left "Does not start with cav" )
55 -- funTV43lte = verifyFun "value" (string "value = " *> decimal)
56 -- (\v -> if v <= 43 then Right v else Left "Greater than 43")
58 -- allvs = [exTC, exTZ, exV42, exV43, funTCPre, funTV43lte]
63 sigs = testProperty "Signatures" $ \sm -> verifySig (secret sm) (macaroon sm) == Right (macaroon sm)