diff options
author | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-10-05 18:35:03 +0200 |
---|---|---|
committer | Julien Tanguy <julien.tanguy@jhome.fr> | 2015-10-05 18:36:55 +0200 |
commit | be278da91e6c97e31c5611721b1bbd593fcd99b9 (patch) | |
tree | a7a0e90bc843a592e88da10fda21e63ddcaea6a8 /test | |
parent | 27d15c27e396a98f445cdc16b2325d5838e6c734 (diff) | |
download | hmacaroons-be278da91e6c97e31c5611721b1bbd593fcd99b9.tar.gz hmacaroons-be278da91e6c97e31c5611721b1bbd593fcd99b9.tar.zst hmacaroons-be278da91e6c97e31c5611721b1bbd593fcd99b9.zip |
Dedicated VerifierResult
The Maybe (Either ValidationError ()) return type was too cryptic, now there is
a real datatype for it.
The validation part is unchanged and still uses the Maybe Either type
Diffstat (limited to 'test')
-rw-r--r-- | test/Crypto/Macaroon/Verifier/Internal/Tests.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/Crypto/Macaroon/Verifier/Internal/Tests.hs b/test/Crypto/Macaroon/Verifier/Internal/Tests.hs index 826b631..59980de 100644 --- a/test/Crypto/Macaroon/Verifier/Internal/Tests.hs +++ b/test/Crypto/Macaroon/Verifier/Internal/Tests.hs | |||
@@ -45,19 +45,19 @@ m = create sec key loc | |||
45 | m2 :: Macaroon | 45 | m2 :: Macaroon |
46 | m2 = addFirstPartyCaveat "test = caveat" m | 46 | m2 = addFirstPartyCaveat "test = caveat" m |
47 | 47 | ||
48 | vtest :: Caveat -> IO (Maybe (Either ValidationError ())) | 48 | vtest :: Caveat -> IO VerifierResult |
49 | vtest c = return $ if "test" `BS.isPrefixOf` cid c then | 49 | vtest c = return $ if "test" `BS.isPrefixOf` cid c then |
50 | Just $ bool (Left (ValidatorError "Failed")) (Right ()) $ "test = caveat" == cid c | 50 | bool (Refused (ValidatorError "Failed")) Verified $ "test = caveat" == cid c |
51 | else Nothing | 51 | else Unrelated |
52 | 52 | ||
53 | 53 | ||
54 | m3 :: Macaroon | 54 | m3 :: Macaroon |
55 | m3 = addFirstPartyCaveat "value = 42" m2 | 55 | m3 = addFirstPartyCaveat "value = 42" m2 |
56 | 56 | ||
57 | vval :: Caveat -> IO (Maybe (Either ValidationError ())) | 57 | vval :: Caveat -> IO VerifierResult |
58 | vval c = return $ if "value" `BS.isPrefixOf` cid c then | 58 | vval c = return $ if "value" `BS.isPrefixOf` cid c then |
59 | Just $ bool (Left (ValidatorError "Failed")) (Right ()) $ "value = 42" == cid c | 59 | bool (Refused (ValidatorError "Failed")) Verified $ "value = 42" == cid c |
60 | else Nothing | 60 | else Unrelated |
61 | 61 | ||
62 | 62 | ||
63 | {- | 63 | {- |