X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=test%2FCrypto%2FMacaroon%2FVerifier%2FTests.hs;h=d69ad8dee100d7d3312fa0fcbcdf3e0ebbc027e2;hb=cfeb65a103cb58048328b2ca3ce74351017f70d1;hp=37d0230ec2c55ed37dcb39b301705f02b8132161;hpb=6f3c0dca02c1069115bc2592c439970d2af07cc5;p=github%2Ffretlink%2Fhmacaroons.git diff --git a/test/Crypto/Macaroon/Verifier/Tests.hs b/test/Crypto/Macaroon/Verifier/Tests.hs index 37d0230..d69ad8d 100644 --- a/test/Crypto/Macaroon/Verifier/Tests.hs +++ b/test/Crypto/Macaroon/Verifier/Tests.hs @@ -12,20 +12,20 @@ This test suite is based on the pymacaroons test suite: module Crypto.Macaroon.Verifier.Tests where -import qualified Data.ByteString.Char8 as B8 -import Test.Tasty -import Test.Tasty.HUnit -import Test.Tasty.QuickCheck +import qualified Data.ByteString.Char8 as B8 +import Data.Either +import Data.List +import Test.Tasty +import Test.Tasty.HUnit +import Test.Tasty.QuickCheck import Crypto.Macaroon import Crypto.Macaroon.Verifier -import Crypto.Macaroon.Instances +import Crypto.Macaroon.Instances tests :: TestTree -tests = testGroup "Crypto.Macaroon.Verifier" [ sigs - , exactCavs - ] +tests = testGroup "Crypto.Macaroon.Verifier" [ ] {- - Test fixtures @@ -44,44 +44,8 @@ m2 = addFirstPartyCaveat "test = caveat" m m3 :: Macaroon m3 = addFirstPartyCaveat "value = 42" m2 -exVerifiers = [ verifyExact "test" "caveat" (many' letter_ascii) - , verifyExact "value" 42 decimal - ] -exVerifiers' = [ verifyExact "test" "caveat" (many' letter_ascii) - , verifyExact "value" 43 decimal - ] - {- - Tests -} -sigs = testGroup "Signatures" [ basic - , one - , two - ] - -basic = testGroup "Basic Macaroon" [ none , sigQC ] - -none = testCase "No caveat" $ - Ok @=? verifySig sec m - -sigQC = testProperty "Random" $ - \sm -> verifySig (secret sm) (macaroon sm) == Ok - -one = testCase "Macaroon with one caveat" $ - Ok @=? verifySig sec m2 - -two = testCase "Macaroon with two caveats" $ - Ok @=? verifySig sec m3 - -exactCavs = testGroup "Exact Caveats" [ zero', one', two' , one'', two''] -zero' = testCase "Zero caveat win" $ - Ok @=? verifyCavs exVerifiers m -one' = testCase "One caveat win" $ - Ok @=? verifyCavs exVerifiers m2 -one'' = testCase "Ignoring non-relevant" $ - Ok @=? verifyCavs exVerifiers' m2 -two' = testCase "Two caveat win" $ - Ok @=? verifyCavs exVerifiers m3 -two'' = testCase "Two caveat fail" $ - Failed @=? verifyCavs exVerifiers' m3 +-- TODO