diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28d99c1..bd7b23c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,60 @@ name: CI workflow_dispatch: jobs: + gtk: + # Issue #86 : suite complète AVEC l'interface GTK4, sous Xvfb (les tests + # test_gui_* se sautent sur le runner maison, sans PyGObject). Sa mesure + # de couverture est combinée à celle du job Qualité, qui applique le seuil. + name: Tests GTK4 (Xvfb, couverture) + runs-on: ubuntu-latest + + steps: + - name: Checkout du dépôt + uses: actions/checkout@v7 + + - name: Dépendances système (GTK4, introspection, Xvfb, D-Bus, GVfs) + # libgirepository-2.0-dev + libcairo2-dev + pkg-config : compilation + # de PyGObject/pycairo dans le venv ; gvfs + dbus : reproduction réelle + # de tests/test_gvfs_env_workaround.py (sinon sauté). + run: | + sudo apt-get update + sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \ + gir1.2-gtk-4.0 libgirepository-2.0-dev libcairo2-dev pkg-config \ + xvfb xauth dbus dbus-x11 gvfs iproute2 + + - name: Installation de uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + enable-cache: true + + - name: Installation de Python + run: uv python install + + - name: Installation des dépendances (dev + quality + gtk-test) + run: uv sync --group quality --group gtk-test + + - name: Tests sous Xvfb (pytest + couverture) + env: + COVERAGE_FILE: .coverage.gtk + run: xvfb-run -a uv run --group quality --group gtk-test coverage run -m pytest -q -rs + + - name: Publication de la mesure (artifact) + uses: actions/upload-artifact@v4 + with: + name: coverage-gtk + path: .coverage.gtk + include-hidden-files: true + retention-days: 7 + if-no-files-found: error + quality: name: Qualité (lint, format, tests) + # Seul check requis sur dev : il attend le job gtk pour appliquer le seuil + # à la mesure combinée. `!cancelled()` : il s'exécute (et échoue, faute + # d'artifact) même si gtk échoue — un job requis « skipped » passerait + # la protection de branche. + needs: gtk + if: ${{ !cancelled() }} runs-on: ${{ fromJSON(vars.RUNS_ON_LINUX || '{"group":"maison","labels":["self-hosted","linux"]}') }} steps: @@ -43,12 +95,22 @@ jobs: - name: Tests (pytest + couverture) # Les tests GTK4 se sautent proprement si PyGObject n'est pas - # installé (tests/conftest.py::require_gtk4) ; `ip` (iproute2) est - # présent par défaut sur ubuntu-latest et installé ci-dessus sinon. + # installé (tests/conftest.py::require_gtk4) : ils tournent dans le + # job gtk. `ip` (iproute2) est installé ci-dessus si absent. + env: + COVERAGE_FILE: .coverage.qualite run: uv run --group quality coverage run -m pytest -q - - name: Rapport de couverture + - name: Mesure du job gtk + uses: actions/download-artifact@v4 + with: + name: coverage-gtk + + - name: Couverture combinée et seuil (lu dans pyproject.toml) + # fail_under déclaré une seule fois dans pyproject.toml ; échoue si + # la mesure du job gtk manque (job gtk en échec). run: | + uv run --group quality coverage combine .coverage.qualite .coverage.gtk uv run --group quality coverage report -m uv run --group quality coverage xml diff --git a/.gitignore b/.gitignore index c40bcef..201e519 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__/ .pytest_cache/ .ruff_cache/ .coverage +.coverage.* # switch_capture.log et ses variantes horodatées : générés à l'exécution # (CLI/tests), retrouvés par erreur dans plusieurs livraisons avant ce diff --git a/pyproject.toml b/pyproject.toml index 9d9bb3e..47d5e8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,6 +91,15 @@ quality = [ "ruff>=0.16.7", "coverage>=7.10.7", ] +# Tests de l'interface GTK4 sous Xvfb (job `gtk` de ci.yml, issue #86) : +# PyGObject compilé dans le venv contre les bibliothèques système +# (libgirepository-2.0-dev, libcairo2-dev, gir1.2-gtk-4.0). Groupe de TEST +# seulement : en usage normal, PyGObject reste le paquet système (voir le +# commentaire « PyGObject » des dépendances ci-dessus). Invocation : +# `uv run --group quality --group gtk-test xvfb-run -a coverage run -m pytest -q`. +gtk-test = [ + "PyGObject>=3.42", +] [tool.ruff] line-length = 120 @@ -111,3 +120,17 @@ testpaths = ["tests"] [tool.coverage.run] source = ["src"] +# Couverture des branches obligatoire (SOCLE §4, Mathilde-Team/.github#9). +branch = true +# Chemins relatifs : les mesures du job Qualité (runner maison) et du job +# `gtk` (ubuntu-latest, Xvfb) sont combinées par `coverage combine` malgré +# des répertoires de travail différents (issue #86). +relative_files = true + +[tool.coverage.report] +# Seuil bloquant de l'équipe (décision du 21/10/2026, Mathilde-Team/.github#9), +# sur la mesure combinée job Qualité + job gtk (interface GTK4 sous Xvfb, +# issue #86). Déclaré ici seulement, appliqué par `coverage report` dans le +# job Qualité (seul check requis sur dev). +fail_under = 95 +show_missing = true diff --git a/src/switch_capture_core.py b/src/switch_capture_core.py index bd7c568..ae36cd9 100644 --- a/src/switch_capture_core.py +++ b/src/switch_capture_core.py @@ -2957,9 +2957,10 @@ def _run_capture_blocking_local(self) -> None: """ logger.debug("_run_capture_blocking_local() appelée") conn = connect_switch(self.cfg) - - delete_remote_all_file_capture(conn, self.cfg.capture_prefix) try: + # Dans le try (issue #86) : un échec du nettoyage (session coupée, + # suppression refusée) ne doit pas laisser la session SSH ouverte. + delete_remote_all_file_capture(conn, self.cfg.capture_prefix) filter_clause = build_capture_filter( self.cfg.switch_ip, self.cfg.capture_filter, self.cfg.hide_capture_traffic ) diff --git a/tests/test_capture_threads_complements.py b/tests/test_capture_threads_complements.py new file mode 100644 index 0000000..39eb967 --- /dev/null +++ b/tests/test_capture_threads_complements.py @@ -0,0 +1,453 @@ +"""Tests de la capture et de la rotation des fichiers (issue #86). + +`SetupAndCaptureThread` : capture locale (`packet-capture … write flash:`) +et RPCAP dans leur propre session SSH, montage sshfs, push de la feature +par sshfs. `CaptureRotationThread` : boucle `run()`, mode FIFO sur un +**vrai FIFO nommé** lu par un vrai lecteur, rapatriement SCP et sshfs (vrai +dossier de flash), nettoyage. + +Remplacés seulement : le switch (session netmiko simulée, SCP), Wireshark +(`subprocess.Popen`), l'interface TAP (root requis) et `time.sleep` du +module (pour arrêter les boucles après quelques tours, sans attendre). +""" + +from __future__ import annotations + +import os +import struct +import threading +import time +from pathlib import Path + +import pytest +from test_setup_and_capture_thread import FakeConn, make_config +from test_tap_pacing import write_synthetic_pcap + +import switch_capture_core as core +from switch_capture_core import CaptureRotationThread, SetupAndCaptureThread, SharedState + +DIR_TROIS_FICHIERS = """Directory of flash: + 1 -rw- 1024 Oct 22 2026 10:00:00 capture_00001_20261022100000.pcap + 2 -rw- 1024 Oct 22 2026 10:01:00 capture_00002_20261022100100.pcap + 3 -rw- 512 Oct 22 2026 10:02:00 capture_00003_20261022100200.pcap + +1046512 KB total (1045000 KB free)""" + + +class CanalSimule(FakeConn): + """FakeConn + canal brut (`write_channel`/`read_channel`) de la capture locale.""" + + def __init__(self, *args, lectures: list[str] | None = None, **kwargs) -> None: + super().__init__(*args, **kwargs) + self.ecrit: list[str] = [] + self.lectures = list(lectures or []) + + def write_channel(self, data: str) -> None: + self.ecrit.append(data) + + def read_channel(self) -> str: + return self.lectures.pop(0) if self.lectures else "" + + +def _arret_apres(monkeypatch, state: SharedState, tours: int) -> list[float]: + """Remplace `time.sleep` du module : positionne stop_event après `tours` appels.""" + attentes: list[float] = [] + + class Temps: + @staticmethod + def sleep(secondes: float) -> None: + attentes.append(secondes) + if len(attentes) >= tours: + state.stop_event.set() + + def __getattr__(self, nom: str): + return getattr(time, nom) + + monkeypatch.setattr(core, "time", Temps()) + return attentes + + +def _pcap(chemin: Path, *trames: bytes) -> bytes: + write_synthetic_pcap(chemin, [(1_700_000_000 + i, t) for i, t in enumerate(trames)]) + return chemin.read_bytes() + + +# ───────────────────────────── SetupAndCaptureThread ───────────────────────────── + + +class TestCaptureLocale: + def test_commande_nettoyage_lecture_puis_ctrl_c(self, monkeypatch) -> None: + state = SharedState() + conn = CanalSimule({"dir flash:/capture*.pcap": DIR_TROIS_FICHIERS}, lectures=["", "Capturing on GE1/0/1"]) + monkeypatch.setattr(core, "connect_switch", lambda cfg: conn) + attentes = _arret_apres(monkeypatch, state, tours=3) + cfg = make_config(rotation_seconds=60, max_ring_files=4, capture_direction="outbound") + SetupAndCaptureThread(cfg, state)._run_capture_blocking() + + # fichiers d'une capture précédente supprimés avant de relancer + assert conn.timing_commands[:3] == [ + f"delete flash:/capture_0000{i}_2026102210{i - 1:02d}00.pcap" for i in (1, 2, 3) + ] + commande, ctrl_c = conn.ecrit + assert commande.startswith("packet-capture interface GigabitEthernet1/0/1 outbound capture-filter ") + assert commande.endswith( + "limit-captured-frames 0 capture-ring-buffer duration 60 " + "capture-ring-buffer files 4 write flash:/capture.pcap\n" + ) + assert 'capture-filter "' in commande # trafic de la capture masqué par défaut + assert ctrl_c == "\x03" + assert attentes == [1, 1, 1, 2] and conn.disconnected + + def test_session_fermee_si_le_nettoyage_echoue(self, monkeypatch) -> None: + class SuppressionRefusee(CanalSimule): + def send_command_timing(self, cmd, read_timeout=15): + raise OSError("session SSH coupée") + + conn = SuppressionRefusee({"dir flash:/": DIR_TROIS_FICHIERS}) + monkeypatch.setattr(core, "connect_switch", lambda cfg: conn) + with pytest.raises(OSError, match="session SSH coupée"): + SetupAndCaptureThread(make_config(), SharedState())._run_capture_blocking_local() + assert conn.disconnected + assert conn.ecrit == [] # aucune capture lancée + + +class TestCaptureRpcap: + def test_demarrage_attente_et_arret(self, monkeypatch) -> None: + state = SharedState() + conn = CanalSimule() + monkeypatch.setattr(core, "connect_switch", lambda cfg: conn) + _arret_apres(monkeypatch, state, tours=2) + cfg = make_config(output_mode="rpcap", rpcap_port=2010, capture_direction="inbound") + SetupAndCaptureThread(cfg, state)._run_capture_blocking() + assert conn.timing_commands == [ + "packet-capture remote interface GigabitEthernet1/0/1 port 2010", # inbound : aucun mot-clé + "packet-capture stop", + ] + assert conn.ecrit == [] and conn.disconnected + + def test_session_fermee_si_le_switch_refuse(self, monkeypatch) -> None: + class Refus(CanalSimule): + def send_command_timing(self, cmd, read_timeout=15): + raise ValueError("% Unrecognized command") + + conn = Refus() + monkeypatch.setattr(core, "connect_switch", lambda cfg: conn) + with pytest.raises(ValueError): + SetupAndCaptureThread(make_config(output_mode="rpcap"), SharedState())._run_rpcap_blocking() + assert conn.disconnected + + +class TestSshfs: + def test_montage_lance_sshfs(self, tmp_path: Path, monkeypatch) -> None: + commandes = [] + monkeypatch.setattr(core.subprocess, "run", lambda cmd, check: commandes.append((cmd, check))) + monkeypatch.setattr(SetupAndCaptureThread, "_is_mounted", staticmethod(lambda path: False)) + mnt = tmp_path / "mnt" / "switch" + SetupAndCaptureThread(make_config(mount_point=str(mnt)), SharedState())._mount_sshfs() + assert mnt.is_dir() + assert commandes == [ + ( + ["sshfs", "mathilde@10.0.0.1:/", str(mnt), "-o", "reconnect", "-o", "ServerAliveInterval=15", + "-o", "ServerAliveCountMax=3"], + True, + ) + ] # fmt: skip + + def test_deja_monte(self, tmp_path: Path, monkeypatch) -> None: + monkeypatch.setattr(core.subprocess, "run", lambda *a, **k: pytest.fail("sshfs relancé")) + monkeypatch.setattr(SetupAndCaptureThread, "_is_mounted", staticmethod(lambda path: True)) + SetupAndCaptureThread(make_config(mount_point=str(tmp_path)), SharedState())._mount_sshfs() + + @pytest.mark.skipif(not Path("/usr/bin/mountpoint").exists() and not Path("/bin/mountpoint").exists(), + reason="mountpoint (util-linux) absent") # fmt: skip + def test_is_mounted_reel(self, tmp_path: Path) -> None: + assert SetupAndCaptureThread._is_mounted(tmp_path) is False + assert SetupAndCaptureThread._is_mounted(Path("/proc")) is True + + def test_push_feature_par_sshfs(self, tmp_path: Path, monkeypatch) -> None: + binaire = tmp_path / "feature.bin" + binaire.write_bytes(b"\x7fELF-feature") + (tmp_path / "mnt" / "flash").mkdir(parents=True) + montages = [] + cfg = make_config( + transfer_mode="sshfs", + mount_point=str(tmp_path / "mnt"), + feature_bin_path=str(binaire), + ) + thread = SetupAndCaptureThread(cfg, SharedState()) + monkeypatch.setattr(thread, "_mount_sshfs", lambda: montages.append(True)) + thread._push_feature_file() + assert montages == [True] + assert (tmp_path / "mnt" / "flash" / "feature.bin").read_bytes() == b"\x7fELF-feature" + + +# ───────────────────────────── CaptureRotationThread ───────────────────────────── + + +def _rotation(tmp_path: Path, **options) -> CaptureRotationThread: + base = {"output_mode": "fifo", "spool_dir": str(tmp_path / "spool"), "fifo_path": str(tmp_path / "live")} + base.update(options) + return CaptureRotationThread(make_config(**base), SharedState()) + + +class _Lecteur(threading.Thread): + """Vrai lecteur du FIFO (rôle de Wireshark) : lit jusqu'à la fermeture côté écriture.""" + + def __init__(self, chemin: Path) -> None: + super().__init__(daemon=True) + self.chemin, self.recu = chemin, b"" + + def run(self) -> None: + with open(self.chemin, "rb") as fifo: + self.recu = fifo.read() + + +class TestModeFifo: + def test_flux_live_reel(self, tmp_path: Path, monkeypatch) -> None: + lances = [] + monkeypatch.setattr(core.subprocess, "Popen", lambda cmd: lances.append(cmd)) + rotation = _rotation(tmp_path, archive_dir=str(tmp_path / "archive"), archive_as_pcapng=False) + rotation.fifo_path.write_text("fichier ordinaire resté d'une session précédente") + rotation._setup_fifo() + assert rotation.fifo_path.is_fifo() + + lecteur = _Lecteur(rotation.fifo_path) + lecteur.start() + rotation._launch_wireshark() # bloque jusqu'à l'ouverture côté lecture + assert lances == [["wireshark", "-k", "-i", str(rotation.fifo_path)]] + + premier = _pcap(rotation.spool_dir / "a.pcap", b"\x01" * 60) + second = _pcap(rotation.spool_dir / "b.pcap", b"\x02" * 70, b"\x03" * 80) + rotation._dispatch_for_injection(rotation.spool_dir / "a.pcap") + rotation._dispatch_for_injection(rotation.spool_dir / "b.pcap") + rotation._cleanup() + lecteur.join(timeout=5) + + # en-tête global une seule fois, puis les enregistrements des deux fichiers + assert lecteur.recu == premier + second[core.PCAP_GLOBAL_HEADER_LEN :] + assert rotation.state.files_merged == 2 + assert rotation.state.bytes_merged == len(premier) + len(second) + assert rotation.state.last_file_name == "b.pcap" + assert sorted(p.name for p in (tmp_path / "archive").iterdir()) == ["a.pcap", "b.pcap"] + assert not rotation.fifo_path.exists() + + def test_sans_archive_le_fichier_est_supprime(self, tmp_path: Path) -> None: + rotation = _rotation(tmp_path) + lecture, ecriture = os.pipe() + rotation._fifo_fd = os.fdopen(ecriture, "wb", buffering=0) + _pcap(rotation.spool_dir / "a.pcap", b"\x01" * 10) + rotation._feed_into_fifo(rotation.spool_dir / "a.pcap") + rotation._fifo_fd.close() + with os.fdopen(lecture, "rb") as flux: + assert len(flux.read()) == core.PCAP_GLOBAL_HEADER_LEN + 16 + 10 + assert not (rotation.spool_dir / "a.pcap").exists() + + @pytest.mark.parametrize( + "contenu", + [ + pytest.param(b"\xd4\xc3", id="trop-petit"), + pytest.param(struct.pack(" None: + rotation = _rotation(tmp_path) + rotation._fifo_fd = open(os.devnull, "wb") # noqa: SIM115 - fermé ci-dessous + fichier = rotation.spool_dir / "x.pcap" + fichier.write_bytes(contenu) + rotation._feed_into_fifo(fichier) + rotation._fifo_fd.close() + assert fichier.exists() and rotation.state.files_merged == 0 + + def test_fifo_pas_pret(self, tmp_path: Path) -> None: + rotation = _rotation(tmp_path) + _pcap(rotation.spool_dir / "a.pcap", b"\x01") + rotation._feed_into_fifo(rotation.spool_dir / "a.pcap") + assert rotation.state.files_merged == 0 and (rotation.spool_dir / "a.pcap").exists() + + def test_nettoyage_tolere_les_erreurs(self, tmp_path: Path, monkeypatch) -> None: + class Echec: + def close(self): + raise OSError("déjà fermé") + + def disconnect(self): + raise OSError("session perdue") + + rotation = _rotation(tmp_path) + rotation._setup_fifo() + rotation._fifo_fd = rotation._poll_conn = Echec() + monkeypatch.setattr(Path, "unlink", lambda self, missing_ok=False: (_ for _ in ()).throw(PermissionError())) + rotation._cleanup() + monkeypatch.undo() + assert rotation.fifo_path.exists() # suppression refusée, sans exception + + +class TestModeTap: + def test_writer_absent(self, tmp_path: Path) -> None: + rotation = _rotation(tmp_path, output_mode="tap", tap_interface="vcap0") + _pcap(rotation.spool_dir / "a.pcap", b"\x01") + rotation._feed_into_tap(rotation.spool_dir / "a.pcap") + assert rotation.state.files_merged == 0 + + def test_archive_apres_injection(self, tmp_path: Path) -> None: + from test_tap_injector_thread import FakeTapWriter + + rotation = _rotation(tmp_path, output_mode="tap", tap_interface="vcap0", archive_dir=str(tmp_path / "arch")) + rotation._tap_writer = FakeTapWriter() + _pcap(rotation.spool_dir / "a.pcap", b"\x01" * 60) + rotation._feed_into_tap(rotation.spool_dir / "a.pcap") + assert rotation._tap_writer.written == [b"\x01" * 60] + assert [p.name for p in (tmp_path / "arch").iterdir()] == ["a.pcapng"] + + +class TestRapatriementScp: + @pytest.fixture + def rotation(self, tmp_path: Path, monkeypatch): + rotation = _rotation(tmp_path) + rotation._poll_conn = FakeConn({"dir flash:/capture*.pcap": DIR_TROIS_FICHIERS}) + self.injectes: list[str] = [] + self.clients: list[str] = [] + monkeypatch.setattr(rotation, "_dispatch_for_injection", lambda chemin: self.injectes.append(chemin.name)) + + class Client: + def close(client): + self.clients.append("fermé") + + def scp_get(client, distant, local, progress_callback): + local.write_bytes(b"pcap de " + distant.encode()) + progress_callback(distant.encode(), 8, 8) # signature de la bibliothèque scp + + monkeypatch.setattr(core, "open_scp_ssh_client", lambda cfg: Client()) + monkeypatch.setattr(core, "scp_get", scp_get) + return rotation + + def test_fichiers_clotures_rapatries_supprimes_injectes(self, rotation) -> None: + rotation._poll_once() + attendus = ["capture_00001_20261022100000.pcap", "capture_00002_20261022100100.pcap"] + assert self.injectes == attendus # le dernier, en cours d'écriture, n'est pas touché + assert rotation._poll_conn.timing_commands == [f"delete flash:/{f}" for f in attendus] + assert self.clients == ["fermé", "fermé"] # une connexion SCP par fichier + assert (rotation.spool_dir / attendus[0]).read_bytes() == b"pcap de " + attendus[0].encode() + assert rotation.state.scp_progress.name == attendus[1] + + def test_un_seul_fichier_rien_a_faire(self, rotation) -> None: + rotation._poll_conn.responses = {"dir": " 1 -rw- 512 Oct 22 2026 10:02:00 capture_1.pcap"} + rotation._poll_once_scp() + assert self.injectes == [] and self.clients == [] + + def test_liste_en_echec(self, rotation, monkeypatch) -> None: + monkeypatch.setattr(core, "list_remote_pcap_files", lambda conn, prefix: (_ for _ in ()).throw(EOFError())) + rotation._poll_once_scp() + assert self.injectes == [] + + def test_connexion_scp_en_echec(self, rotation, monkeypatch) -> None: + monkeypatch.setattr(core, "open_scp_ssh_client", lambda cfg: (_ for _ in ()).throw(TimeoutError())) + rotation._poll_once_scp() + assert self.injectes == [] and rotation._poll_conn.timing_commands == [] + + def test_transfert_en_echec_ni_suppression_ni_injection(self, rotation, monkeypatch) -> None: + monkeypatch.setattr(core, "scp_get", lambda *a, **k: (_ for _ in ()).throw(OSError("Bad file descriptor"))) + rotation._poll_once_scp() + assert self.injectes == [] and rotation._poll_conn.timing_commands == [] + assert self.clients == ["fermé", "fermé"] + + def test_fermeture_et_suppression_en_echec_non_bloquantes(self, rotation, monkeypatch) -> None: + class ClientCasse: + def close(self): + raise OSError("transport mort") + + monkeypatch.setattr(core, "open_scp_ssh_client", lambda cfg: ClientCasse()) + monkeypatch.setattr(core, "delete_remote_file", lambda conn, f: (_ for _ in ()).throw(OSError("flash occupée"))) + rotation._poll_once_scp() + assert len(self.injectes) == 2 + + +class TestRapatriementSshfs: + @pytest.fixture + def rotation(self, tmp_path: Path, monkeypatch): + flash = tmp_path / "mnt" / "flash" + flash.mkdir(parents=True) + for nom in ("capture_1.pcap", "capture_2.pcap", "capture_3.pcap", "autre_9.pcap"): + (flash / nom).write_bytes(nom.encode()) + rotation = _rotation(tmp_path, transfer_mode="sshfs", mount_point=str(tmp_path / "mnt")) + self.flash, self.injectes = flash, [] + monkeypatch.setattr(rotation, "_dispatch_for_injection", lambda chemin: self.injectes.append(chemin.name)) + return rotation + + def test_copie_suppression_injection(self, rotation) -> None: + rotation._poll_once() + assert self.injectes == ["capture_1.pcap", "capture_2.pcap"] + assert sorted(p.name for p in self.flash.iterdir()) == ["autre_9.pcap", "capture_3.pcap"] + assert (rotation.spool_dir / "capture_1.pcap").read_bytes() == b"capture_1.pcap" + + def test_montage_inaccessible(self, rotation, monkeypatch) -> None: + monkeypatch.setattr(Path, "glob", lambda self, motif: (_ for _ in ()).throw(FileNotFoundError())) + rotation._poll_once_sshfs() + assert self.injectes == [] + + def test_copie_en_echec(self, rotation, monkeypatch) -> None: + monkeypatch.setattr(core.shutil, "copy", lambda a, b: (_ for _ in ()).throw(OSError("sshfs déconnecté"))) + rotation._poll_once_sshfs() + assert self.injectes == [] and len(list(self.flash.iterdir())) == 4 + + def test_suppression_en_echec_non_bloquante(self, rotation, monkeypatch) -> None: + vrai_unlink = Path.unlink + + def unlink(self, missing_ok=False): + if self.parent.name == "flash": + raise PermissionError(self) + return vrai_unlink(self, missing_ok=missing_ok) + + monkeypatch.setattr(Path, "unlink", unlink) + rotation._poll_once_sshfs() + assert self.injectes == ["capture_1.pcap", "capture_2.pcap"] + + +class TestBoucleRun: + def test_arret_avant_le_debut_de_capture(self, tmp_path: Path, monkeypatch) -> None: + rotation = _rotation(tmp_path) + rotation.state.capture_started.set() + rotation.state.stop_event.set() + monkeypatch.setattr(rotation, "_setup_fifo", lambda: pytest.fail("FIFO créé après l'arrêt")) + rotation.run() + + def test_tap_scp_metadonnees_en_echec_puis_arret(self, tmp_path: Path, monkeypatch) -> None: + from test_tap_injector_thread import FakeTapWriter + + evenements: list[str] = [] + writer = FakeTapWriter() + conn = FakeConn({"dir": ""}) + monkeypatch.setattr(core, "ensure_tap_interface", lambda nom: evenements.append(f"tap {nom}")) + monkeypatch.setattr(core, "delete_tap_interface", lambda nom: evenements.append(f"suppression {nom}")) + monkeypatch.setattr(core, "TapFrameWriter", lambda nom: writer) + monkeypatch.setattr(core.subprocess, "Popen", lambda cmd: evenements.append(" ".join(cmd))) + monkeypatch.setattr(core, "connect_switch", lambda cfg: conn) + + def metadonnees(cfg, state): + raise OSError("disque plein") + + monkeypatch.setattr(core, "write_capture_metadata", metadonnees) + rotation = _rotation( + tmp_path, output_mode="tap", tap_interface="vcap7", tap_launch_wireshark=True, tap_cleanup_on_stop=True + ) + rotation.state.capture_started.set() + attentes = _arret_apres(monkeypatch, rotation.state, tours=2) + rotation.run() + + assert evenements == ["tap vcap7", "wireshark -k -i vcap7", "suppression vcap7"] + assert conn.sent_commands == ["dir flash:/capture*.pcap"] * 2 + assert attentes == [rotation.cfg.poll_interval] * 2 + assert conn.disconnected and writer.closed + assert not rotation._injector_thread.is_alive() + + def test_fifo_sshfs(self, tmp_path: Path, monkeypatch) -> None: + rotation = _rotation(tmp_path, transfer_mode="sshfs", mount_point=str(tmp_path / "mnt")) + etapes: list[str] = [] + monkeypatch.setattr(rotation, "_setup_fifo", lambda: etapes.append("fifo")) + monkeypatch.setattr(rotation, "_launch_wireshark", lambda: etapes.append("wireshark")) + monkeypatch.setattr(core, "write_capture_metadata", lambda cfg, state: etapes.append("métadonnées")) + monkeypatch.setattr(core, "connect_switch", lambda cfg: pytest.fail("pas de session SSH en sshfs")) + rotation.state.capture_started.set() + _arret_apres(monkeypatch, rotation.state, tours=1) + rotation.run() + assert etapes == ["fifo", "wireshark", "métadonnées"] + assert rotation._poll_conn is None diff --git a/tests/test_gui_sessions_actions.py b/tests/test_gui_sessions_actions.py new file mode 100644 index 0000000..7cb8a82 --- /dev/null +++ b/tests/test_gui_sessions_actions.py @@ -0,0 +1,531 @@ +"""Tests GTK4 des actions de la fenêtre principale (issue #86). + +Sessions (ajout, modification, suppression, inspection, test de connexion), +mémorisation du mot de passe, installation, démarrage et arrêt, journal, +résultats, modèles de formulaire et fermeture — sur une vraie +`CaptureWindow` (Xvfb), avec de vrais `Gtk.ListBox`. + +Seuls les effets de bord externes sont remplacés : connexion SSH au switch +(`connect_switch`, `inspect_switch`), threads de capture/installation, et +`threading.Thread`/`GLib.idle_add` du module GTK rendus synchrones pour que +chaque test observe le résultat sans boucle d'évènements. Même politique de +saut que les autres `test_gui_*` (pas de PyGObject ou pas d'affichage). +""" + +from __future__ import annotations + +import types +from pathlib import Path +from typing import ClassVar + +import pytest +from conftest import require_gtk4 + +gi = require_gtk4() + +from gi.repository import GLib, Gtk +from test_model_detection import VERSION_5130EI + +import switch_capture_core as core +import switch_capture_gtk as gtk_app + + +class _ThreadSynchrone: + """Remplace `threading.Thread` du module GTK : `start()` exécute la cible tout de suite.""" + + lances: ClassVar[list[str]] = [] + + def __init__(self, target=None, daemon=None, name=None, args=(), kwargs=None) -> None: + self._target, self._args, self._kwargs, self.name = target, args, kwargs or {}, name + + def start(self) -> None: + _ThreadSynchrone.lances.append(self.name or "") + self._target(*self._args, **self._kwargs) + + +class _GLibIdleImmediat: + """Vrai GLib, sauf `idle_add` qui exécute la fonction tout de suite.""" + + @staticmethod + def idle_add(fonction, *args): + fonction(*args) + + def __getattr__(self, nom: str): + return getattr(GLib, nom) + + +@pytest.fixture +def win(tmp_path, monkeypatch): + monkeypatch.setattr(gtk_app, "DEFAULT_PREFS_CONFIG_PATH", str(tmp_path / "config.yaml")) + app = Gtk.Application(application_id="org.transcende.switch_capture.tests.sessions") + holder: dict = {} + + def on_activate(a): + try: + holder["win"] = gtk_app.CaptureWindow(a) + except RuntimeError as exc: + holder["error"] = exc + a.quit() + + app.connect("activate", on_activate) + app.run([]) + if "error" in holder: + pytest.skip(f"pas d'affichage graphique disponible : {holder['error']}") + fenetre = holder["win"] + + _ThreadSynchrone.lances = [] + monkeypatch.setattr(gtk_app, "threading", types.SimpleNamespace(Thread=_ThreadSynchrone)) + monkeypatch.setattr(gtk_app, "GLib", _GLibIdleImmediat()) + fenetre.dialogues = [] + monkeypatch.setattr(fenetre, "_show_dialog", lambda titre, corps: fenetre.dialogues.append((titre, corps))) + return fenetre + + +def _remplir(win, switch_ip: str = "10.0.0.1") -> None: + win._entries["switch_ip"].set_text(switch_ip) + win._entries["ssh_user"].set_text("mathilde") + win._entries["ssh_password"].set_text("secret") + win._entries["capture_interface"].set_text("GigabitEthernet1/0/1") + + +def _textes(listbox: Gtk.ListBox) -> list[str]: + """Libellés de chaque ligne d'un Gtk.ListBox (hors boutons), joints par « | ».""" + lignes = [] + ligne = listbox.get_first_child() + while ligne is not None: + morceaux = [] + pile = [ligne] + while pile: + widget = pile.pop() + if isinstance(widget, Gtk.Label): + morceaux.append(widget.get_label()) + if isinstance(widget, Gtk.Button): + continue + enfant = widget.get_last_child() + while enfant is not None: + pile.append(enfant) + enfant = enfant.get_prev_sibling() + lignes.append(" | ".join(morceaux)) + ligne = ligne.get_next_sibling() + return lignes + + +def _boutons(listbox: Gtk.ListBox, rang: int) -> dict[str, Gtk.Button]: + ligne = listbox.get_row_at_index(rang) + boite = ligne.get_child() + boutons = {} + enfant = boite.get_first_child() + while enfant is not None: + if isinstance(enfant, Gtk.Button): + boutons[enfant.get_label()] = enfant + enfant = enfant.get_next_sibling() + return boutons + + +def _ajouter(win, switch_ip: str = "10.0.0.1"): + _remplir(win, switch_ip) + win._on_add_session(None) + return win._sessions[-1] + + +# ───────────────────────────── sessions ───────────────────────────── + + +class TestSessions: + def test_liste_vide_puis_ajout(self, win) -> None: + win._refresh_sessions_list() + assert _textes(win._sessions_list) == ["Aucune capture ajoutée pour l'instant."] + session = _ajouter(win) + assert _textes(win._sessions_list) == [session.label] + assert win._journal_status.get_label() == f"Capture ajoutée : {session.label}" + assert set(_boutons(win._sessions_list, 0)) == { + "Inspecter (dry run)", + "Désinstaller la feature", + "Modifier", + "Supprimer", + } + + def test_ajout_formulaire_incomplet(self, win) -> None: + win._on_add_session(None) + assert win._sessions == [] + assert win.dialogues[0][0] == "Configuration incomplète" + + def test_supprimer_par_le_bouton(self, win) -> None: + _ajouter(win) + _boutons(win._sessions_list, 0)["Supprimer"].emit("clicked") + assert win._sessions == [] + assert _textes(win._sessions_list) == ["Aucune capture ajoutée pour l'instant."] + + def test_supprimer_une_session_deja_retiree(self, win) -> None: + session = _ajouter(win) + win._sessions.clear() + win._on_remove_session(None, session) + assert win._sessions == [] + + def test_modifier_recharge_le_formulaire(self, win) -> None: + session = _ajouter(win, "10.0.0.9") + _remplir(win, "192.0.2.1") + win._entries["ssh_password"].set_text("") + _boutons(win._sessions_list, 0)["Modifier"].emit("clicked") + assert win._sessions == [] + assert win._entries["switch_ip"].get_text() == "10.0.0.9" + assert win._entries["ssh_password"].get_text() == "secret" + assert win._stack.get_visible_child_name() == "config" + assert win._prefs["slot"] == session.cfg.slot + assert "chargée dans le formulaire" in win._journal_status.get_label() + + def test_modifier_ignore_une_capture_en_cours(self, win) -> None: + session = _ajouter(win) + session.capture_running = True + win._refresh_sessions_list() + assert _boutons(win._sessions_list, 0)["Modifier"].get_sensitive() is False + win._on_edit_session(None, session) + assert win._sessions == [session] + + @pytest.mark.parametrize("deja_retiree", [False, True]) + def test_modifier_session_absente_de_la_liste(self, win, deja_retiree: bool) -> None: + session = _ajouter(win) + if deja_retiree: + win._sessions.clear() + win._on_edit_session(None, session) + assert win._sessions == [] + + +class TestInspectionEtTestConnexion: + def test_inspection_reussie(self, win, monkeypatch) -> None: + session = _ajouter(win) + vus = [] + monkeypatch.setattr(gtk_app, "inspect_switch", lambda cfg: vus.append(cfg) or {"rapport": 1}) + monkeypatch.setattr(gtk_app, "format_inspect_report", lambda ip, mode, rapport: f"{ip}/{mode}/{rapport}") + _boutons(win._sessions_list, 0)["Inspecter (dry run)"].emit("clicked") + assert vus[0].switch_ip == "10.0.0.1" and vus[0].ssh_password == "secret" + assert win.dialogues == [("Inspection de 10.0.0.1", f"10.0.0.1/{session.cfg.transfer_mode}/{{'rapport': 1}}")] + assert win._journal_status.get_label() == f"Inspection terminée pour {session.label}" + assert _ThreadSynchrone.lances == [f"inspect-{session.id}"] + + def test_inspection_en_echec(self, win, monkeypatch) -> None: + session = _ajouter(win) + + def panne(cfg): + raise ConnectionError("switch injoignable") + + monkeypatch.setattr(gtk_app, "inspect_switch", panne) + win._on_inspect_session(None, session) + assert win.dialogues == [("Échec de l'inspection", "switch injoignable")] + assert win._journal_status.get_label() == f"Inspection en échec pour {session.label} : switch injoignable" + + def test_connexion_reussie_modele_et_version(self, win, monkeypatch) -> None: + commandes, fermetures = [], [] + + class Connexion: + def send_command(self, commande): + commandes.append(commande) + return VERSION_5130EI + + def disconnect(self): + fermetures.append(True) + + monkeypatch.setattr(core, "connect_switch", lambda cfg: Connexion()) + _remplir(win) + win._on_test_connection(None) + assert commandes == ["display version"] and fermetures == [True] + titre, message = win.dialogues[0] + assert titre == "Connexion réussie" + assert message == "Connexion OK — modèle détecté : 5130EI, version : 6555P05" + + def test_connexion_modele_inconnu(self, win, monkeypatch) -> None: + class Connexion: + def send_command(self, commande): + return "rien d'identifiable" + + def disconnect(self): + pass + + monkeypatch.setattr(core, "connect_switch", lambda cfg: Connexion()) + _remplir(win) + win._on_test_connection(None) + assert win.dialogues == [("Connexion réussie", "Connexion OK — modèle détecté : non reconnu, version : ?")] + + def test_connexion_deconnecte_meme_si_la_commande_echoue(self, win, monkeypatch) -> None: + fermetures = [] + + class Connexion: + def send_command(self, commande): + raise TimeoutError("pas de réponse") + + def disconnect(self): + fermetures.append(True) + + monkeypatch.setattr(core, "connect_switch", lambda cfg: Connexion()) + _remplir(win) + win._on_test_connection(None) + assert fermetures == [True] + assert win.dialogues == [("Échec de la connexion", "pas de réponse")] + + def test_connexion_formulaire_incomplet(self, win) -> None: + win._on_test_connection(None) + assert win.dialogues[0][0] == "Configuration incomplète" + assert _ThreadSynchrone.lances == [] + + +class TestMemorisationMotDePasse: + def test_case_non_cochee(self, win, monkeypatch) -> None: + monkeypatch.setattr(gtk_app, "save_ssh_password_to_keyring", lambda *a: pytest.fail("ne doit pas mémoriser")) + _ajouter(win) + assert _ThreadSynchrone.lances == [] + + def test_trousseau(self, win, monkeypatch) -> None: + enregistres = [] + monkeypatch.setattr(gtk_app, "KEYRING_AVAILABLE", True) + monkeypatch.setattr(gtk_app, "save_ssh_password_to_keyring", lambda *a: enregistres.append(a)) + win._entries["remember_password"].set_active(True) + _ajouter(win) + assert enregistres == [("10.0.0.1", "mathilde", "secret")] + assert win.dialogues == [] + + def test_trousseau_verrouille_signale(self, win, monkeypatch) -> None: + def verrouille(*a): + raise RuntimeError("trousseau verrouillé") + + monkeypatch.setattr(gtk_app, "KEYRING_AVAILABLE", True) + monkeypatch.setattr(gtk_app, "save_ssh_password_to_keyring", verrouille) + win._entries["remember_password"].set_active(True) + _ajouter(win) + assert win.dialogues == [("Échec de la mémorisation", "trousseau verrouillé")] + + def test_keepass_en_echec_signale(self, win, monkeypatch) -> None: + def illisible(*a): + raise RuntimeError("mot de passe maître incorrect") + + monkeypatch.setattr(gtk_app, "KEYRING_AVAILABLE", False) + monkeypatch.setattr(gtk_app, "KEEPASS_AVAILABLE", True) + monkeypatch.setenv("SWITCH_CAPTURE_KEEPASS_PASSWORD", "maitre") + monkeypatch.setattr(gtk_app, "save_ssh_password_to_keepass", illisible) + win._prefs["keepass_path"] = "/tmp/base.kdbx" + win._entries["remember_password"].set_active(True) + _ajouter(win) + assert win.dialogues == [("Échec de la mémorisation (KeePass)", "mot de passe maître incorrect")] + + +# ─────────────────────── installation, démarrage, arrêt ─────────────────────── + + +class _Setup: + def __init__(self, erreur: Exception | None = None, vivant: bool = False) -> None: + self.erreur, self.vivant, self.prepares, self.captures = erreur, vivant, 0, 0 + + def prepare(self) -> None: + self.prepares += 1 + if self.erreur: + raise self.erreur + + def start_capture_blocking(self) -> None: + self.captures += 1 + + def is_alive(self) -> bool: + return self.vivant + + +class TestInstallationDemarrageArret: + def test_installation_reussie_et_en_echec(self, win) -> None: + ok, ko = _ajouter(win, "10.0.0.1"), _ajouter(win, "10.0.0.2") + ok.setup, ko.setup = _Setup(), _Setup(RuntimeError("flash pleine")) + win._on_install_all(None) + assert (ok.install_status, ko.install_status) == ("ok", "failed") + assert ko.install_error == "flash pleine" + lignes = _textes(win._install_list) + assert lignes[1].endswith("(flash pleine)") + assert win._btn_start_all.get_sensitive() is False # une capture n'est pas prête + + def test_rien_a_installer(self, win) -> None: + win._on_install_all(None) + assert win.dialogues[0][0] == "Rien à installer" + session = _ajouter(win) + session.install_status = "ok" + win._on_install_all(None) + assert [t for t, _ in win.dialogues] == ["Rien à installer", "Rien à installer"] + + def test_installation_refusee_pendant_une_capture(self, win) -> None: + session = _ajouter(win) + session.capture_running = True + win._on_install_all(None) + assert win.dialogues[0][0] == "Installation impossible" + assert session.label in win.dialogues[0][1] + + def test_demarrer_toutes(self, win, monkeypatch) -> None: + rotations = [] + + class Rotation: + def __init__(self, cfg, state): + rotations.append(cfg.switch_ip) + + def start(self): + pass + + def is_alive(self): + return False + + monkeypatch.setattr(gtk_app, "CaptureRotationThread", Rotation) + fichier, rpcap = _ajouter(win, "10.0.0.1"), _ajouter(win, "10.0.0.2") + rpcap.cfg.output_mode = "rpcap" + for session in (fichier, rpcap): + session.setup, session.install_status = _Setup(), "ok" + win._refresh_start_list() + assert win._btn_start_all.get_sensitive() is True + win._on_start_all(None) + assert rotations == ["10.0.0.1"] # pas de rotation de fichiers en rpcap + assert rpcap.rotation is None + assert fichier.setup.captures == rpcap.setup.captures == 1 + assert fichier.capture_running and rpcap.capture_running + assert win._journal_status.get_label() == "2 capture(s) démarrée(s)." + assert win._stack.get_visible_child_name() == "journal" + assert win._btn_start_all.get_sensitive() is False + assert all(texte.endswith("en cours") for texte in _textes(win._start_list)) + + def test_demarrer_sans_capture_prete(self, win) -> None: + _ajouter(win) + win._on_start_all(None) + assert win._sessions[0].capture_running is False + + def test_arreter(self, win) -> None: + win._on_stop_all(None) + assert win._journal_status.get_label() == "Aucune capture en cours à arrêter." + active, inactive = _ajouter(win, "10.0.0.1"), _ajouter(win, "10.0.0.2") + active.capture_running = True + win._on_stop_all(None) + assert active.state.stop_event.is_set() and not inactive.state.stop_event.is_set() + assert win._journal_status.get_label() == "Arrêt de 1 capture(s) en cours ..." + + def test_fermeture_arrete_les_captures_et_les_preferences(self, win) -> None: + session = _ajouter(win) + session.capture_running = True + detruites = [] + win._prefs_window = types.SimpleNamespace(destroy=lambda: detruites.append(True)) + assert win._on_close_request(win) is False + assert session.state.stop_event.is_set() and detruites == [True] + assert win._prefs_window is None + + +class TestJournalEtResultats: + def test_journal_progression_et_fin_de_capture(self, win) -> None: + fichier, rpcap, finie = _ajouter(win, "10.0.0.1"), _ajouter(win, "10.0.0.2"), _ajouter(win, "10.0.0.3") + rpcap.cfg.output_mode = "rpcap" + fichier.setup, rpcap.setup, finie.setup = _Setup(vivant=True), _Setup(vivant=True), _Setup(vivant=False) + for session in (fichier, rpcap, finie): + session.capture_running = True + fichier.state.files_merged, fichier.state.bytes_merged = 3, 2048 + fichier.state.scp_progress = core.ScpProgress("push", "cap_1.pcap", 50, 512, 1024) + assert win._refresh_journal() is True + lignes = _textes(win._progress_list) + assert len(lignes) == 3 + assert "en cours — 3 fichier(s), 2.0 Ko — " in lignes[0] + assert lignes[0].endswith("— SCP cap_1.pcap : 50 % (512 o / 1.0 Ko)") + assert "en cours — streaming réseau direct (rpcap)" in lignes[1] + assert "arrêtée" in lignes[2] + assert finie.capture_running is False # thread terminé : la session repasse à l'arrêt + win._refresh_journal() + assert len(_textes(win._progress_list)) == 2 + + def test_journal_rotation_encore_active(self, win) -> None: + session = _ajouter(win) + session.setup = _Setup(vivant=False) + session.rotation = types.SimpleNamespace(is_alive=lambda: True) + session.capture_running = True + win._refresh_journal() + assert "en cours" in _textes(win._progress_list)[0] and session.capture_running + + def test_resultats(self, win, tmp_path: Path, monkeypatch) -> None: + spool, archive = tmp_path / "spool", tmp_path / "archive" + spool.mkdir() + archive.mkdir() + (spool / "b.pcap").write_bytes(b"x" * 1024) + (archive / "a.pcap").write_bytes(b"x" * 2048) + (archive / "ignore.txt").write_text("pas un pcap") + win._refresh_results() + assert win._results_summary.get_label() == "Aucun fichier .pcap trouvé pour l'instant." + session = _ajouter(win) + session.cfg.spool_dir, session.cfg.archive_dir = str(spool), str(archive) + session.cfg.capture_label = "" + _ajouter(win, "10.0.0.2").cfg.spool_dir = str(tmp_path / "absent") + win._refresh_results() + assert win._results_summary.get_label() == "2 fichier(s), 3.0 Ko au total" + assert _textes(win._results_list) == [ + "[10.0.0.1/Spool] | b.pcap | 1.0 Ko", + "[10.0.0.1/Archive] | a.pcap | 2.0 Ko", + ] + + def test_resultats_fichier_disparu(self, win, tmp_path: Path, monkeypatch) -> None: + spool = tmp_path / "spool" + spool.mkdir() + (spool / "disparu.pcap").write_bytes(b"x") + session = _ajouter(win) + session.cfg.spool_dir, session.cfg.archive_dir = str(spool), "" + vrai_stat = Path.stat + + def stat(self, *args, **kwargs): + if self.name == "disparu.pcap": + raise FileNotFoundError(self) + return vrai_stat(self, *args, **kwargs) + + monkeypatch.setattr(Path, "stat", stat) + win._refresh_results() + assert win._results_summary.get_label() == "Aucun fichier .pcap trouvé pour l'instant." + + +# ───────────────────────────── modèles de formulaire ───────────────────────────── + + +@pytest.fixture +def formulaire(monkeypatch, tmp_path): + """Remplace `_open_form_dialog` : mémorise les widgets et la fonction de réponse.""" + monkeypatch.setattr(gtk_app, "DEFAULT_MODELS_DIR", str(tmp_path / "models")) + ouvert: dict = {} + + def ouvrir(parent, titre, texte, widgets, annuler, valider, on_response): + ouvert.update(titre=titre, widgets=widgets, repondre=on_response) + + monkeypatch.setattr(gtk_app, "_open_form_dialog", ouvrir) + return ouvert + + +class TestModeles: + def test_enregistrer_puis_importer(self, win, formulaire) -> None: + _remplir(win, "10.0.0.7") + win._on_save_template(None) + assert formulaire["titre"] == "Enregistrer comme modèle" + formulaire["widgets"][0].set_text("labo") + formulaire["repondre"](True) + assert win._journal_status.get_label().startswith("Modèle enregistré : ") + assert "secret" not in (Path(gtk_app.DEFAULT_MODELS_DIR) / "labo.yaml").read_text() + + _remplir(win, "192.0.2.1") + win._on_load_template(None) + assert formulaire["titre"] == "Importer un modèle" + formulaire["repondre"](True) + assert win._entries["switch_ip"].get_text() == "10.0.0.7" + assert win._journal_status.get_label() == "Modèle « labo » importé dans le formulaire." + + def test_enregistrer_annule_ou_nom_invalide(self, win, formulaire) -> None: + win._on_save_template(None) + formulaire["repondre"](False) + assert not Path(gtk_app.DEFAULT_MODELS_DIR).exists() + formulaire["widgets"][0].set_text("../hors-du-dossier") + formulaire["repondre"](True) + assert win.dialogues[0][0] == "Échec de l'enregistrement" + + def test_importer_sans_modele(self, win, formulaire) -> None: + win._on_load_template(None) + assert win.dialogues[0][0] == "Aucun modèle" + assert "titre" not in formulaire + + def test_importer_annule_ou_fichier_disparu(self, win, formulaire) -> None: + _remplir(win, "10.0.0.7") + win._on_save_template(None) + formulaire["widgets"][0].set_text("labo") + formulaire["repondre"](True) + win._on_load_template(None) + formulaire["repondre"](False) + assert win._entries["switch_ip"].get_text() == "10.0.0.7" + (Path(gtk_app.DEFAULT_MODELS_DIR) / "labo.yaml").unlink() + formulaire["repondre"](True) + assert win.dialogues[0][0] == "Échec de l'import" diff --git a/tests/test_gvfs_env_workaround.py b/tests/test_gvfs_env_workaround.py index 3e78280..69294d7 100644 --- a/tests/test_gvfs_env_workaround.py +++ b/tests/test_gvfs_env_workaround.py @@ -198,8 +198,6 @@ def test_warning_present_without_workaround_absent_with(self): import shutil if not shutil.which("Xvfb") or not shutil.which("dbus-daemon"): - import pytest - pytest.skip("Xvfb ou dbus-daemon absent de cet environnement") gi_probe = subprocess.run( @@ -208,10 +206,16 @@ def test_warning_present_without_workaround_absent_with(self): check=False, ) if gi_probe.returncode != 0: - import pytest - pytest.skip("GTK4/PyGObject indisponibles dans cet environnement") + # L'avertissement vient du moniteur de volumes distants de GVfs : sans + # moniteur installé (paquet gvfs absent, cas des conteneurs et des + # runners CI), il ne peut pas se produire et l'assertion « présent sans + # le contournement » n'aurait pas de sens (issue #86). + moniteurs = Path("/usr/share/gvfs/remote-volume-monitors") + if not any(moniteurs.glob("*.monitor")): + pytest.skip(f"GVfs absent ({moniteurs} sans *.monitor) : avertissement impossible à reproduire") + script = r""" import faulthandler, sys faulthandler.enable() @@ -245,10 +249,18 @@ def on_response(dlg, response): """ import time - display = ":97" - xvfb = subprocess.Popen(["Xvfb", display, "-screen", "0", "1280x1024x24"]) + # Affichage libre choisi par Xvfb (`-displayfd`) plutôt qu'un numéro + # fixe déjà pris sur certaines machines ; la lecture bloque jusqu'à ce + # que le serveur soit prêt. + lecture, ecriture = os.pipe() + xvfb = subprocess.Popen( + ["Xvfb", "-displayfd", str(ecriture), "-screen", "0", "1280x1024x24", "-nolisten", "tcp"], + pass_fds=(ecriture,), + ) + os.close(ecriture) try: - time.sleep(1) + with os.fdopen(lecture) as flux: + display = ":" + flux.readline().strip() dbus_out = subprocess.run( ["dbus-daemon", "--session", "--print-address=1", "--print-pid=1", "--fork"], capture_output=True, @@ -280,10 +292,15 @@ def run_with(vfs_env: dict[str, str]) -> str: xvfb.terminate() xvfb.wait(timeout=5) - assert "GVFS-RemoteVolumeMonitor" in stderr_without, ( - "avertissement GVfs attendu absent sans le contournement (environnement " - f"peut-être trop différent de celui de reproduction) — stderr : {stderr_without!r}" - ) assert "GVFS-RemoteVolumeMonitor" not in stderr_with, ( f"avertissement GVfs toujours présent malgré le contournement — stderr : {stderr_with!r}" ) + # Condition préalable, pas résultat : même avec GVfs installé, + # l'avertissement dépend de la version de GVfs et de la session D-Bus + # (reproduit sous Ubuntu 26.04, absent sous Ubuntu 24.04 du job gtk, + # issue #86). Sans reproduction, le test ne prouve rien : il se saute. + if "GVFS-RemoteVolumeMonitor" not in stderr_without: + pytest.skip( + "avertissement GVfs non reproduit sans le contournement dans cet environnement " + f"(stderr : {stderr_without!r})" + ) diff --git a/tests/test_setup_and_capture_thread.py b/tests/test_setup_and_capture_thread.py index 3d83bfa..e579a58 100644 --- a/tests/test_setup_and_capture_thread.py +++ b/tests/test_setup_and_capture_thread.py @@ -8,10 +8,10 @@ service de transfert, NTP, push+activation de la feature) et le garde-fou de `start_capture_blocking()`. La capture elle-même (`_run_capture_blocking_local`/`_run_rpcap_blocking`, qui délèguent à -`CaptureRotationThread`/Wireshark/FIFO/TAP) reste hors périmètre : elle est -déjà couverte ailleurs par ses propres fichiers de tests dédiés -(`test_tap_pacing.py`, `test_tap_injector_thread.py`, etc.) et nécessiterait -ici une duplication de mocks sans valeur ajoutée. +`CaptureRotationThread`/Wireshark/FIFO/TAP) est testée dans +`test_capture_threads_complements.py` (issue #86), avec les doublures de +ce fichier ; `test_tap_pacing.py` et `test_tap_injector_thread.py` ne +couvrent que la réinjection TAP. Même principe que `test_inspect.py` (FakeConn sans switch réel) et `test_scp_transfer.py` (mock des globals `open_scp_ssh_client`/`scp_put`) — diff --git a/uv.lock b/uv.lock index 71c4a90..4328cef 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 5 requires-python = ">=3.9" resolution-markers = [ "python_full_version >= '3.14'", @@ -30,7 +30,7 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "cffi", version = "2.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, + { name = "cffi", version = "2.0.0", source = { registry = "https://pypi.org/simple" } }, ] sdist = { url = "https://files.pythonhosted.org/packages/5c/2d/db8af0df73c1cf454f71b2bbe5e356b8c1f8041c979f505b3d3186e520a9/argon2_cffi_bindings-25.1.0.tar.gz", hash = "sha256:b957f3e6ea4d55d820e40ff76f450952807013d361a65d7f28acc0acbf29229d", size = 1783441, upload-time = "2025-07-30T10:02:05.147Z" } wheels = [ @@ -70,7 +70,7 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "cffi", version = "2.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, + { name = "cffi", version = "2.1.1", source = { registry = "https://pypi.org/simple" } }, ] sdist = { url = "https://files.pythonhosted.org/packages/0b/43/bb8b6e8708d49a5ab36781333af092d9f483b198a2710d01281204640055/argon2_cffi_bindings-26.1.0.tar.gz", hash = "sha256:63505c71542a44b68b1e38060450fb006404170da375feb31af153e7f9c6205d", size = 1790807, upload-time = "2026-08-20T07:44:22.492Z" } wheels = [ @@ -204,7 +204,7 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "pycparser", version = "2.23", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10' and implementation_name != 'PyPy'" }, + { name = "pycparser", version = "2.23", source = { registry = "https://pypi.org/simple" }, marker = "implementation_name != 'PyPy'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/eb/56/b1ba7935a17738ae8453301356628e8147c79dbb825bcbc73dc7401f9846/cffi-2.0.0.tar.gz", hash = "sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529", size = 523588, upload-time = "2025-09-08T23:24:04.541Z" } wheels = [ @@ -302,7 +302,7 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "pycparser", version = "3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10' and implementation_name != 'PyPy'" }, + { name = "pycparser", version = "3.0", source = { registry = "https://pypi.org/simple" }, marker = "implementation_name != 'PyPy'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be", size = 530807, upload-time = "2026-08-03T21:21:18.939Z" } wheels = [ @@ -680,8 +680,8 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "cffi", version = "2.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version <= '3.9' and platform_python_implementation != 'PyPy'" }, - { name = "typing-extensions", marker = "python_full_version <= '3.9'" }, + { name = "cffi", version = "2.0.0", source = { registry = "https://pypi.org/simple" }, marker = "platform_python_implementation != 'PyPy'" }, + { name = "typing-extensions" }, ] sdist = { url = "https://files.pythonhosted.org/packages/ef/b2/7ffa7fe8207a8c42147ffe70c3e360b228160c1d85dc3faff16aaa3244c0/cryptography-47.0.0.tar.gz", hash = "sha256:9f8e55fe4e63613a5e1cc5819030f27b97742d720203a087802ce4ce9ceb52bb", size = 830863, upload-time = "2026-04-24T19:54:57.056Z" } wheels = [ @@ -745,9 +745,9 @@ resolution-markers = [ "python_full_version > '3.9' and python_full_version < '3.10'", ] dependencies = [ - { name = "cffi", version = "2.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version > '3.9' and python_full_version < '3.10' and platform_python_implementation != 'PyPy'" }, + { name = "cffi", version = "2.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10' and platform_python_implementation != 'PyPy'" }, { name = "cffi", version = "2.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10' and platform_python_implementation != 'PyPy'" }, - { name = "typing-extensions", marker = "python_full_version > '3.9' and python_full_version < '3.11'" }, + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/bb/ad/5d6702db60b1e40b41ef513b6967ff5848f307d50f8449baf1634f5908f1/cryptography-50.0.1.tar.gz", hash = "sha256:5dd9bda1c12b4162f6ff568eeb5e0ff956c28d14406e875cfe8a63a2d414ff20", size = 880381, upload-time = "2026-08-25T19:45:45.499Z" } wheels = [ @@ -803,7 +803,7 @@ name = "exceptiongroup" version = "1.3.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "typing-extensions", marker = "python_full_version < '3.13'" }, + { name = "typing-extensions" }, ] sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" } wheels = [ @@ -819,7 +819,7 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "zipp", version = "3.23.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, + { name = "zipp", version = "3.23.1", source = { registry = "https://pypi.org/simple" } }, ] sdist = { url = "https://files.pythonhosted.org/packages/f3/49/3b30cad09e7771a4982d9975a8cbf64f00d4a1ececb53297f1d9a7be1b10/importlib_metadata-8.7.1.tar.gz", hash = "sha256:49fef1ae6440c182052f407c8d34a68f72efc36db9ca90dc0113398f2fdde8bb", size = 57107, upload-time = "2025-12-21T10:00:19.278Z" } wheels = [ @@ -835,7 +835,7 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "zipp", version = "4.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, + { name = "zipp", version = "4.1.0", source = { registry = "https://pypi.org/simple" } }, ] sdist = { url = "https://files.pythonhosted.org/packages/6f/7e/1e7e8dc30634b93ebb3d58a3dea569ad146e656218d3960ab04f62047b29/importlib_metadata-9.0.1.tar.gz", hash = "sha256:ab830580bc0ef3db61ce8fae716389e5462b67e033018bab6d8f80ef17172f99", size = 59124, upload-time = "2026-08-28T15:30:34.646Z" } wheels = [ @@ -899,7 +899,7 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "backports-tarfile", marker = "python_full_version < '3.10'" }, + { name = "backports-tarfile" }, ] sdist = { url = "https://files.pythonhosted.org/packages/27/7b/c3081ff1af947915503121c649f26a778e1a2101fd525f74aef997d75b7e/jaraco_context-6.1.1.tar.gz", hash = "sha256:bc046b2dc94f1e5532bd02402684414575cc11f565d929b6563125deb0a6e581", size = 15832, upload-time = "2026-03-07T15:46:04.63Z" } wheels = [ @@ -915,7 +915,7 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "backports-tarfile", marker = "python_full_version >= '3.10' and python_full_version < '3.12'" }, + { name = "backports-tarfile", marker = "python_full_version < '3.12'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/af/50/4763cd07e722bb6285316d390a164bc7e479db9d90daa769f22578f698b4/jaraco_context-6.1.2.tar.gz", hash = "sha256:f1a6c9d391e661cc5b8d39861ff077a7dc24dc23833ccee564b234b81c82dfe3", size = 16801, upload-time = "2026-03-20T22:13:33.922Z" } wheels = [ @@ -931,7 +931,7 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "more-itertools", version = "10.8.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, + { name = "more-itertools", version = "10.8.0", source = { registry = "https://pypi.org/simple" } }, ] sdist = { url = "https://files.pythonhosted.org/packages/0f/27/056e0638a86749374d6f57d0b0db39f29509cce9313cf91bdc0ac4d91084/jaraco_functools-4.4.0.tar.gz", hash = "sha256:da21933b0417b89515562656547a77b4931f98176eb173644c0d35032a33d6bb", size = 19943, upload-time = "2025-12-21T09:29:43.6Z" } wheels = [ @@ -947,7 +947,7 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "more-itertools", version = "11.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, + { name = "more-itertools", version = "11.1.0", source = { registry = "https://pypi.org/simple" } }, ] sdist = { url = "https://files.pythonhosted.org/packages/6c/1f/c23395957d41ccf27c4e535c3d334c4051e5395b3752057ba4cbaec35c56/jaraco_functools-4.6.0.tar.gz", hash = "sha256:880c577ec9720b3a052d5bc611fb9f2269b3d87902ef42440df443b88e443280", size = 20837, upload-time = "2026-07-14T01:28:02.544Z" } wheels = [ @@ -1183,7 +1183,7 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "mdurl", marker = "python_full_version < '3.10'" }, + { name = "mdurl" }, ] sdist = { url = "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size = 74596, upload-time = "2023-06-03T06:41:14.443Z" } wheels = [ @@ -1199,7 +1199,7 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "mdurl", marker = "python_full_version >= '3.10'" }, + { name = "mdurl" }, ] sdist = { url = "https://files.pythonhosted.org/packages/06/ff/7841249c247aa650a76b9ee4bbaeae59370dc8bfd2f6c01f3630c35eb134/markdown_it_py-4.2.0.tar.gz", hash = "sha256:04a21681d6fbb623de53f6f364d352309d4094dd4194040a10fd51833e418d49", size = 82454, upload-time = "2026-05-07T12:08:28.36Z" } wheels = [ @@ -1250,14 +1250,14 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "ntc-templates", version = "8.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, - { name = "paramiko", marker = "python_full_version < '3.10'" }, - { name = "pyserial", marker = "python_full_version < '3.10'" }, - { name = "pyyaml", marker = "python_full_version < '3.10'" }, - { name = "rich", marker = "python_full_version < '3.10'" }, - { name = "ruamel-yaml", marker = "python_full_version < '3.10'" }, - { name = "scp", marker = "python_full_version < '3.10'" }, - { name = "textfsm", marker = "python_full_version < '3.10'" }, + { name = "ntc-templates", version = "8.1.0", source = { registry = "https://pypi.org/simple" } }, + { name = "paramiko" }, + { name = "pyserial" }, + { name = "pyyaml" }, + { name = "rich" }, + { name = "ruamel-yaml" }, + { name = "scp" }, + { name = "textfsm" }, ] sdist = { url = "https://files.pythonhosted.org/packages/df/0a/4d557ffd4070a47f87c3e07abd28f9fcbdbf799f2a62940168236b4a8d31/netmiko-4.6.0.tar.gz", hash = "sha256:9701bb2c1a15eb2e8074cb2e28ca007c69b9fa52961b83b98c757ead6b80deef", size = 169274, upload-time = "2025-06-26T19:13:17.303Z" } wheels = [ @@ -1273,14 +1273,14 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "ntc-templates", version = "9.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, - { name = "paramiko", marker = "python_full_version >= '3.10'" }, - { name = "pyserial", marker = "python_full_version >= '3.10'" }, - { name = "pyyaml", marker = "python_full_version >= '3.10'" }, - { name = "rich", marker = "python_full_version >= '3.10'" }, - { name = "ruamel-yaml", marker = "python_full_version >= '3.10'" }, - { name = "scp", marker = "python_full_version >= '3.10'" }, - { name = "textfsm", marker = "python_full_version >= '3.10'" }, + { name = "ntc-templates", version = "9.3.0", source = { registry = "https://pypi.org/simple" } }, + { name = "paramiko" }, + { name = "pyserial" }, + { name = "pyyaml" }, + { name = "rich" }, + { name = "ruamel-yaml" }, + { name = "scp" }, + { name = "textfsm" }, ] sdist = { url = "https://files.pythonhosted.org/packages/87/f7/28dc70a15f496635a9353726e7015d4819ed648a06f57f4b362176a57d51/netmiko-4.7.0.tar.gz", hash = "sha256:94cf7bfe5daed1d058444ce1637e10177df22f903683a53d1fbee47553488c65", size = 185674, upload-time = "2026-05-12T18:26:14.39Z" } wheels = [ @@ -1296,7 +1296,7 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "textfsm", marker = "python_full_version < '3.10'" }, + { name = "textfsm" }, ] sdist = { url = "https://files.pythonhosted.org/packages/d6/0c/decd784b5969ddfed7e41d95baaa309f31c896bd7ed22d3a6d29ec1117a1/ntc_templates-8.1.0.tar.gz", hash = "sha256:e570a5bb4ee829d62bfdce3fb46045a40aaa176b134aa0db21542d6518ca4be7", size = 313051, upload-time = "2025-09-22T21:02:55.83Z" } wheels = [ @@ -1312,7 +1312,7 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "textfsm", marker = "python_full_version >= '3.10'" }, + { name = "textfsm" }, ] sdist = { url = "https://files.pythonhosted.org/packages/63/0f/4f1e745d5871490e86d2ae9839b51486e1389d0c25b0dbbbd3f15853bd81/ntc_templates-9.3.0.tar.gz", hash = "sha256:2045d20839b5892152637b7c22893923c9a57b6c3e92771fc976f473d0fb05e3", size = 327538, upload-time = "2026-09-14T18:44:03.579Z" } wheels = [ @@ -1353,6 +1353,68 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, ] +[[package]] +name = "pycairo" +version = "1.28.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version > '3.9' and python_full_version < '3.10'", + "python_full_version <= '3.9'", +] +sdist = { url = "https://files.pythonhosted.org/packages/40/d9/412da520de9052b7e80bfc810ec10f5cb3dbfa4aa3e23c2820dc61cdb3d0/pycairo-1.28.0.tar.gz", hash = "sha256:26ec5c6126781eb167089a123919f87baa2740da2cca9098be8b3a6b91cc5fbc", size = 662477, upload-time = "2025-04-14T20:11:08.218Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3e/67/6e5d6328c6037f0479017f51e97f5cbb79a68ed6e93f671dac17cb47bf2e/pycairo-1.28.0-cp310-cp310-win32.whl", hash = "sha256:53e6dbc98456f789965dad49ef89ce2c62f9a10fc96c8d084e14da0ffb73d8a6", size = 750438, upload-time = "2025-04-14T20:10:43.722Z" }, + { url = "https://files.pythonhosted.org/packages/00/79/e941186c2275333643504f57711b157ba17e81a2be805346585ad7fd382e/pycairo-1.28.0-cp310-cp310-win_amd64.whl", hash = "sha256:c8ab91a75025f984bc327ada335c787efb61c929ea0512063793cb36cee503d4", size = 841526, upload-time = "2025-04-14T20:10:45.557Z" }, + { url = "https://files.pythonhosted.org/packages/84/4b/3495baabd3c830bf80bf112a0e645342bfe8f3fc05ed6423444adf62d496/pycairo-1.28.0-cp310-cp310-win_arm64.whl", hash = "sha256:e955328c1a5147bf71ee94e206413ce15e12630296a79788fcd246c80e5337b8", size = 691866, upload-time = "2025-04-16T19:30:17.73Z" }, + { url = "https://files.pythonhosted.org/packages/c9/94/47d75f4eaac865f32e0550ed42869f8b3c4036f8e2b1e6163e9548f4d44f/pycairo-1.28.0-cp311-cp311-win32.whl", hash = "sha256:0fee15f5d72b13ba5fd065860312493dc1bca6ff2dce200ee9d704e11c94e60a", size = 750441, upload-time = "2025-04-14T20:10:48.311Z" }, + { url = "https://files.pythonhosted.org/packages/aa/02/1169a2917b043998585f9dd0f36da618947fdf9b6cc0e9ff9852aa4d548b/pycairo-1.28.0-cp311-cp311-win_amd64.whl", hash = "sha256:6339979bfec8b58a06476094a9a5c104bd5a99932ddaff16ca0d9203d2f4482c", size = 841536, upload-time = "2025-04-14T20:10:51.112Z" }, + { url = "https://files.pythonhosted.org/packages/eb/99/13031086fb4d4ea71568d9ce74e03afbb2e18047f1e6b4e8674851f0414f/pycairo-1.28.0-cp311-cp311-win_arm64.whl", hash = "sha256:c6ae15392e28ebfc0b35d8dc05d395d3b6be4bad9ad4caecf0fa12c8e7150225", size = 691895, upload-time = "2025-04-16T19:30:20.724Z" }, + { url = "https://files.pythonhosted.org/packages/a9/d7/206d7945aac5c6c889e7fea4011410d1311455a1d8dfce66106d8d700b7f/pycairo-1.28.0-cp312-cp312-win32.whl", hash = "sha256:c00cfbb7f30eb7ca1d48886712932e2d91e8835a8496f4e423878296ceba573e", size = 750594, upload-time = "2025-04-14T20:10:53.72Z" }, + { url = "https://files.pythonhosted.org/packages/2e/ba/259fc9a4d3afdad1e5b9db52b9d8a5df67f70dd787167185e8ec8a1af007/pycairo-1.28.0-cp312-cp312-win_amd64.whl", hash = "sha256:d50d190f5033992b55050b9f337ee42a45c3568445d5e5d7987bab96c278d8a6", size = 841767, upload-time = "2025-04-14T20:10:56.711Z" }, + { url = "https://files.pythonhosted.org/packages/c0/08/aa0903612ea0e8686ad6af58d4fb9cbab8ee0b0831201cddf7abd578d045/pycairo-1.28.0-cp312-cp312-win_arm64.whl", hash = "sha256:957e0340ee1c279d197d4f7cfa96f6d8b48e453eec711fca999748d752468ff4", size = 691687, upload-time = "2025-04-16T19:30:23.729Z" }, + { url = "https://files.pythonhosted.org/packages/59/a7/c3e5ed55781dfe1b31eb4a2482aeae707671f3d36b0ea53a1722f4a3dfe9/pycairo-1.28.0-cp313-cp313-win32.whl", hash = "sha256:d13352429d8a08a1cb3607767d23d2fb32e4c4f9faa642155383980ec1478c24", size = 750594, upload-time = "2025-04-14T20:10:59.284Z" }, + { url = "https://files.pythonhosted.org/packages/8b/1c/ebadd290748aff3b6bc35431114d41e7a42f40a4b988c2aaf2dfed5d8156/pycairo-1.28.0-cp313-cp313-win_amd64.whl", hash = "sha256:082aef6b3a9dcc328fa648d38ed6b0a31c863e903ead57dd184b2e5f86790140", size = 841774, upload-time = "2025-04-14T20:11:01.79Z" }, + { url = "https://files.pythonhosted.org/packages/3e/ce/a3f5f1946613cd8a4654322b878c59f273c6e9b01dfadadd3f609070e0b9/pycairo-1.28.0-cp313-cp313-win_arm64.whl", hash = "sha256:026afd53b75291917a7412d9fe46dcfbaa0c028febd46ff1132d44a53ac2c8b6", size = 691675, upload-time = "2025-04-16T19:30:26.565Z" }, + { url = "https://files.pythonhosted.org/packages/96/1b/1f5da2b2e44b33a5b269ff28af710b0a7903001d9cf8a40d00fc944a5092/pycairo-1.28.0-cp314-cp314-win32.whl", hash = "sha256:d0ab30585f536101ad6f09052fc3895e2a437ba57531ea07223d0e076248025d", size = 766699, upload-time = "2025-07-24T06:36:07.267Z" }, + { url = "https://files.pythonhosted.org/packages/c9/91/1d5f18bd3ed469b1de8f83bfbf8bd67d23439f075151b66740fd35356190/pycairo-1.28.0-cp314-cp314-win_amd64.whl", hash = "sha256:94f2ed204999ab95a0671a0fa948ffbb9f3d6fb8731fe787917f6d022d9c1c0f", size = 868725, upload-time = "2025-07-24T06:36:09.597Z" }, + { url = "https://files.pythonhosted.org/packages/79/0e/476ffe64b309672aa4012897d91a2bda7e5b2eb43504bbff48be03e5055c/pycairo-1.28.0-cp39-cp39-win32.whl", hash = "sha256:3ed16d48b8a79cc584cb1cb0ad62dfb265f2dda6d6a19ef5aab181693e19c83c", size = 750680, upload-time = "2025-04-14T20:11:04.197Z" }, + { url = "https://files.pythonhosted.org/packages/f4/77/872e843993bb152f93e970f0807ee08b5a496116ad8eadfa0a1590452111/pycairo-1.28.0-cp39-cp39-win_amd64.whl", hash = "sha256:da0d1e6d4842eed4d52779222c6e43d254244a486ca9fdab14e30042fd5bdf28", size = 842157, upload-time = "2025-04-14T20:11:05.981Z" }, + { url = "https://files.pythonhosted.org/packages/a8/c5/fce33dbb973c5ee7606167056502a70eb316350c41c7656e5739a5f9e490/pycairo-1.28.0-cp39-cp39-win_arm64.whl", hash = "sha256:458877513eb2125513122e8aa9c938630e94bb0574f94f4fb5ab55eb23d6e9ac", size = 691902, upload-time = "2025-04-16T19:30:28.615Z" }, +] + +[[package]] +name = "pycairo" +version = "1.29.2" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.14'", + "python_full_version >= '3.10' and python_full_version < '3.14'", +] +sdist = { url = "https://files.pythonhosted.org/packages/bb/5e/19ab2572981a996ce96b853a189d2dcced40506b67d9555a7568457abcf2/pycairo-1.29.2.tar.gz", hash = "sha256:3e69fff74fe64f5ba2dfa31f67c6bdf26413342574047437d2ac520d35e9a489", size = 666308, upload-time = "2026-10-04T19:11:03.81Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2e/5f/0890d23d6ce884fa3f3ee93fa8be5e41588b152901ce88c5d5a84a0d9e7e/pycairo-1.29.2-cp310-cp310-win32.whl", hash = "sha256:edbe75fe4267bda95f3bec1fcb6e90cccf10e72a8e2645bd1b3431e9a75225ce", size = 751952, upload-time = "2026-10-04T19:11:21.224Z" }, + { url = "https://files.pythonhosted.org/packages/8b/5c/3072b9257b7fffa9ff3368bb94a22b549cefe7c0aafc2cf1c9285804bcc5/pycairo-1.29.2-cp310-cp310-win_amd64.whl", hash = "sha256:104dc796eaf9ae4194079e1948634cdc8b88088437e1fd8e997853d2e78407c6", size = 846572, upload-time = "2026-10-04T19:11:23.031Z" }, + { url = "https://files.pythonhosted.org/packages/d1/c2/9f5cce8e06f6e2526cd7c41e4e1bd03670e8b18b75531c1c4682e376874c/pycairo-1.29.2-cp310-cp310-win_arm64.whl", hash = "sha256:680a2bd4ab97d088483044774e8007ad7da109f0715df900f3bd328fe52c2e34", size = 695312, upload-time = "2026-10-04T19:11:24.977Z" }, + { url = "https://files.pythonhosted.org/packages/e0/ad/745fea890b749ef0a99068ffe51cdeb9182e91f84c9f8bf79dd3095471fc/pycairo-1.29.2-cp311-cp311-win32.whl", hash = "sha256:c66e08496678ba36d2d2aed2add1fade358b96c4842cb8b558c77ae01ca61fa7", size = 751962, upload-time = "2026-10-04T19:11:26.492Z" }, + { url = "https://files.pythonhosted.org/packages/2f/08/77eb56c6c441bda69bac6de4cc2e143a4559768a580da2820b4787ebfbeb/pycairo-1.29.2-cp311-cp311-win_amd64.whl", hash = "sha256:00cb8f7a343e6ab5a6a2d275184b511ed2132ef1bdcba03487283cdc01b593d2", size = 846544, upload-time = "2026-10-04T19:11:28.02Z" }, + { url = "https://files.pythonhosted.org/packages/2d/5e/07ea27f0d615b876420ce7b1039f882be1adf9f074b1459ab9ce060350fe/pycairo-1.29.2-cp311-cp311-win_arm64.whl", hash = "sha256:fc75fca130e8f9b3d1548b322b0b79b149f482478d1b70e771c66c4dfc654d4f", size = 695316, upload-time = "2026-10-04T19:11:29.645Z" }, + { url = "https://files.pythonhosted.org/packages/0f/be/5433f918a50238f848e7f6e4d9662331f4c556a01e2e8dc58945c2af440f/pycairo-1.29.2-cp312-cp312-win32.whl", hash = "sha256:75b1b6ff515b6bcb89e86c5f2bb4762c46f0fcbde6c444ea035c8fecd1bc8b55", size = 752061, upload-time = "2026-10-04T19:11:31.193Z" }, + { url = "https://files.pythonhosted.org/packages/7e/0e/1571890c2ab04a6e4b59758ffbeab3c141fe08f909fb0d2f6e8cacfbe47a/pycairo-1.29.2-cp312-cp312-win_amd64.whl", hash = "sha256:b97fd674dea445eae40387353f32665dbe19080a2ef63df97fd81273afc6e9d1", size = 846938, upload-time = "2026-10-04T19:11:32.717Z" }, + { url = "https://files.pythonhosted.org/packages/80/07/890c5d83d4f7d4972c496f6966c1257a46384fb93fbbfb8c207daea92e57/pycairo-1.29.2-cp312-cp312-win_arm64.whl", hash = "sha256:a9ed77de6f9ba148d493360d1b2a93be8a785c8ae855d4fd6e8df293ed58ddd8", size = 695598, upload-time = "2026-10-04T19:11:34.111Z" }, + { url = "https://files.pythonhosted.org/packages/03/e9/03a625a9da4f0f0f5cb9420b7e6419478363d27c91888d82717d38a224d2/pycairo-1.29.2-cp313-cp313-win32.whl", hash = "sha256:50c30f88fa12b722ac8f997b67f83f5ea8fad06bc1d6c33dbdab504eb9978e56", size = 751443, upload-time = "2026-10-04T19:11:35.895Z" }, + { url = "https://files.pythonhosted.org/packages/23/44/7f39568959f5b2997bb888728423aeab00617cf8844f8126ec9ddeee86c2/pycairo-1.29.2-cp313-cp313-win_amd64.whl", hash = "sha256:0b87aa05a50a2c8cf2489dffc1b12f88b6e2fe384075f8c799367625081ca3cd", size = 845293, upload-time = "2026-10-04T19:11:37.541Z" }, + { url = "https://files.pythonhosted.org/packages/8f/90/83ebe0ae1d66378306085c505e7bf7abd0060714695e303877c800ff6d5c/pycairo-1.29.2-cp313-cp313-win_arm64.whl", hash = "sha256:806cd0f1266776fb6e881ce322569f0439993d66df0eeb8a255b1316f947acd0", size = 694636, upload-time = "2026-10-04T19:11:39.185Z" }, + { url = "https://files.pythonhosted.org/packages/53/d4/48e4b327563beae41c5eabea70c4b8b9aec790361dec02c338d4e8e2ac21/pycairo-1.29.2-cp314-cp314-win32.whl", hash = "sha256:98360270afaa909bcc1769f299160123322da29d2a7310763b0ddc16e624d5c6", size = 767785, upload-time = "2026-10-04T19:11:43.794Z" }, + { url = "https://files.pythonhosted.org/packages/42/bf/9d9eb2d0780440b1b5fe916e6a3abfa11e05f750b0ad643987cb9c0761d2/pycairo-1.29.2-cp314-cp314-win_amd64.whl", hash = "sha256:786373ba1bd78fbdec02cb1c99254eef12438bf942dd13534fe61b948becb527", size = 872750, upload-time = "2026-10-04T19:11:45.545Z" }, + { url = "https://files.pythonhosted.org/packages/78/36/f785d5a974809f36247ee56d15ca135433d1bf3c2adf1eb8fd66150b6a5e/pycairo-1.29.2-cp314-cp314-win_arm64.whl", hash = "sha256:9bb09bca782b5e21a4beb698075b5504f234af0597920f0c0439979226a76182", size = 720245, upload-time = "2026-10-04T19:11:47.69Z" }, + { url = "https://files.pythonhosted.org/packages/4f/74/c751bab17d770a3092d79b111281a7dca420b1490dd6e6f5408faab884ee/pycairo-1.29.2-cp314-cp314t-win_amd64.whl", hash = "sha256:bc9e26b7e9577d3655509766275653aa945f101fb28c197496facf8c9ba90321", size = 875205, upload-time = "2026-10-04T19:11:40.692Z" }, + { url = "https://files.pythonhosted.org/packages/b8/61/2d6f8361ba8497bb23bbb8ec8b91959b2e71366a3af2830c5a758663eabd/pycairo-1.29.2-cp314-cp314t-win_arm64.whl", hash = "sha256:29e3389c0b6d3dafda1b2360a8938790c2c7b6971b78e109a565c1cb91f8ae9a", size = 721982, upload-time = "2026-10-04T19:11:42.146Z" }, + { url = "https://files.pythonhosted.org/packages/92/05/427798a6722ee60ff9e1dbde0d6b67d56bdf4362c48c3239cf790804359e/pycairo-1.29.2-cp315-cp315-win_amd64.whl", hash = "sha256:c5dfa99afdde95b82325f240d144008a6b5be99405e74070540a1b7a857eb2a7", size = 872704, upload-time = "2026-10-04T19:11:53.589Z" }, + { url = "https://files.pythonhosted.org/packages/5e/58/708d622971b11215d113a27b8a3ca21815383ff2441eac8922b03a22aa0a/pycairo-1.29.2-cp315-cp315-win_arm64.whl", hash = "sha256:6b0410280b82bf60a84185392f720c099d71524dd7983f93d9abe18c8b2cd3a6", size = 720251, upload-time = "2026-10-04T19:11:55.606Z" }, + { url = "https://files.pythonhosted.org/packages/a9/db/fb0d756cc1966a3e5f3c903f14136690d567983a571d1864e6e7ca1f8c21/pycairo-1.29.2-cp315-cp315t-win_amd64.whl", hash = "sha256:88cbf5632be0b9255822b457d3bfe4f9eb0bc24e5520f54b6c4334e4f5b0f5aa", size = 875248, upload-time = "2026-10-04T19:11:50.36Z" }, + { url = "https://files.pythonhosted.org/packages/0f/ec/3c2700abac22e3ea70c67cb27caa6c2960372ebb7361127328471a39fa7f/pycairo-1.29.2-cp315-cp315t-win_arm64.whl", hash = "sha256:0e49de5b93fc1e76e670f368b9bd0ffc881c72f506e4293c4b4d79f52cbe4c47", size = 721983, upload-time = "2026-10-04T19:11:51.895Z" }, +] + [[package]] name = "pycparser" version = "2.23" @@ -1428,6 +1490,32 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" }, ] +[[package]] +name = "pygobject" +version = "3.54.5" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version > '3.9' and python_full_version < '3.10'", + "python_full_version <= '3.9'", +] +dependencies = [ + { name = "pycairo", version = "1.28.0", source = { registry = "https://pypi.org/simple" } }, +] +sdist = { url = "https://files.pythonhosted.org/packages/d3/a5/68f883df1d8442e3b267cb92105a4b2f0de819bd64ac9981c2d680d3f49f/pygobject-3.54.5.tar.gz", hash = "sha256:b6656f6348f5245606cf15ea48c384c7f05156c75ead206c1b246c80a22fb585", size = 1274658, upload-time = "2025-10-18T13:45:03.121Z" } + +[[package]] +name = "pygobject" +version = "3.58.1" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.14'", + "python_full_version >= '3.10' and python_full_version < '3.14'", +] +dependencies = [ + { name = "pycairo", version = "1.29.2", source = { registry = "https://pypi.org/simple" } }, +] +sdist = { url = "https://files.pythonhosted.org/packages/65/1e/d590f82e14db75945b03f6b63e0f19662e0340babd8f574fdb1bb5a015e2/pygobject-3.58.1.tar.gz", hash = "sha256:4c80598ade17fbaa7798e01a25d0bf29ce109740786026a074c5c62bb3e79d23", size = 1408671, upload-time = "2026-10-09T11:29:48.929Z" } + [[package]] name = "pykeepass" version = "4.2.0" @@ -1509,13 +1597,13 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "colorama", marker = "python_full_version < '3.10' and sys_platform == 'win32'" }, - { name = "exceptiongroup", marker = "python_full_version < '3.10'" }, - { name = "iniconfig", version = "2.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, - { name = "packaging", marker = "python_full_version < '3.10'" }, - { name = "pluggy", marker = "python_full_version < '3.10'" }, - { name = "pygments", marker = "python_full_version < '3.10'" }, - { name = "tomli", marker = "python_full_version < '3.10'" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "exceptiongroup" }, + { name = "iniconfig", version = "2.1.0", source = { registry = "https://pypi.org/simple" } }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, + { name = "tomli" }, ] sdist = { url = "https://files.pythonhosted.org/packages/a3/5c/00a0e072241553e1a7496d638deababa67c5058571567b92a7eaa258397c/pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01", size = 1519618, upload-time = "2025-09-04T14:34:22.711Z" } wheels = [ @@ -1531,13 +1619,13 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "colorama", marker = "python_full_version >= '3.10' and sys_platform == 'win32'" }, - { name = "exceptiongroup", marker = "python_full_version == '3.10.*'" }, - { name = "iniconfig", version = "2.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, - { name = "packaging", marker = "python_full_version >= '3.10'" }, - { name = "pluggy", marker = "python_full_version >= '3.10'" }, - { name = "pygments", marker = "python_full_version >= '3.10'" }, - { name = "tomli", marker = "python_full_version == '3.10.*'" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, + { name = "iniconfig", version = "2.3.0", source = { registry = "https://pypi.org/simple" } }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/e4/47/b9efed96c114afcfa3c9d3fe98a76a1d14c74a9e266d397cf6eb64be5e01/pytest-9.1.1.tar.gz", hash = "sha256:1088fbde8f2b49d95a549a195707afa7a76a3ce9bcadc26b6d71f0ffda5fe313", size = 1636369, upload-time = "2026-06-19T10:58:32.857Z" } wheels = [ @@ -1695,9 +1783,9 @@ resolution-markers = [ "python_full_version <= '3.9'", ] dependencies = [ - { name = "cryptography", version = "47.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version <= '3.9'" }, + { name = "cryptography", version = "47.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version <= '3.9' or python_full_version >= '3.10'" }, { name = "cryptography", version = "50.0.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version > '3.9' and python_full_version < '3.10'" }, - { name = "jeepney", marker = "python_full_version < '3.10'" }, + { name = "jeepney" }, ] sdist = { url = "https://files.pythonhosted.org/packages/53/a4/f48c9d79cb507ed1373477dbceaba7401fd8a23af63b837fa61f1dcd3691/SecretStorage-3.3.3.tar.gz", hash = "sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77", size = 19739, upload-time = "2022-08-13T16:22:46.976Z" } wheels = [ @@ -1713,8 +1801,8 @@ resolution-markers = [ "python_full_version >= '3.10' and python_full_version < '3.14'", ] dependencies = [ - { name = "cryptography", version = "50.0.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, - { name = "jeepney", marker = "python_full_version >= '3.10'" }, + { name = "cryptography", version = "50.0.1", source = { registry = "https://pypi.org/simple" } }, + { name = "jeepney" }, ] sdist = { url = "https://files.pythonhosted.org/packages/1c/03/e834bcd866f2f8a49a85eaff47340affa3bfa391ee9912a952a1faa68c7b/secretstorage-3.5.0.tar.gz", hash = "sha256:f04b8e4689cbce351744d5537bf6b1329c6fc68f91fa666f60a380edddcd11be", size = 19884, upload-time = "2025-11-23T19:02:53.191Z" } wheels = [ @@ -1741,6 +1829,10 @@ dev = [ { name = "pytest", version = "8.4.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, { name = "pytest", version = "9.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, ] +gtk-test = [ + { name = "pygobject", version = "3.54.5", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, + { name = "pygobject", version = "3.58.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, +] quality = [ { name = "coverage", version = "7.10.7", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, { name = "coverage", version = "7.16.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, @@ -1762,6 +1854,7 @@ dev = [ { name = "pykeepass", specifier = ">=4.0" }, { name = "pytest", specifier = ">=7.0" }, ] +gtk-test = [{ name = "pygobject", specifier = ">=3.42" }] quality = [ { name = "coverage", specifier = ">=7.10.7" }, { name = "ruff", specifier = ">=0.16.7" },