2010/2/18 Balazs Lecz <[email protected]>:
> Also replace positional calls with explicit keyword argument calls in
> test/ganeti.serializer_unittest.py

You shouldn't. Positional arguments should be passed as positional
arguments, keyword arguments as keyword arguments.

> --- a/lib/serializer.py
> +++ b/lib/serializer.py
> -def DumpSignedJson(data, key, salt=None):
> +def DumpSignedJson(data, key, salt=None, key_selector=None):
> @@ -117,6 +119,8 @@ def DumpSignedJson(data, key, salt=None):
>     'salt': salt,
>     'hmac': hmac.new(key, salt + txt, sha1).hexdigest(),
>   }
> +  if key_selector:
> +    signed_dict["key_selector"] = key_selector

As commented on by Guido, you should include key_selector in the hmac.

> --- a/test/ganeti.serializer_unittest.py
> +++ b/test/ganeti.serializer_unittest.py
> @@ -68,16 +68,29 @@ class TestSerializer(testutils.GanetiTestCase):
>     DumpSigned = serializer.DumpSigned
>
>     for data in self._TESTDATA:
> -      self.assertEqualValues(LoadSigned(DumpSigned(data, "mykey"), "mykey"),
> +      self.assertEqualValues(LoadSigned(DumpSigned(data,
> +                                                   key="mykey"),
> +                                        key="mykey"),
>                              (data, ''))
> -      self.assertEqualValues(LoadSigned(DumpSigned(data, "myprivatekey",
> -                                                   "mysalt"),
> -                                        "myprivatekey"),
> +      self.assertEqualValues(LoadSigned(DumpSigned(data,
> +                                                   key="myprivatekey",
> +                                                   salt="mysalt"),
> +                                        key="myprivatekey"),
>                              (data, "mysalt"))

See above for why you shouldn't pass the key as a keyword argument.

Regards,
Michael

Reply via email to