fix: partage dirigé — dossier Partage virtuel + ouverture en onglet #196
- _resolve_shared_file: home-<user>/Partage/<f> -> fichier source (/api/file, raw, download) - clic dossier Partage: dépliage sans navigation (fix Directory not found) - fichiers reçus ouverts en onglet applicatif (arbre, recherche, dashboard) - POST /api/share: path vide/null rejeté (400) — un share path:null cassait /api/shares - +2 tests (13 total)
This commit is contained in:
@@ -167,3 +167,33 @@ class TestDirectedShareGate:
|
||||
resp = user_client.get("/api/search", params={"q": "dirigé", "vault": "all"})
|
||||
assert resp.status_code == 200
|
||||
assert not [r for r in resp.json()["results"] if r.get("share_token")]
|
||||
|
||||
def test_recipient_opens_shared_file_in_app(self, sessions):
|
||||
# #196 : /api/file résout home-<user>/Partage/<fichier> vers la source.
|
||||
admin_client, user_client = sessions
|
||||
path = _ensure_shared_file()
|
||||
resp = admin_client.post("/api/share/TestVault", json={
|
||||
"path": path, "shared_with": ["normaluser"],
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
r = user_client.get("/api/file/home-normaluser", params={"path": "Partage/share_directed.md"})
|
||||
assert r.status_code == 200, r.text
|
||||
body = r.json()
|
||||
assert body["is_markdown"] is True
|
||||
assert "dirigé" in body["html"]
|
||||
|
||||
# raw endpoint too
|
||||
r = user_client.get("/api/file/home-normaluser/raw", params={"path": "Partage/share_directed.md"})
|
||||
assert r.status_code == 200
|
||||
assert "dirigé" in r.json()["raw"]
|
||||
|
||||
def test_shared_file_resolution_is_user_scoped(self, sessions):
|
||||
# home-admin/Partage/x.md demandé par normaluser → pas de mapping
|
||||
# (le home d'un autre user lui est interdit, 403 avant tout).
|
||||
admin_client, user_client = sessions
|
||||
path = _ensure_shared_file()
|
||||
admin_client.post("/api/share/TestVault", json={
|
||||
"path": path, "shared_with": ["normaluser"],
|
||||
})
|
||||
r = user_client.get("/api/file/home-admin", params={"path": "Partage/share_directed.md"})
|
||||
assert r.status_code == 403
|
||||
|
||||
Reference in New Issue
Block a user