from app import ( build_archinstall_config, build_archinstall_creds, validate_step1, ) def test_validate_step1_accepts_good_input(): errors, values = validate_step1( { "hostname": "furtka", "username": "daniel", "password": "topsecretpw", "password2": "topsecretpw", "language": "de", } ) assert errors == [] assert values == { "hostname": "furtka", "username": "daniel", "password": "topsecretpw", "language": "de", } def test_validate_step1_collects_all_errors(): errors, _ = validate_step1( { "hostname": "BAD!", "username": "1bad", "password": "short", "password2": "mismatch", "language": "xx", } ) assert len(errors) == 5 def test_build_archinstall_config_uses_selected_locale(monkeypatch): # build_disk_config imports archinstall lazily; archinstall isn't # installed in CI (only runs on the live ISO), so stub it out. import app as app_module monkeypatch.setattr(app_module, "build_disk_config", lambda d: {"stubbed_device": d}) cfg = build_archinstall_config( { "hostname": "h", "username": "u", "password": "pw12345678", "language": "pl", "boot_drive": "/dev/sda", } ) assert cfg["disk_config"] == {"stubbed_device": "/dev/sda"} assert cfg["hostname"] == "h" assert cfg["locale_config"]["locale"] == "pl_PL.UTF-8" # Users moved out of config into creds once we adopted archinstall 4.x's # `!password` sentinel; config only carries a gpasswd in custom_commands # so the user lands in the docker group after docker is pacstrapped. assert "users" not in cfg assert any("gpasswd -a u docker" in c for c in cfg["custom_commands"]) def test_build_archinstall_creds_uses_archinstall_sentinel_keys(): creds = build_archinstall_creds({"username": "u", "password": "pw12345678"}) assert creds["!root-password"] == "pw12345678" assert creds["users"] == [ { "username": "u", "!password": "pw12345678", "sudo": True, "groups": [], } ]