aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/Crypto/Macaroon
diff options
context:
space:
mode:
Diffstat (limited to 'test/Crypto/Macaroon')
-rw-r--r--test/Crypto/Macaroon/Verifier/Tests.hs30
1 files changed, 18 insertions, 12 deletions
diff --git a/test/Crypto/Macaroon/Verifier/Tests.hs b/test/Crypto/Macaroon/Verifier/Tests.hs
index 37d0230..54c8db1 100644
--- a/test/Crypto/Macaroon/Verifier/Tests.hs
+++ b/test/Crypto/Macaroon/Verifier/Tests.hs
@@ -12,6 +12,7 @@ This test suite is based on the pymacaroons test suite:
12module Crypto.Macaroon.Verifier.Tests where 12module Crypto.Macaroon.Verifier.Tests where
13 13
14 14
15import Data.List
15import qualified Data.ByteString.Char8 as B8 16import qualified Data.ByteString.Char8 as B8
16import Test.Tasty 17import Test.Tasty
17import Test.Tasty.HUnit 18import Test.Tasty.HUnit
@@ -50,6 +51,9 @@ exVerifiers = [ verifyExact "test" "caveat" (many' letter_ascii)
50exVerifiers' = [ verifyExact "test" "caveat" (many' letter_ascii) 51exVerifiers' = [ verifyExact "test" "caveat" (many' letter_ascii)
51 , verifyExact "value" 43 decimal 52 , verifyExact "value" 43 decimal
52 ] 53 ]
54funVerifiers = [ verifyFun "test" ("cav" `isPrefixOf`) (many' letter_ascii)
55 , verifyFun "value" (<= 43) decimal
56 ]
53 57
54{- 58{-
55 - Tests 59 - Tests
@@ -73,15 +77,17 @@ one = testCase "Macaroon with one caveat" $
73two = testCase "Macaroon with two caveats" $ 77two = testCase "Macaroon with two caveats" $
74 Ok @=? verifySig sec m3 78 Ok @=? verifySig sec m3
75 79
76exactCavs = testGroup "Exact Caveats" [ zero', one', two' , one'', two''] 80exactCavs = testGroup "Exact Caveats" [
77 81 testGroup "Ignoring non-relevant" [
78zero' = testCase "Zero caveat win" $ 82 testCase "Zero caveat" $ Ok @=? verifyCavs exVerifiers m
79 Ok @=? verifyCavs exVerifiers m 83 , testCase "One caveat" $ Ok @=? verifyCavs exVerifiers' m2
80one' = testCase "One caveat win" $ 84 ]
81 Ok @=? verifyCavs exVerifiers m2 85 , testCase "One caveat win" $ Ok @=? verifyCavs exVerifiers m2
82one'' = testCase "Ignoring non-relevant" $ 86 , testCase "Two caveat win" $ Ok @=? verifyCavs exVerifiers m3
83 Ok @=? verifyCavs exVerifiers' m2 87 , testCase "Two caveat fail" $ Failed @=? verifyCavs exVerifiers' m3
84two' = testCase "Two caveat win" $ 88 ]
85 Ok @=? verifyCavs exVerifiers m3 89
86two'' = testCase "Two caveat fail" $ 90funCavs = testGroup "Function Caveats" [
87 Failed @=? verifyCavs exVerifiers' m3 91 testCase "One caveat win" $ Ok @=? verifyCavs funVerifiers m2
92 , testCase "Two caveat win" $ Ok @=? verifyCavs funVerifiers m3
93 ]