aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/Crypto/Macaroon
diff options
context:
space:
mode:
authorJulien Tanguy <julien.tanguy@jhome.fr>2015-04-09 17:29:37 +0200
committerJulien Tanguy <julien.tanguy@jhome.fr>2015-04-09 17:29:37 +0200
commit2aede11ad7e5addd50cd4e3c202e094319e942f2 (patch)
treeaf40c821fef8b8066e736937396a08ec5b4ded35 /test/Crypto/Macaroon
parentf678145637ba6f42c36d07c19f8c764e5d537f72 (diff)
downloadhmacaroons-2aede11ad7e5addd50cd4e3c202e094319e942f2.tar.gz
hmacaroons-2aede11ad7e5addd50cd4e3c202e094319e942f2.tar.zst
hmacaroons-2aede11ad7e5addd50cd4e3c202e094319e942f2.zip
Rewording and lint
Diffstat (limited to 'test/Crypto/Macaroon')
-rw-r--r--test/Crypto/Macaroon/Tests.hs48
1 files changed, 29 insertions, 19 deletions
diff --git a/test/Crypto/Macaroon/Tests.hs b/test/Crypto/Macaroon/Tests.hs
index cdfb620..f57bec3 100644
--- a/test/Crypto/Macaroon/Tests.hs
+++ b/test/Crypto/Macaroon/Tests.hs
@@ -23,6 +23,7 @@ tests :: TestTree
23tests = testGroup "Crypto.Macaroon" [ basicSignature 23tests = testGroup "Crypto.Macaroon" [ basicSignature
24 , basicSerialize 24 , basicSerialize
25 , basicMint 25 , basicMint
26 , basicInspect
26 , basicMintTrimmed 27 , basicMintTrimmed
27 ] 28 ]
28 29
@@ -34,12 +35,39 @@ m = create secret key loc
34 key = B8.pack "we used our secret key" 35 key = B8.pack "we used our secret key"
35 loc = B8.pack "http://mybank/" 36 loc = B8.pack "http://mybank/"
36 37
38basicSignature = testCase "Basic signature" $
39 "E3D9E02908526C4C0039AE15114115D97FDD68BF2BA379B342AAF0F617D0552F" @=? (hex . signature) m
40
41basicSerialize = testCase "Serialization" $
42 "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudG\
43 \lmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25h\
44 \dHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo" @=? serialize m
45
37m2 :: Macaroon 46m2 :: Macaroon
38m2 = addFirstPartyCaveat "test = caveat" m 47m2 = addFirstPartyCaveat "test = caveat" m
39 48
49basicInspect = testCase "Inspect" $
50 "location http://mybank/\nidentifier we used\
51 \ our secret key\ncid test = caveat\nsignature\
52 \ 197BAC7A044AF33332865B9266E26D49\
53 \3BDD668A660E44D88CE1A998C23DBD67" @=? inspect m2
54
55
56basicMint = testCase "First Party Caveat" $
57 "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZ\
58 \WQgb3VyIHNlY3JldCBrZXkKMDAxNmNpZCB0ZXN0ID0gY2F2ZWF0CjAwMmZzaWduYXR1cmUgGXusegR\
59 \K8zMyhluSZuJtSTvdZopmDkTYjOGpmMI9vWcK" @=? serialize m2
60
61
40m3 :: Macaroon 62m3 :: Macaroon
41m3 = addFirstPartyCaveat "test = acaveat" m 63m3 = addFirstPartyCaveat "test = acaveat" m
42 64
65basicMintTrimmed = testCase "Trimmed base64" $
66 "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVz\
67 \ZWQgb3VyIHNlY3JldCBrZXkKMDAxN2NpZCB0ZXN0ID0gYWNhdmVhdAowMDJmc2ln\
68 \bmF0dXJlIJRJ_V3WNJQnqlVq5eez7spnltwU_AXs8NIRY739sHooCg" @=? serialize m3
69
70
43m4 :: Macaroon 71m4 :: Macaroon
44m4 = addThirdPartyCaveat caveat_key caveat_id caveat_loc n 72m4 = addThirdPartyCaveat caveat_key caveat_id caveat_loc n
45 where 73 where
@@ -52,23 +80,5 @@ m4 = addThirdPartyCaveat caveat_key caveat_id caveat_loc n
52 caveat_loc = B8.pack "http://auth.mybank/" 80 caveat_loc = B8.pack "http://auth.mybank/"
53 81
54 82
55basicSignature = testCase "Basic signature" $ 83basicThirdParty = testCase "Third Party Caveat" $
56 "E3D9E02908526C4C0039AE15114115D97FDD68BF2BA379B342AAF0F617D0552F" @=? (hex . signature) m
57
58basicSerialize = testCase "Serialization" $
59 "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudG\
60 \lmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25h\
61 \dHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo" @=? serialize m
62
63basicMint = testCase "First Party Caveat" $
64 "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZ\
65 \WQgb3VyIHNlY3JldCBrZXkKMDAxNmNpZCB0ZXN0ID0gY2F2ZWF0CjAwMmZzaWduYXR1cmUgGXusegR\
66 \K8zMyhluSZuJtSTvdZopmDkTYjOGpmMI9vWcK" @=? serialize m2
67
68basicMintTrimmed = testCase "Trimmed base64" $
69 "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVz\
70 \ZWQgb3VyIHNlY3JldCBrZXkKMDAxN2NpZCB0ZXN0ID0gYWNhdmVhdAowMDJmc2ln\
71 \bmF0dXJlIJRJ_V3WNJQnqlVq5eez7spnltwU_AXs8NIRY739sHooCg" @=? serialize m3
72
73basicThirdParty = testCase "Third Party Caveat" $
74 "6B99EDB2EC6D7A4382071D7D41A0BF7DFA27D87D2F9FEA86E330D7850FFDA2B2" @=? (hex . signature) m4 84 "6B99EDB2EC6D7A4382071D7D41A0BF7DFA27D87D2F9FEA86E330D7850FFDA2B2" @=? (hex . signature) m4