Status: Done (2026-04-20)
Priority: High
Component: lib/wsl/proxy.ps1, lib/wsl/scripts/setup-proxy.sh, lib/wsl/scripts/setup-proxy-negotiate.sh (new), lib/wsl/proxy.Tests.ps1
Parent: SC-036
Summary:
As a developer, I want setup-proxy to ask me upfront whether I want Auto, Manual, or Remove — and, when a proxy URL is resolved, whether to use Basic or Negotiate auth — so that the tool's intent is obvious from the first prompt and I can opt into Kerberos mode in later slices.
Description: Foundation slice for the SC-036 epic. Two prompt changes plus a mode marker:
- Top-level mode prompt
[A]uto / [M]anual / [R]emovereplaces the current PAC-first branching inInstall-WslProxy. Auto runs PAC detection and asks the user to confirm the resolved URL. Manual goes straight to ahost:portprompt. Remove dispatchessetup-proxy.sh --removewith no further prompts. - Auth-method prompt
[B]asic / [N]egotiate, shown only after a URL is resolved. Negotiate is stubbed in this slice:Install-WslProxydispatches to a new sibling scriptsetup-proxy-negotiate.shwhich prints "not yet implemented" and exits with code 10. - Mode marker file
/etc/wsl-manager/proxy-mode(valuesbasicornegotiate) so future--remove(SC-036e) can tear down the correct set of artifacts without guessing.
Basic mode continues to call setup-proxy.sh unchanged, but now also writes basic to the marker file so SC-036e's mode-aware teardown works uniformly from day one.
Scope Decisions:
- Upfront A/M/R prompt over PAC-first branching: makes the tool's intent obvious from the first prompt rather than surfacing different follow-up prompts depending on whether PAC was found. "Remove" also gives users an interactive path to tear down config without needing to remember the
--removeflag. - Auto → DIRECT collapses to Remove: when PAC resolves to DIRECT, dispatch the same
setup-proxy.sh --removeteardown that the Remove branch uses. Semantically identical (no proxy applies to this network) and keeps the concept count small. - Auto with no PAC errors out: if the user explicitly picks Auto and no PAC/AutoConfigURL is present in the registry, fail with a hint to re-run and choose Manual. No silent fallback — the user's intent was "figure it out for me", and we can't.
- Auto confirmation gate: after PAC resolves to a URL, show it and ask
[Y/N]before proceeding. Preserves the transparency of the old flow, where the resolved proxy was always printed. --removeflag stays: scripted/non-interactive teardown must not require a TTY. The interactive Remove branch is a convenience over the flag, not a replacement.- Sibling script, not branching: Negotiate logic goes in a new
setup-proxy-negotiate.shrather than branching insidesetup-proxy.sh. Keeps each script single-purpose (the existing script writes config files; the new one also installs packages and starts a service — three different kinds of work). - Marker file location:
/etc/wsl-manager/proxy-mode. System-wide (setup-proxy already writes root-owned files to/etc/apt/apt.conf.d/), survives user-home churn, explicit over auto-detecting by presence of~/.local/bin/px. - Stub the Negotiate path: emit "not yet implemented", exit code 10, so later slices land as functional additions rather than behavior changes.
Acceptance Criteria:
-
Install-WslProxyprompts upfront:[A]uto / [M]anual / [R]emove - Auto runs PAC detection, shows the resolved URL, and asks
[Y/N]to confirm before proceeding - Auto → PAC resolves to DIRECT: dispatches
setup-proxy.sh --remove(same path as Remove) - Auto → no PAC/AutoConfigURL in registry: throws with a hint to re-run and choose Manual
- Manual prompts for
host:portand proceeds to the auth-method prompt - Remove dispatches
setup-proxy.sh --removewith no auth-method or credential prompts -
--removeCLI flag continues to work for non-interactive teardown - Auth-method prompt
[B]asic / [N]egotiateis shown only after a proxy URL is resolved (never for Remove, never for Auto → DIRECT) - Basic path dispatches to existing
setup-proxy.shunchanged - Negotiate path dispatches to new
setup-proxy-negotiate.sh - New
setup-proxy-negotiate.shexists, accepts the same base args (--proxy-url,--no-proxy,--username), prints a clear "not yet implemented" message, and exits with code 10 - Basic mode writes
basicto/etc/wsl-manager/proxy-mode(creates the directory if missing) -
--removeinsetup-proxy.shdeletes/etc/wsl-manager/proxy-modeon successful teardown - Pester unit tests cover all three top-level branches (Auto/Manual/Remove) and the Auto sub-branches (URL confirm Y, URL confirm N, DIRECT, no PAC)
- Pester unit tests cover the auth-method prompt branch (mock the script invocation; assert correct script is called)
- All Y/N confirmation prompts use the
utils.ps1Y/N helper so that Enter is accepted as the default answer - Credential prompt (
Do you want to provide proxy credentials?) defaults to Yes — corporate proxies almost always require authentication - All existing tests continue to pass
-
docs/wsl-manager.mdupdated: Step 4 walkthrough, Setup Proxy command reference, and module structure reflect the new [A/M/R] flow, auth-method prompt, andsetup-proxy-negotiate.sh - UAT procedure below executed on a corporate WSL distro; all steps pass
UAT Procedure (run on a WSL distro with the feature branch checked out):
- Auto — happy path:
wsl-manager setup-proxy→A→ confirm detected URL withY→ authB→ credentials as usual. Expect:/etc/wsl-manager/proxy-modecontainsbasic; proxy configured. - Auto — reject detected URL:
A→Nat the confirm prompt. Expect: throws with hint mentioningRe-runandManual; no files changed. - Auto — no PAC (run off VPN or on a network without PAC):
A. Expect: throws withNo PAC/AutoConfigURL detected in registry. Re-run setup-proxy and choose [M]anual. - Manual:
M→ enterproxy.corp.com:8080. Expect: no PAC probe (feels instant), then auth/credentials prompts as before. - Remove (interactive):
R. Expect: no auth or credential prompts;setup-proxy.sh --removeruns;/etc/wsl-manager/proxy-modeis deleted. - Invalid input: enter
X(or just Enter). Expect: throws withInvalid choice 'X'. Expected [A]uto, [M]anual, or [R]emove. - Negotiate stub:
A→Y→N. Expect: "not yet implemented" message, exit code 10. -
--removeflag (non-interactive):wsl-manager setup-proxy --remove. Expect: no prompts; teardown runs; marker deleted. - Regression: after a fresh Basic setup, confirm
.profile,/etc/apt/apt.conf.d/99proxy,~/.docker/config.json, and~/.config/containers/containers.confall get the proxy config as before. - Credential prompt default:
M→ enter host:port → authB→ press Enter at the credential prompt. Expect: prompt accepts Enter as Yes and proceeds to ask for username/password.
UAT Issues:
General — Y/N prompts do not accept Enter as default: AllResolved: switched all prompts to the[Y/N]confirmation prompts require an explicit key press; pressing Enter is not accepted.utils.ps1Y/N helper.