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
15 import qualified Data.ByteString.Char8 as B8
17 import Test.Tasty.HUnit
19 import Crypto.Macaroon
20 import Crypto.Macaroon.Verifier
22 import Crypto.Macaroon.Instances
25 tests = testGroup "Crypto.Macaroon.Verifier" [ sigs
28 sec = B8.pack "this is our super secret key; only we should know it"
31 m = create sec key loc
33 key = B8.pack "we used our sec key"
34 loc = B8.pack "http://mybank/"
37 m2 = addFirstPartyCaveat "test = caveat" m
40 m3 = addFirstPartyCaveat "test = acaveat" m
42 sigs = testGroup "Signatures" [ basic
46 basic = testCase "Basic Macaroon Signature" $
47 Success @=? verifySig sec m
51 minted = testGroup "Macaroon with first party caveats" [ one
54 one = testCase "One caveat" $
55 Success @=? verifySig sec m2
57 two = testCase "Two caveats" $
58 Success @=? verifySig sec m3