Revision 20bc5360 htest/Test/Ganeti/Confd/Utils.hs

b/htest/Test/Ganeti/Confd/Utils.hs
64 64
-- | Test that signing messages and checking signatures is correct. It
65 65
-- also tests, indirectly the serialisation of messages so we don't
66 66
-- need a separate test for that.
67
prop_ConfdUtils_req_sign :: Hash.HashKey        -- ^ The hash key
68
                    -> NonNegative Integer -- ^ The base timestamp
69
                    -> Positive Integer    -- ^ Delta for out of window
70
                    -> Bool                -- ^ Whether delta should be + or -
71
                    -> Confd.ConfdRequest
72
                    -> Property
73
prop_ConfdUtils_req_sign key (NonNegative timestamp) (Positive bad_delta)
67
prop_req_sign :: Hash.HashKey        -- ^ The hash key
68
              -> NonNegative Integer -- ^ The base timestamp
69
              -> Positive Integer    -- ^ Delta for out of window
70
              -> Bool                -- ^ Whether delta should be + or -
71
              -> Confd.ConfdRequest
72
              -> Property
73
prop_req_sign key (NonNegative timestamp) (Positive bad_delta)
74 74
                         pm crq =
75 75
  forAll (choose (0, fromIntegral C.confdMaxClockSkew)) $ \ good_delta ->
76 76
  let encoded = J.encode crq
......
89 89

  
90 90
-- | Tests that signing with a different key fails detects failure
91 91
-- correctly.
92
prop_ConfdUtils_bad_key :: String             -- ^ Salt
93
                   -> Confd.ConfdRequest -- ^ Request
94
                   -> Property
95
prop_ConfdUtils_bad_key salt crq =
92
prop_bad_key :: String             -- ^ Salt
93
             -> Confd.ConfdRequest -- ^ Request
94
             -> Property
95
prop_bad_key salt crq =
96 96
  -- fixme: we hardcode here the expected length of a sha1 key, as
97 97
  -- otherwise we could have two short keys that differ only in the
98 98
  -- final zero elements count, and those will be expanded to be the
......
106 106
     Confd.Utils.parseRequest key_verify encoded
107 107

  
108 108
testSuite "ConfdUtils"
109
  [ 'prop_ConfdUtils_req_sign
110
  , 'prop_ConfdUtils_bad_key
109
  [ 'prop_req_sign
110
  , 'prop_bad_key
111 111
  ]

Also available in: Unified diff