diff --git a/stages/test/test_kickstart.py b/stages/test/test_kickstart.py index 22a3b78ca3..30cf8aaa0b 100644 --- a/stages/test/test_kickstart.py +++ b/stages/test/test_kickstart.py @@ -4,6 +4,7 @@ import pytest +import osbuild.meta from osbuild.testutil.imports import import_module_from_path @@ -30,3 +31,32 @@ def test_kickstart(tmp_path, test_input, expected): with open(os.path.join(tmp_path, ks_path), encoding="utf-8") as fp: ks_content = fp.read() assert ks_content == expected + "\n" + + +@pytest.mark.parametrize("test_user,expected_err", [ + ("user;invalid", "'user;invalid' does not match any of the regexes:"), +]) +def test_schema_validation_regression_user(test_user, expected_err): + name = "org.osbuild.kickstart" + root = os.path.join(os.path.dirname(__file__), "../..") + mod_info = osbuild.meta.ModuleInfo.load(root, "Stage", name) + schema = osbuild.meta.Schema(mod_info.get_schema(), name) + + test_input = { + "name": "org.osbuild.kickstart", + "options": { + "path": "some-path", + "users": { + test_user: { + "uid": 1000, + } + } + } + } + res = schema.validate(test_input) + + assert res.valid == False + assert len(res.errors) == 1 + err_msgs = [e.as_dict()["message"] for e in res.errors] + assert expected_err in err_msgs[0] +