update
This commit is contained in:
@@ -46,6 +46,21 @@ class FakeCommandRunner:
|
||||
|
||||
|
||||
class AptManifestTests(unittest.TestCase):
|
||||
def test_wildcard_accepts_any_valid_apt_package_name(self) -> None:
|
||||
validator_settings = SimpleNamespace(allowed_apt_packages=["*"])
|
||||
with patch("app.core.manifest_validator.settings", validator_settings):
|
||||
manifest = ManifestValidator().validate(
|
||||
apt_manifest(
|
||||
{
|
||||
"componentId": "nginx-extras",
|
||||
"type": "apt",
|
||||
"packageName": "nginx-extras",
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(manifest["components"][0]["packageName"], "nginx-extras")
|
||||
|
||||
def test_postgresql_is_accepted_when_allowlisted(self) -> None:
|
||||
validator_settings = SimpleNamespace(allowed_apt_packages=["postgresql"])
|
||||
with patch("app.core.manifest_validator.settings", validator_settings):
|
||||
@@ -54,6 +69,23 @@ class AptManifestTests(unittest.TestCase):
|
||||
self.assertEqual(manifest["components"][0]["type"], "apt")
|
||||
self.assertEqual(manifest["components"][0]["packageName"], "postgresql")
|
||||
|
||||
def test_any_package_in_a_multi_package_allowlist_is_accepted(self) -> None:
|
||||
validator_settings = SimpleNamespace(
|
||||
allowed_apt_packages=["postgresql", "nginx", "redis-server"]
|
||||
)
|
||||
with patch("app.core.manifest_validator.settings", validator_settings):
|
||||
manifest = ManifestValidator().validate(
|
||||
apt_manifest(
|
||||
{
|
||||
"componentId": "redis-server",
|
||||
"type": "apt",
|
||||
"packageName": "redis-server",
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(manifest["components"][0]["packageName"], "redis-server")
|
||||
|
||||
def test_non_allowlisted_package_is_rejected(self) -> None:
|
||||
validator_settings = SimpleNamespace(allowed_apt_packages=["postgresql"])
|
||||
with patch("app.core.manifest_validator.settings", validator_settings):
|
||||
|
||||
Reference in New Issue
Block a user