diff --git a/stages/org.osbuild.selinux.meta.json b/stages/org.osbuild.selinux.meta.json index f9e701e5..ea1bb3ef 100644 --- a/stages/org.osbuild.selinux.meta.json +++ b/stages/org.osbuild.selinux.meta.json @@ -48,6 +48,13 @@ "default": false } } + }, + "devices": { + "type": "object", + "additionalProperties": true + }, + "mounts": { + "type": "array" } } } diff --git a/stages/org.osbuild.users.meta.json b/stages/org.osbuild.users.meta.json index 433e7811..6c8668a6 100644 --- a/stages/org.osbuild.users.meta.json +++ b/stages/org.osbuild.users.meta.json @@ -72,6 +72,13 @@ } } } + }, + "devices": { + "type": "object", + "additionalProperties": true + }, + "mounts": { + "type": "array" } } } diff --git a/stages/test/conftest.py b/stages/test/conftest.py index f2f9d5a7..d9a314e4 100644 --- a/stages/test/conftest.py +++ b/stages/test/conftest.py @@ -43,3 +43,39 @@ def stage_schema(request: pytest.FixtureRequest) -> osbuild.meta.Schema: root = caller_dir.parent.parent mod_info = osbuild.meta.ModuleInfo.load(root, "Stage", stage_name) return osbuild.meta.Schema(mod_info.get_schema(version=schema_version), stage_name) + + +@pytest.fixture +def bootc_devices_mounts_dict() -> dict: + """ bootc_devices_mounts_dict returns a dict with a typical bootc + devices/mount dict + """ + return { + "devices": { + "disk": { + "type": "org.osbuild.loopback", + "options": { + "filename": "disk.raw", + "partscan": True, + } + } + }, + "mounts": [ + { + "name": "root", + "type": "org.osbuild.ext4", + "source": "disk", + "partition": 4, + "target": "/" + }, { + "name": "ostree.deployment", + "type": "org.osbuild.ostree.deployment", + "options": { + "source": "mount", + "deployment": { + "default": True, + } + } + } + ] + } diff --git a/stages/test/test_selinux.py b/stages/test/test_selinux.py index 98e78147..27eba4a5 100644 --- a/stages/test/test_selinux.py +++ b/stages/test/test_selinux.py @@ -48,6 +48,13 @@ def test_schema_validation_selinux_file_context_required(stage_schema): testutil.assert_jsonschema_error_contains(res, expected_err, expected_num_errs=1) +def test_schema_supports_bootc_style_mounts(stage_schema, bootc_devices_mounts_dict): + test_input = bootc_devices_mounts_dict + test_input["type"] = STAGE_NAME + res = stage_schema.validate(test_input) + assert res.valid is True, f"err: {[e.as_dict() for e in res.errors]}" + + @patch("osbuild.util.selinux.setfiles") def test_selinux_file_contexts(mocked_setfiles, tmp_path, stage_module): options = { diff --git a/stages/test/test_users.py b/stages/test/test_users.py index c74cbe55..392449fb 100644 --- a/stages/test/test_users.py +++ b/stages/test/test_users.py @@ -36,6 +36,13 @@ def test_schema_validation(stage_schema, test_data, expected_err): assert_jsonschema_error_contains(res, expected_err, expected_num_errs=1) +def test_schema_supports_bootc_style_mounts(stage_schema, bootc_devices_mounts_dict): + test_input = bootc_devices_mounts_dict + test_input["type"] = STAGE_NAME + res = stage_schema.validate(test_input) + assert res.valid is True, f"err: {[e.as_dict() for e in res.errors]}" + + TEST_CASES = [ # user_opts,expected commandline args ({}, []),