test: add local 2x2 route topology
This commit is contained in:
@@ -125,10 +125,14 @@ class QBittorrentReader:
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
)
|
||||
try:
|
||||
response = self._read(self._opener.open(call, timeout=self.timeout), 64)
|
||||
login_response = self._opener.open(call, timeout=self.timeout)
|
||||
login_status = getattr(login_response, "status", 200)
|
||||
response = self._read(login_response, 64)
|
||||
except (error.URLError, OSError) as exc:
|
||||
raise QBittorrentError("qBittorrent authentication failed") from exc
|
||||
if response.strip() != b"Ok.":
|
||||
if response.strip() != b"Ok." and not (
|
||||
login_status == 204 and not response.strip()
|
||||
):
|
||||
raise QBittorrentError("qBittorrent authentication failed")
|
||||
self._authenticated = True
|
||||
|
||||
|
||||
@@ -55,7 +55,12 @@ def probe_qbittorrent(
|
||||
method="POST",
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
)
|
||||
if _read(opener.open(login, timeout=timeout)).strip() != "Ok.":
|
||||
login_response = opener.open(login, timeout=timeout)
|
||||
login_status = getattr(login_response, "status", 200)
|
||||
login_body = _read(login_response).strip()
|
||||
if login_body != "Ok." and not (
|
||||
login_status == 204 and not login_body
|
||||
):
|
||||
raise PermissionError("qBittorrent authentication failed")
|
||||
version = _text_get(opener, config.endpoint, "/api/v2/app/version", timeout)
|
||||
api_version = _text_get(
|
||||
|
||||
@@ -325,6 +325,13 @@ def _ack_name(nonce_owner: str, observer: str) -> str:
|
||||
|
||||
def _atomic_json(path: Path, value: dict[str, Any]) -> None:
|
||||
encoded = json.dumps(value, sort_keys=True, separators=(",", ":"))
|
||||
try:
|
||||
if path.read_text(encoding="utf-8") == encoded:
|
||||
return
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except (OSError, UnicodeError) as exc:
|
||||
raise RouteSetupError("route verification file is unreadable") from exc
|
||||
temporary = path.with_name(
|
||||
f".{path.name}.{os.getpid()}.{uuid.uuid4().hex}.tmp"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user