aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJulien Tanguy <julien.tanguy@jhome.fr>2015-10-05 18:35:03 +0200
committerJulien Tanguy <julien.tanguy@jhome.fr>2015-10-05 18:36:55 +0200
commitbe278da91e6c97e31c5611721b1bbd593fcd99b9 (patch)
treea7a0e90bc843a592e88da10fda21e63ddcaea6a8 /test
parent27d15c27e396a98f445cdc16b2325d5838e6c734 (diff)
downloadhmacaroons-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.hs12
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
45m2 :: Macaroon 45m2 :: Macaroon
46m2 = addFirstPartyCaveat "test = caveat" m 46m2 = addFirstPartyCaveat "test = caveat" m
47 47
48vtest :: Caveat -> IO (Maybe (Either ValidationError ())) 48vtest :: Caveat -> IO VerifierResult
49vtest c = return $ if "test" `BS.isPrefixOf` cid c then 49vtest 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
54m3 :: Macaroon 54m3 :: Macaroon
55m3 = addFirstPartyCaveat "value = 42" m2 55m3 = addFirstPartyCaveat "value = 42" m2
56 56
57vval :: Caveat -> IO (Maybe (Either ValidationError ())) 57vval :: Caveat -> IO VerifierResult
58vval c = return $ if "value" `BS.isPrefixOf` cid c then 58vval 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{-