SHA256
1
0
forked from pool/salt
salt/remove-msgpack-1.0.0-requirement-in-the-installed-me.patch

198 lines
6.4 KiB
Diff

From acf0a8a159cd5d24e98c7b7181e97135d093f2e4 Mon Sep 17 00:00:00 2001
From: Duncan Mac-Vicar P <dmacvicar@suse.de>
Date: Wed, 16 Sep 2020 12:08:40 +0200
Subject: [PATCH] Remove msgpack<1.0.0 requirement in the installed
metadata (#261)
We do run Salt with msgpack>=1.0.0. A program using this metadata to
check if dependencies are satisfied will break, as salt-sproxy does.
update msgpack
fix msg_test
fix .decode
fix .decode 2
fix failing tests
undo decode 2
fix strict_map_key
fix tab error
add back raw True
fix upack kwargs
add raw false
move raw false
raw=false move
clean up
---
requirements/static/py3.8/darwin.txt | 4 +-
requirements/static/py3.8/linux.txt | 2 +-
requirements/static/py3.9/darwin.txt | 4 +-
requirements/static/py3.9/linux.txt | 2 +-
salt/utils/msgpack.py | 2 +
tests/unit/utils/test_msgpack.py | 68 ++++++++++++++++++++++++++++
6 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/requirements/static/py3.8/darwin.txt b/requirements/static/py3.8/darwin.txt
index 95bcd7748d..3164168937 100644
--- a/requirements/static/py3.8/darwin.txt
+++ b/requirements/static/py3.8/darwin.txt
@@ -62,8 +62,8 @@ markupsafe==1.1.1
mock==3.0.5
more-itertools==5.0.0
moto==1.3.7
-msgpack-python==0.5.6
-msgpack==0.5.6
+msgpack==1.0.0
+msgpack==1.0.0
ncclient==0.6.4 # via junos-eznc
netaddr==0.7.19 # via junos-eznc
oscrypto==1.2.0 # via certvalidator
diff --git a/requirements/static/py3.8/linux.txt b/requirements/static/py3.8/linux.txt
index 5d42a310fa..217f07267e 100644
--- a/requirements/static/py3.8/linux.txt
+++ b/requirements/static/py3.8/linux.txt
@@ -57,7 +57,7 @@ markupsafe==1.1.1
mock==3.0.5
more-itertools==5.0.0
moto==1.3.7
-msgpack==0.5.6
+msgpack==1.0.0
ncclient==0.6.4 # via junos-eznc
netaddr==0.7.19 # via junos-eznc
oscrypto==1.2.0 # via certvalidator
diff --git a/requirements/static/py3.9/darwin.txt b/requirements/static/py3.9/darwin.txt
index 419f8ee1d1..c5f02fd7a5 100644
--- a/requirements/static/py3.9/darwin.txt
+++ b/requirements/static/py3.9/darwin.txt
@@ -62,8 +62,8 @@ markupsafe==1.1.1
mock==3.0.5
more-itertools==5.0.0
moto==1.3.7
-msgpack-python==0.5.6
-msgpack==0.5.6
+msgpack==1.0.0
+msgpack==1.0.0
ncclient==0.6.4 # via junos-eznc
netaddr==0.7.19 # via junos-eznc
oscrypto==1.2.0 # via certvalidator
diff --git a/requirements/static/py3.9/linux.txt b/requirements/static/py3.9/linux.txt
index b7eb8320de..8db5efa224 100644
--- a/requirements/static/py3.9/linux.txt
+++ b/requirements/static/py3.9/linux.txt
@@ -57,7 +57,7 @@ markupsafe==1.1.1
mock==3.0.5
more-itertools==5.0.0
moto==1.3.7
-msgpack==0.5.6
+msgpack==1.0.0
ncclient==0.6.4 # via junos-eznc
netaddr==0.7.19 # via junos-eznc
oscrypto==1.2.0 # via certvalidator
diff --git a/salt/utils/msgpack.py b/salt/utils/msgpack.py
index df4ac6cb9c..551e51f537 100644
--- a/salt/utils/msgpack.py
+++ b/salt/utils/msgpack.py
@@ -81,6 +81,8 @@ def _sanitize_msgpack_unpack_kwargs(kwargs):
if version >= (1, 0, 0):
kwargs.setdefault("raw", True)
kwargs.setdefault("strict_map_key", False)
+ if "encoding" in kwargs:
+ del kwargs["encoding"]
return _sanitize_msgpack_kwargs(kwargs)
diff --git a/tests/unit/utils/test_msgpack.py b/tests/unit/utils/test_msgpack.py
index 3c5f54dd3f..0287becfc4 100644
--- a/tests/unit/utils/test_msgpack.py
+++ b/tests/unit/utils/test_msgpack.py
@@ -200,6 +200,74 @@ class TestMsgpack(TestCase):
"msgpack functions with no alias in `salt.utils.msgpack`",
)
+ def test_sanitize_msgpack_kwargs(self):
+ """
+ Test helper function _sanitize_msgpack_kwargs
+ """
+ version = salt.utils.msgpack.version
+
+ kwargs = {"strict_map_key": True, "raw": True, "use_bin_type": True}
+ salt.utils.msgpack.version = (0, 6, 0)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_kwargs(kwargs),
+ {"raw": True, "strict_map_key": True, "use_bin_type": True},
+ )
+
+ kwargs = {"strict_map_key": True, "raw": True, "use_bin_type": True}
+ salt.utils.msgpack.version = (0, 5, 2)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_kwargs(kwargs),
+ {"raw": True, "use_bin_type": True},
+ )
+
+ kwargs = {"strict_map_key": True, "raw": True, "use_bin_type": True}
+ salt.utils.msgpack.version = (0, 4, 0)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_kwargs(kwargs), {"use_bin_type": True}
+ )
+
+ kwargs = {"strict_map_key": True, "raw": True, "use_bin_type": True}
+ salt.utils.msgpack.version = (0, 3, 0)
+ self.assertEqual(salt.utils.msgpack._sanitize_msgpack_kwargs(kwargs), {})
+ salt.utils.msgpack.version = version
+
+ def test_sanitize_msgpack_unpack_kwargs(self):
+ """
+ Test helper function _sanitize_msgpack_unpack_kwargs
+ """
+ version = salt.utils.msgpack.version
+
+ kwargs = {"strict_map_key": True, "use_bin_type": True, "encoding": "utf-8"}
+ salt.utils.msgpack.version = (1, 0, 0)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_unpack_kwargs(kwargs.copy()),
+ {"raw": True, "strict_map_key": True, "use_bin_type": True},
+ )
+
+ salt.utils.msgpack.version = (0, 6, 0)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_unpack_kwargs(kwargs.copy()),
+ {"strict_map_key": True, "use_bin_type": True, "encoding": "utf-8"},
+ )
+
+ salt.utils.msgpack.version = (0, 5, 2)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_unpack_kwargs(kwargs.copy()),
+ {"use_bin_type": True, "encoding": "utf-8"},
+ )
+
+ salt.utils.msgpack.version = (0, 4, 0)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_unpack_kwargs(kwargs.copy()),
+ {"use_bin_type": True, "encoding": "utf-8"},
+ )
+ kwargs = {"strict_map_key": True, "use_bin_type": True}
+ salt.utils.msgpack.version = (0, 3, 0)
+ self.assertEqual(
+ salt.utils.msgpack._sanitize_msgpack_unpack_kwargs(kwargs.copy()), {}
+ )
+ salt.utils.msgpack.version = version
+
def _test_base(self, pack_func, unpack_func):
"""
In msgpack, 'dumps' is an alias for 'packb' and 'loads' is an alias for 'unpackb'.
--
2.29.2