From 2aede11ad7e5addd50cd4e3c202e094319e942f2 Mon Sep 17 00:00:00 2001 From: Julien Tanguy Date: Thu, 9 Apr 2015 17:29:37 +0200 Subject: Rewording and lint --- test/Crypto/Macaroon/Tests.hs | 48 ++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'test') 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 tests = testGroup "Crypto.Macaroon" [ basicSignature , basicSerialize , basicMint + , basicInspect , basicMintTrimmed ] @@ -34,12 +35,39 @@ m = create secret key loc key = B8.pack "we used our secret key" loc = B8.pack "http://mybank/" +basicSignature = testCase "Basic signature" $ + "E3D9E02908526C4C0039AE15114115D97FDD68BF2BA379B342AAF0F617D0552F" @=? (hex . signature) m + +basicSerialize = testCase "Serialization" $ + "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudG\ + \lmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25h\ + \dHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo" @=? serialize m + m2 :: Macaroon m2 = addFirstPartyCaveat "test = caveat" m +basicInspect = testCase "Inspect" $ + "location http://mybank/\nidentifier we used\ + \ our secret key\ncid test = caveat\nsignature\ + \ 197BAC7A044AF33332865B9266E26D49\ + \3BDD668A660E44D88CE1A998C23DBD67" @=? inspect m2 + + +basicMint = testCase "First Party Caveat" $ + "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZ\ + \WQgb3VyIHNlY3JldCBrZXkKMDAxNmNpZCB0ZXN0ID0gY2F2ZWF0CjAwMmZzaWduYXR1cmUgGXusegR\ + \K8zMyhluSZuJtSTvdZopmDkTYjOGpmMI9vWcK" @=? serialize m2 + + m3 :: Macaroon m3 = addFirstPartyCaveat "test = acaveat" m +basicMintTrimmed = testCase "Trimmed base64" $ + "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVz\ + \ZWQgb3VyIHNlY3JldCBrZXkKMDAxN2NpZCB0ZXN0ID0gYWNhdmVhdAowMDJmc2ln\ + \bmF0dXJlIJRJ_V3WNJQnqlVq5eez7spnltwU_AXs8NIRY739sHooCg" @=? serialize m3 + + m4 :: Macaroon m4 = addThirdPartyCaveat caveat_key caveat_id caveat_loc n where @@ -52,23 +80,5 @@ m4 = addThirdPartyCaveat caveat_key caveat_id caveat_loc n caveat_loc = B8.pack "http://auth.mybank/" -basicSignature = testCase "Basic signature" $ - "E3D9E02908526C4C0039AE15114115D97FDD68BF2BA379B342AAF0F617D0552F" @=? (hex . signature) m - -basicSerialize = testCase "Serialization" $ - "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudG\ - \lmaWVyIHdlIHVzZWQgb3VyIHNlY3JldCBrZXkKMDAyZnNpZ25h\ - \dHVyZSDj2eApCFJsTAA5rhURQRXZf91ovyujebNCqvD2F9BVLwo" @=? serialize m - -basicMint = testCase "First Party Caveat" $ - "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVzZ\ - \WQgb3VyIHNlY3JldCBrZXkKMDAxNmNpZCB0ZXN0ID0gY2F2ZWF0CjAwMmZzaWduYXR1cmUgGXusegR\ - \K8zMyhluSZuJtSTvdZopmDkTYjOGpmMI9vWcK" @=? serialize m2 - -basicMintTrimmed = testCase "Trimmed base64" $ - "MDAxY2xvY2F0aW9uIGh0dHA6Ly9teWJhbmsvCjAwMjZpZGVudGlmaWVyIHdlIHVz\ - \ZWQgb3VyIHNlY3JldCBrZXkKMDAxN2NpZCB0ZXN0ID0gYWNhdmVhdAowMDJmc2ln\ - \bmF0dXJlIJRJ_V3WNJQnqlVq5eez7spnltwU_AXs8NIRY739sHooCg" @=? serialize m3 - -basicThirdParty = testCase "Third Party Caveat" $ +basicThirdParty = testCase "Third Party Caveat" $ "6B99EDB2EC6D7A4382071D7D41A0BF7DFA27D87D2F9FEA86E330D7850FFDA2B2" @=? (hex . signature) m4 -- cgit v1.2.3