change: give the provider imports shared structure (#23) #138
Loading…
Reference in a new issue
No description provided.
Delete branch "change/provider-base-class"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
#23: the four provider import routines duplicate one skeleton — allow-list IPs, fetch, parse, copy_certs, emit — with drifted error handling (~7 hand-rolled
remove_temp_dir+failed.emitpairs) and dispatch viagetattr(self, self.provider.lower())(), conflating a provider's display name with its type everywhere. #33's SRP work needs auth to be a strategy on one provider, and the recorded entry model — (display name, provider type, credentials, server list) — needs the name≠type split to become cheap now rather than retrofitted later.Fix
Six commits, each standing alone:
PROVIDERSregistry; bodies moved verbatim, thread keeps the signals, temp dir and file helpers (also the tests' stubbing seams).import_servers()becomes the base template — allow API access,fetch(), the two anticipated failures (AuthFailure,RequestException), copy certs, emit. Message strings unchanged (template tests now pin them byte-exactly).CustomProvidervia the registry fallback; its no-API path overridesimport_serverswhole.typein the credentials dict (D-Busa{ss}unchanged) defaulting to the name; dispatch, copy_certs' supported branch and the config-template lookup key off type; payloads and server entries gain atypefield and drop the hardcoded provider literals; service timestamp/airvpn_key persistence follows the type. One-entry-per-type installs behave identically.config.PROVIDER_TYPESbecomes the single source for the type list + gui metadata (credential placeholders, needs_key); gui placeholder map and bothprovider == "Airvpn"key-field checks become lookups; the cli's own drifted list literal dies.aqomui/providers/<type>.pyper provider, base + shared helpers + registry in the package root. update.py keeps AddServers and the thread-side file helpers (~180 lines); adding a provider is now adding a file, and #33's SRP lands in providers/protonvpn.py next to its only consumer.Deliberately still name-keyed for 0.9.2 (the future multi-entry issue's follow-through): gui purge-on-reimport check, auto-update queue, provider combo,
change_ovpn_config, the cli flow, and{type}_lasttimestamp granularity.Verification
pytest— 329 passed (12 new: template error handling ×2, Airvpn single-emission, name≠type entry, registry/config consistency, plus the 36 characterization tests from #135 passing with only two mechanical seam adaptations).ruff+ compileall gates clean. Diffed the&-message format strings against trunk: the per-provider literals collapse into the two template strings; runtime output pinned identical by tests. Live gui check still to do viapackaging/arch/build-branch-and-install.sh: a custom .ovpn import (Windscribe live testing is deferred until that provider is actively supported; Proton stays broken until #33).Related fixes (found along the way, technically out of scope)
&-less "Sorry, something went wrong" that the gui parses as a success token (tries to open it as a filename). Airvpn now reports network failures once through the template; unexpected errors fall to GuardedThread's standard message. (The gui-side parser fragility is filed separately.)AuthFailure.🤖 Generated with Claude Code
5b5c80f3da3bdc83440d