test_removed_unwired_routes.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. """Routes for two features that never had a UI are gone (audit A1-02, A2-01).
  2. Archive rescan and project file attachments were reachable only through the
  3. API, while the wiki described buttons and a section that did not exist.
  4. The project cover image keeps its own routes and storage.
  5. """
  6. import pytest
  7. from httpx import AsyncClient
  8. pytestmark = [pytest.mark.asyncio, pytest.mark.integration]
  9. @pytest.mark.parametrize(
  10. ("method", "path"),
  11. [
  12. ("POST", "/api/v1/archives/{archive}/rescan"),
  13. ("POST", "/api/v1/archives/rescan-all"),
  14. ("POST", "/api/v1/projects/{project}/attachments"),
  15. ("GET", "/api/v1/projects/{project}/attachments/notes.pdf"),
  16. ("DELETE", "/api/v1/projects/{project}/attachments/notes.pdf"),
  17. ],
  18. )
  19. async def test_route_is_gone(async_client: AsyncClient, printer_factory, archive_factory, method, path):
  20. printer = await printer_factory()
  21. archive = await archive_factory(printer.id)
  22. project = (await async_client.post("/api/v1/projects/", json={"name": "Gone"})).json()
  23. response = await async_client.request(method, path.format(archive=archive.id, project=project["id"]))
  24. assert response.status_code in (404, 405), response.text
  25. if response.status_code == 404:
  26. # The router's (or the API catch-all's) generic answer, not the old
  27. # route's own "Attachment not found" for a missing file.
  28. assert response.json()["detail"].lower() == "not found"