aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/Crypto/Macaroon
diff options
context:
space:
mode:
Diffstat (limited to 'test/Crypto/Macaroon')
-rw-r--r--test/Crypto/Macaroon/Instances.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/Crypto/Macaroon/Instances.hs b/test/Crypto/Macaroon/Instances.hs
index 4e2f39f..17044a0 100644
--- a/test/Crypto/Macaroon/Instances.hs
+++ b/test/Crypto/Macaroon/Instances.hs
@@ -48,6 +48,16 @@ newtype Identifier = Identifier { unIdent :: BS.ByteString } deriving (Show)
48instance Arbitrary Identifier where 48instance Arbitrary Identifier where
49 arbitrary = Identifier . B8.pack <$>(scale (*3) . listOf1 . elements $ ['a'..'z']) 49 arbitrary = Identifier . B8.pack <$>(scale (*3) . listOf1 . elements $ ['a'..'z'])
50 50
51newtype EquationLike = EquationLike { unEqlike :: BS.ByteString } deriving (Show)
52
53instance Arbitrary EquationLike where
54 arbitrary = do
55 keylen <- choose (3,8)
56 key <- B8.pack <$> vectorOf keylen (elements ['a'..'z'])
57 val <- B8.pack <$> (scale (*3) . listOf1 . elements $ ['a'..'z'])
58 return $ EquationLike (BS.concat [ key, " = ", val])
59
60
51data SimpleMac = SimpleMac { secret :: BS.ByteString, macaroon :: Macaroon } deriving Show 61data SimpleMac = SimpleMac { secret :: BS.ByteString, macaroon :: Macaroon } deriving Show
52 62
53instance Arbitrary SimpleMac where 63instance Arbitrary SimpleMac where
@@ -55,6 +65,8 @@ instance Arbitrary SimpleMac where
55 secret <- unSecret <$> arbitrary 65 secret <- unSecret <$> arbitrary
56 location <- unUrl <$> arbitrary 66 location <- unUrl <$> arbitrary
57 ident <- unIdent <$> arbitrary 67 ident <- unIdent <$> arbitrary
58 return $ SimpleMac secret (create secret ident location) 68 fpcavs <- listOf arbitrary
69 let mac = foldl (flip addFirstPartyCaveat) (create secret ident location) (map unEqlike fpcavs)
70 return $ SimpleMac secret mac
59 71
60 72