Accepting request 1118342 from home:mczernek:branches:systemsmanagement:saltstack
- Allow all primitive grain types for autosign_grains (bsc#1214477) - Added: * allow-all-primitive-grain-types-for-autosign_grains-.patch OBS-URL: https://build.opensuse.org/request/show/1118342 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=220
This commit is contained in:
parent
7a28d6f4c1
commit
bc54283667
@ -1 +1 @@
|
||||
a07e4ffc42dc0bcf9a52cea8d681ed46dba2505a
|
||||
98760e99efa76ce0a348adb87dbd36511a748edf
|
97
allow-all-primitive-grain-types-for-autosign_grains-.patch
Normal file
97
allow-all-primitive-grain-types-for-autosign_grains-.patch
Normal file
@ -0,0 +1,97 @@
|
||||
From ae4e1d1cc15b3c510bdd774a1dfeff67c522324a Mon Sep 17 00:00:00 2001
|
||||
From: Marek Czernek <marek.czernek@suse.com>
|
||||
Date: Tue, 17 Oct 2023 13:05:00 +0200
|
||||
Subject: [PATCH] Allow all primitive grain types for autosign_grains
|
||||
(#607)
|
||||
|
||||
* Allow all primitive grain types for autosign_grains
|
||||
|
||||
Signed-off-by: Marek Czernek <marek.czernek@suse.com>
|
||||
|
||||
* blacken daemons/masterapi.py and its test_auto_key
|
||||
|
||||
Signed-off-by: Marek Czernek <marek.czernek@suse.com>
|
||||
|
||||
---------
|
||||
|
||||
Signed-off-by: Marek Czernek <marek.czernek@suse.com>
|
||||
Co-authored-by: Alexander Graul <agraul@suse.com>
|
||||
---
|
||||
changelog/61416.fixed.md | 1 +
|
||||
changelog/63708.fixed.md | 1 +
|
||||
salt/daemons/masterapi.py | 2 +-
|
||||
.../pytests/unit/daemons/masterapi/test_auto_key.py | 13 +++++++------
|
||||
4 files changed, 10 insertions(+), 7 deletions(-)
|
||||
create mode 100644 changelog/61416.fixed.md
|
||||
create mode 100644 changelog/63708.fixed.md
|
||||
|
||||
diff --git a/changelog/61416.fixed.md b/changelog/61416.fixed.md
|
||||
new file mode 100644
|
||||
index 0000000000..3203a0a1c6
|
||||
--- /dev/null
|
||||
+++ b/changelog/61416.fixed.md
|
||||
@@ -0,0 +1 @@
|
||||
+Allow all primitive grain types for autosign_grains
|
||||
diff --git a/changelog/63708.fixed.md b/changelog/63708.fixed.md
|
||||
new file mode 100644
|
||||
index 0000000000..3203a0a1c6
|
||||
--- /dev/null
|
||||
+++ b/changelog/63708.fixed.md
|
||||
@@ -0,0 +1 @@
|
||||
+Allow all primitive grain types for autosign_grains
|
||||
diff --git a/salt/daemons/masterapi.py b/salt/daemons/masterapi.py
|
||||
index 3716c63d99..54aca64a76 100644
|
||||
--- a/salt/daemons/masterapi.py
|
||||
+++ b/salt/daemons/masterapi.py
|
||||
@@ -366,7 +366,7 @@ class AutoKey:
|
||||
line = salt.utils.stringutils.to_unicode(line).strip()
|
||||
if line.startswith("#"):
|
||||
continue
|
||||
- if autosign_grains[grain] == line:
|
||||
+ if str(autosign_grains[grain]) == line:
|
||||
return True
|
||||
return False
|
||||
|
||||
diff --git a/tests/pytests/unit/daemons/masterapi/test_auto_key.py b/tests/pytests/unit/daemons/masterapi/test_auto_key.py
|
||||
index b3657b7f1b..54c3f22d2a 100644
|
||||
--- a/tests/pytests/unit/daemons/masterapi/test_auto_key.py
|
||||
+++ b/tests/pytests/unit/daemons/masterapi/test_auto_key.py
|
||||
@@ -17,11 +17,11 @@ def gen_permissions(owner="", group="", others=""):
|
||||
"""
|
||||
ret = 0
|
||||
for c in owner:
|
||||
- ret |= getattr(stat, "S_I{}USR".format(c.upper()), 0)
|
||||
+ ret |= getattr(stat, f"S_I{c.upper()}USR", 0)
|
||||
for c in group:
|
||||
- ret |= getattr(stat, "S_I{}GRP".format(c.upper()), 0)
|
||||
+ ret |= getattr(stat, f"S_I{c.upper()}GRP", 0)
|
||||
for c in others:
|
||||
- ret |= getattr(stat, "S_I{}OTH".format(c.upper()), 0)
|
||||
+ ret |= getattr(stat, f"S_I{c.upper()}OTH", 0)
|
||||
return ret
|
||||
|
||||
|
||||
@@ -256,16 +256,17 @@ def test_check_autosign_grains_no_autosign_grains_dir(auto_key):
|
||||
_test_check_autosign_grains(test_func, auto_key, autosign_grains_dir=None)
|
||||
|
||||
|
||||
-def test_check_autosign_grains_accept(auto_key):
|
||||
+@pytest.mark.parametrize("grain_value", ["test_value", 123, True])
|
||||
+def test_check_autosign_grains_accept(grain_value, auto_key):
|
||||
"""
|
||||
Asserts that autosigning from grains passes when a matching grain value is in an
|
||||
autosign_grain file.
|
||||
"""
|
||||
|
||||
def test_func(*args):
|
||||
- assert auto_key.check_autosign_grains({"test_grain": "test_value"}) is True
|
||||
+ assert auto_key.check_autosign_grains({"test_grain": grain_value}) is True
|
||||
|
||||
- file_content = "#test_ignore\ntest_value"
|
||||
+ file_content = f"#test_ignore\n{grain_value}"
|
||||
_test_check_autosign_grains(test_func, auto_key, file_content=file_content)
|
||||
|
||||
|
||||
--
|
||||
2.42.0
|
||||
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 17 15:28:22 UTC 2023 - Marek Czernek <marek.czernek@suse.com>
|
||||
|
||||
- Allow all primitive grain types for autosign_grains (bsc#1214477)
|
||||
|
||||
- Added:
|
||||
* allow-all-primitive-grain-types-for-autosign_grains-.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Oct 2 12:49:41 UTC 2023 - Victor Zhestkov <vzhestkov@suse.com>
|
||||
|
||||
|
@ -316,6 +316,8 @@ Patch84: use-salt-call-from-salt-bundle-with-transactional_up.patch
|
||||
Patch85: improve-salt.utils.json.find_json-bsc-1213293.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/65266
|
||||
Patch86: fix-optimization_order-opt-to-prevent-test-fails.patch
|
||||
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/65232
|
||||
Patch87: allow-all-primitive-grain-types-for-autosign_grains-.patch
|
||||
|
||||
### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
|
||||
### SALT PATCHES LIST END
|
||||
|
Loading…
x
Reference in New Issue
Block a user