Sfoglia il codice sorgente

Tests: CA certificate tests use their own folder

- the virtual printer CA lives in the real data folder, which all
  test workers share; on an empty one (the Docker run) several
  workers made a CA at once and overwrote each other's, so the
  installer test saw a different CA than the one it had just fetched
- each test in the class now points the manager at its own tmp_path
maziggy 1 giorno fa
parent
commit
1c6f54f8bc
1 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 9 0
      backend/tests/integration/test_virtual_printer_api.py

+ 9 - 0
backend/tests/integration/test_virtual_printer_api.py

@@ -387,6 +387,15 @@ class TestVirtualPrinterTailscaleToggleAPI:
 class TestVirtualPrinterCaCertificateAPI:
     """Integration tests for GET /api/v1/virtual-printers/ca-certificate."""
 
+    @pytest.fixture(autouse=True)
+    def _own_ca_dir(self, monkeypatch, tmp_path):
+        # The CA lives under the real data dir, which all test workers share.
+        # On a fresh one (Docker) they each created a CA at once and
+        # overwrote one another between two requests of the same test.
+        from backend.app.services.virtual_printer import virtual_printer_manager
+
+        monkeypatch.setattr(virtual_printer_manager, "_base_dir", tmp_path)
+
     @pytest.mark.asyncio
     @pytest.mark.integration
     async def test_get_ca_certificate_returns_pem(self, async_client: AsyncClient):