let signed = Confd.Utils.signMessage key_sign salt (J.encode crq)
encoded = J.encode signed
in printTestCase ("Accepted message signed with different key" ++ encoded) $
- BasicTypes.Bad "HMAC verification failed" ==?
- Confd.Utils.parseRequest key_verify encoded
+ Confd.Utils.parseRequest key_verify encoded ==?
+ BasicTypes.Bad "HMAC verification failed"
testSuite "Confd/Utils"
[ 'prop_req_sign
prop_addIdempotent :: PeerMap.PeerMap
-> PeerMap.Key -> PeerMap.Elem -> Property
prop_addIdempotent pmap key em =
- fn puniq ==? fn (fn puniq)
+ fn (fn puniq) ==? fn puniq
where fn = PeerMap.add key em
puniq = PeerMap.accumArray const pmap
-- | Make sure remove is idempotent.
prop_removeIdempotent :: PeerMap.PeerMap -> PeerMap.Key -> Property
prop_removeIdempotent pmap key =
- fn puniq ==? fn (fn puniq)
+ fn (fn puniq) ==? fn puniq
where fn = PeerMap.remove key
puniq = PeerMap.accumArray const pmap
-- * Helper functions
--- | Checks for equality with proper annotation.
+-- | Checks for equality with proper annotation. The first argument is
+-- the computed value, the second one the expected value.
(==?) :: (Show a, Eq a) => a -> a -> Property
(==?) x y = printTestCase
- ("Expected equality, but '" ++
- show x ++ "' /= '" ++ show y ++ "'") (x == y)
+ ("Expected equality, but got mismatch\nexpected: " ++
+ show x ++ "\n but got: " ++ show y) (x == y)
infix 3 ==?
--- | Checks for inequality with proper annotation.
+-- | Checks for inequality with proper annotation. The first argument
+-- is the computed value, the second one the expected (not equal)
+-- value.
(/=?) :: (Show a, Eq a) => a -> a -> Property
(/=?) x y = printTestCase
("Expected inequality, but got equality: '" ++