| 97 | |
| 98 | |
| 99 | def section_params(binary, work): |
| 100 | cache = os.path.join(work, "cache-params") |
| 101 | os.makedirs(cache, exist_ok=True) |
| 102 | bare = run_cli(binary, cache, ["daemon"]) |
| 103 | if bare.returncode == 0 or "usage:" not in out_text(bare): |
| 104 | print("RED: bare `daemon` should print usage and fail:\n%s" % out_text(bare)[:300]) |
| 105 | return False |
| 106 | unknown = run_cli(binary, cache, ["daemon", "bogus"]) |
| 107 | if unknown.returncode == 0 or "unknown daemon option" not in out_text(unknown): |
| 108 | print("RED: `daemon bogus` should be rejected:\n%s" % out_text(unknown)[:300]) |
| 109 | return False |
| 110 | bad_port = run_cli(binary, cache, ["daemon", "start", "--port=0"]) |
| 111 | if bad_port.returncode == 0 or "--port requires" not in out_text(bad_port): |
| 112 | print("RED: `--port=0` should be rejected before spawning:\n%s" |
| 113 | % out_text(bad_port)[:300]) |
| 114 | return False |
| 115 | print("PASS: parameter surface rejects bare/unknown/out-of-range daemon invocations") |
| 116 | return True |
| 117 | |
| 118 | |
| 119 | def section_hook_fail_open(binary, work): |