Skip to content

Commit

Permalink
fix: fix profile load and add test (#59)
Browse files Browse the repository at this point in the history
Signed-off-by: Weston Steimel <[email protected]>
  • Loading branch information
westonsteimel authored Mar 17, 2023
1 parent b24e38c commit adc3f0b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/yardstick/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def clean_dict_keys(d):


def yaml_decoder(data) -> Dict[Any, Any]:
return clean_dict_keys(yaml.load(data, yaml.CSafeLoader))
return clean_dict_keys(yaml.safe_load(data))


def load(path: str = ".yardstick.yaml") -> Application:
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def test_config(tmp_path):
file = tmp_path / "config.yaml"
file.write_text(subject)

profile_text = """
test_profile:
something:
name: jim
config_path: .abc/xyx.conf
refresh: false
"""
profile_file = tmp_path / ".yardstick.profiles.yaml"
profile_file.write_text(profile_text)

cfg = config.load(str(file))

assert cfg.result_sets["sboms"].matrix.images == [
Expand All @@ -47,3 +57,15 @@ def test_config(tmp_path):
"docker.io/anchore/test_images:grype-quality-node-d89207b@sha256:f56164678054e5eb59ab838367373a49df723b324617b1ba6de775749d7f91d4",
"docker.io/vulhub/cve-2017-1000353:latest@sha256:da2a59314b9ccfb428a313a7f163adcef77a74a393b8ebadeca8223b8cea9797",
]

assert cfg.profiles == config.Profiles(
{
"test_profile": {
"something": {
"name": "jim",
"config_path": ".abc/xyx.conf",
"refresh": False,
},
},
}
)

0 comments on commit adc3f0b

Please sign in to comment.