Revision 1a0defea htest/Test/Ganeti/Confd/Utils.hs
b/htest/Test/Ganeti/Confd/Utils.hs | ||
---|---|---|
67 | 67 |
\ timestamp, got " ++ show ts_bad) |
68 | 68 |
(ts_bad ==? BasicTypes.Bad "Too old/too new timestamp or clock skew") |
69 | 69 |
|
70 |
-- | Tests that a ConfdReply can be properly encoded, signed and parsed using |
|
71 |
-- the proper salt, but fails parsing with the wrong salt. |
|
72 |
prop_rep_salt :: Hash.HashKey -- ^ The hash key |
|
73 |
-> Confd.ConfdReply -- ^ A Confd reply |
|
74 |
-> Property |
|
75 |
prop_rep_salt hmac reply = |
|
76 |
forAll arbitrary $ \salt1 -> |
|
77 |
forAll (arbitrary `suchThat` (/= salt1)) $ \salt2 -> |
|
78 |
let innerMsg = J.encode reply |
|
79 |
msg = J.encode $ Confd.Utils.signMessage hmac salt1 innerMsg |
|
80 |
in |
|
81 |
Confd.Utils.parseReply hmac msg salt1 ==? BasicTypes.Ok (innerMsg, reply) |
|
82 |
.&&. Confd.Utils.parseReply hmac msg salt2 ==? |
|
83 |
BasicTypes.Bad "The received salt differs from the expected salt" |
|
84 |
|
|
70 | 85 |
-- | Tests that signing with a different key fails detects failure |
71 | 86 |
-- correctly. |
72 | 87 |
prop_bad_key :: String -- ^ Salt |
... | ... | |
88 | 103 |
|
89 | 104 |
testSuite "Confd/Utils" |
90 | 105 |
[ 'prop_req_sign |
106 |
, 'prop_rep_salt |
|
91 | 107 |
, 'prop_bad_key |
92 | 108 |
] |
Also available in: Unified diff