Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit allowed pkg_managers #1145

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions osbs/schemas/container.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
"type": ["array", "null"],
"items": {
"type": "string",
"enum": ["gomod", "rubygems", "pip", "yarn", "npm", "git-submodule"],
"examples": [
"gomod"
]
Expand Down
40 changes: 40 additions & 0 deletions tests/utils/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,43 @@ def test_invalid_remote_sources_schema(config, err_message, caplog):
def test_valid_remote_sources_schema(config, expected_data):
data = read_yaml(dedent(config), "schemas/container.json")
assert expected_data == data


@pytest.mark.parametrize("pkg_manager,valid", [
("npm", True),
("pip", True),
("gomod", True),
("git-submodule", True),
("yarn", True),
("rubygems", True),
("generic", False),
("rpm", False),
])
def test_valid_pkg_managers(pkg_manager, valid):
remote_sources = f"""
remote_sources:
- name: valid-name
remote_source:
repo: https://git.example.com/team/repo.git
ref: b55c00f45ec3dfee0c766cea3d395d6e21cc2e5a
pkg_managers:
- {pkg_manager}
"""
if valid:
assert read_yaml(dedent(remote_sources), "schemas/container.json")
else:
with pytest.raises(OsbsValidationException):
read_yaml(dedent(remote_sources), "schemas/container.json")

remote_source = f"""
remote_source:
repo: https://git.example.com/team/repo.git
ref: b55c00f45ec3dfee0c766cea3d395d6e21cc2e5a
pkg_managers:
- {pkg_manager}
"""
if valid:
read_yaml(dedent(remote_source), "schemas/container.json")
else:
with pytest.raises(OsbsValidationException):
read_yaml(dedent(remote_source), "schemas/container.json")