diff --git a/changelog/61416.fixed.md b/changelog/61416.fixed.md new file mode 100644 index 000000000000..3203a0a1c6ac --- /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 000000000000..3203a0a1c6ac --- /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 485f39ee9fbf..07ce6122ba4c 100644 --- a/salt/daemons/masterapi.py +++ b/salt/daemons/masterapi.py @@ -380,7 +380,7 @@ def check_autosign_grains(self, autosign_grains): 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 b3657b7f1bc8..ddcfc17e4a77 100644 --- a/tests/pytests/unit/daemons/masterapi/test_auto_key.py +++ b/tests/pytests/unit/daemons/masterapi/test_auto_key.py @@ -256,16 +256,17 @@ def test_func(mock_walk, mock_open, mock_permissions): _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)