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
18 import Test.Tasty.QuickCheck
20 import Crypto.Macaroon
21 import Crypto.Macaroon.Verifier
23 import Crypto.Macaroon.Instances
26 tests = testGroup "Crypto.Macaroon.Verifier" [ sigs
32 sec = B8.pack "this is our super secret key; only we should know it"
35 m = create sec key loc
37 key = B8.pack "we used our sec key"
38 loc = B8.pack "http://mybank/"
41 m2 = addFirstPartyCaveat "test = caveat" m
44 m3 = addFirstPartyCaveat "test = acaveat" m
49 sigs = testGroup "Signatures" [ basic
54 basic = testGroup "Basic Macaroon" [ none , sigQC ]
56 none = testCase "No caveat" $
57 VSuccess @=? verifySig sec m
59 sigQC = testProperty "Random" $
60 \sm -> verifySig (secret sm) (macaroon sm) == VSuccess
62 one = testCase "Macaroon with one caveat" $
63 VSuccess @=? verifySig sec m2
65 two = testCase "Macaroon with two caveats" $
66 VSuccess @=? verifySig sec m3