diff options
author | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-08-17 17:38:24 +0200 |
---|---|---|
committer | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-08-17 17:39:31 +0200 |
commit | 86f3882318d323d1920ca1c7da6e816f0ed376da (patch) | |
tree | 0e16232125c2fb6c0413d654e6b1537c9813b301 /test/Crypto/Macaroon/Verifier | |
parent | bf31e29028a4402ea0d2deefdb3b86efd526acd0 (diff) | |
download | hmacaroons-86f3882318d323d1920ca1c7da6e816f0ed376da.tar.gz hmacaroons-86f3882318d323d1920ca1c7da6e816f0ed376da.tar.zst hmacaroons-86f3882318d323d1920ca1c7da6e816f0ed376da.zip |
Change verifier api and split Verifier module
- Added haddocks
Diffstat (limited to 'test/Crypto/Macaroon/Verifier')
-rw-r--r-- | test/Crypto/Macaroon/Verifier/Internal/Tests.hs | 30 | ||||
-rw-r--r-- | test/Crypto/Macaroon/Verifier/Tests.hs | 28 |
2 files changed, 37 insertions, 21 deletions
diff --git a/test/Crypto/Macaroon/Verifier/Internal/Tests.hs b/test/Crypto/Macaroon/Verifier/Internal/Tests.hs new file mode 100644 index 0000000..cd75118 --- /dev/null +++ b/test/Crypto/Macaroon/Verifier/Internal/Tests.hs | |||
@@ -0,0 +1,30 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | {-| | ||
3 | Copyright : (c) 2015 Julien Tanguy | ||
4 | License : BSD3 | ||
5 | |||
6 | Maintainer : julien.tanguy@jhome.fr | ||
7 | |||
8 | |||
9 | This test suite is based on the pymacaroons test suite: | ||
10 | <https://github.com/ecordell/pymacaroons> | ||
11 | -} | ||
12 | module Crypto.Macaroon.Verifier.Internal.Tests where | ||
13 | |||
14 | import qualified Data.ByteString.Char8 as B8 | ||
15 | import Data.List | ||
16 | import Test.Tasty | ||
17 | -- import Test.Tasty.HUnit | ||
18 | import Data.Either | ||
19 | import Test.Tasty.QuickCheck hiding (Failure, Success) | ||
20 | |||
21 | import Crypto.Macaroon | ||
22 | import Crypto.Macaroon.Verifier.Internal | ||
23 | |||
24 | import Crypto.Macaroon.Instances | ||
25 | |||
26 | tests :: TestTree | ||
27 | tests = testGroup "Crypto.Macaroon.Verifier.Internal" [ sigs | ||
28 | ] | ||
29 | |||
30 | sigs = testProperty "Signatures" $ \sm -> verifySig (secret sm) (macaroon sm) == Right (macaroon sm) | ||
diff --git a/test/Crypto/Macaroon/Verifier/Tests.hs b/test/Crypto/Macaroon/Verifier/Tests.hs index 670c991..b6220eb 100644 --- a/test/Crypto/Macaroon/Verifier/Tests.hs +++ b/test/Crypto/Macaroon/Verifier/Tests.hs | |||
@@ -12,21 +12,20 @@ This test suite is based on the pymacaroons test suite: | |||
12 | module Crypto.Macaroon.Verifier.Tests where | 12 | module Crypto.Macaroon.Verifier.Tests where |
13 | 13 | ||
14 | 14 | ||
15 | import Data.List | 15 | import qualified Data.ByteString.Char8 as B8 |
16 | import qualified Data.ByteString.Char8 as B8 | 16 | import Data.List |
17 | import Test.Tasty | 17 | import Test.Tasty |
18 | -- import Test.Tasty.HUnit | 18 | -- import Test.Tasty.HUnit |
19 | import Test.Tasty.QuickCheck hiding (Success, Failure) | 19 | import Data.Either |
20 | import Data.Either | 20 | import Test.Tasty.QuickCheck hiding (Failure, Success) |
21 | 21 | ||
22 | import Crypto.Macaroon | 22 | import Crypto.Macaroon |
23 | import Crypto.Macaroon.Verifier | 23 | import Crypto.Macaroon.Verifier |
24 | 24 | ||
25 | import Crypto.Macaroon.Instances | 25 | import Crypto.Macaroon.Instances |
26 | 26 | ||
27 | tests :: TestTree | 27 | tests :: TestTree |
28 | tests = testGroup "Crypto.Macaroon.Verifier" [ sigs | 28 | tests = testGroup "Crypto.Macaroon.Verifier" [ ] |
29 | ] | ||
30 | 29 | ||
31 | {- | 30 | {- |
32 | - Test fixtures | 31 | - Test fixtures |
@@ -45,22 +44,9 @@ m2 = addFirstPartyCaveat "test = caveat" m | |||
45 | m3 :: Macaroon | 44 | m3 :: Macaroon |
46 | m3 = addFirstPartyCaveat "value = 42" m2 | 45 | m3 = addFirstPartyCaveat "value = 42" m2 |
47 | 46 | ||
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 | ||
52 | |||
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") | ||
57 | |||
58 | -- allvs = [exTC, exTZ, exV42, exV43, funTCPre, funTV43lte] | ||
59 | |||
60 | {- | 47 | {- |
61 | - Tests | 48 | - Tests |
62 | -} | 49 | -} |
63 | sigs = testProperty "Signatures" $ \sm -> verifySig (secret sm) (macaroon sm) == Right (macaroon sm) | ||
64 | 50 | ||
65 | -- TODO: Re-do tests | 51 | -- TODO: Re-do tests |
66 | {- | 52 | {- |