forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use Salt's custom YAML loader to load static grains file
- Loading branch information
1 parent
47ad770
commit a401152
Showing
4 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
tests.pytests.unit.grains.test_extra | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
""" | ||
|
||
import pytest | ||
|
||
import salt.grains.extra as extra | ||
import salt.utils.platform | ||
from tests.support.mock import MagicMock, patch | ||
|
||
|
||
@pytest.fixture | ||
def configure_loader_modules(): | ||
return {extra: {}} | ||
|
||
|
||
def test_static_grains_file_conflicting_keys(tmp_path): | ||
""" | ||
Test that static grains files with conflicting keys don't result in failure | ||
to load all grains from that file. | ||
""" | ||
with (tmp_path / "grains").open("w") as fh: | ||
fh.write('foo: bar\nfoo: baz\nno_conflict_here: "yay"\n') | ||
|
||
with patch.object( | ||
salt.utils.platform, "is_proxy", MagicMock(return_value=False) | ||
), patch("salt.grains.extra.__opts__", {"conf_file": str(tmp_path / "minion")}): | ||
static_grains = extra.config() | ||
assert "no_conflict_here" in static_grains |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters