diff --git a/api/tests/integration/test_cell_formula_integration.py b/api/tests/integration/test_cell_formula_integration.py index 4dfe13e..881d26d 100644 --- a/api/tests/integration/test_cell_formula_integration.py +++ b/api/tests/integration/test_cell_formula_integration.py @@ -206,6 +206,12 @@ def test_get_formulas_unknown_form_404(client, headers): assert r.status_code == 404 +def test_get_formulas_no_form_access_404(client, isp_tokens, auth_headers): + # isp1 в оргединице формы 1 не состоит: форма для него «не найдена» (спека: как у GET листа). + r = client.get(f"{FORM}/sheet/AHR/formulas", headers=auth_headers(isp_tokens)) + assert r.status_code == 404, r.text + + # ---- Отчёты проектов (FORM_3) ---- import uuid @@ -459,3 +465,12 @@ def test_rf_project_report_line_trigger_direct_delete(client, headers): left = {f["line_id"] for f in _project_formulas(client, headers, pid, year)} assert l1 not in left assert l2 in left + + +def test_project_formulas_report_no_access_400(client, headers, isp_tokens, auth_headers): + # Проект админа в филиале 1; isp1 доступа к нему не имеет: та же ошибка, что у PATCH отчёта. + year = datetime.now().year + pid = _create_project(client, headers, year) + r = client.get(f"{_report_url(pid, year)}/formulas", headers=auth_headers(isp_tokens)) + assert r.status_code == 400, r.text + assert r.json().get("message") == "Отчёт не найден" diff --git a/openspec/changes/aurora-1896-cell-formulas/specs/cell-formula/spec.md b/openspec/changes/aurora-1896-cell-formulas/specs/cell-formula/spec.md index 274f86c..dce076c 100644 --- a/openspec/changes/aurora-1896-cell-formulas/specs/cell-formula/spec.md +++ b/openspec/changes/aurora-1896-cell-formulas/specs/cell-formula/spec.md @@ -40,7 +40,7 @@ - **THEN** сохраняется выражение `100+50` ### Requirement: Чтение формул листа -Сервер SHALL отдавать все формулы листа: `GET /api/v1/form/{form_id}/sheet/{sheet}/formulas` и `GET /api/v1/projects/{project_id}/report/{year}/{report_type}/formulas`. Каждая запись SHALL содержать `line_id`, `column`, `expression`, `value`, `updated_by` (`id`, `full_name`) и `updated_at`. Доступ SHALL проверяться так же, как у GET листа (форма) или отчёта (проект): нет доступа к форме или проекту — 404. +Сервер SHALL отдавать все формулы листа: `GET /api/v1/form/{form_id}/sheet/{sheet}/formulas` и `GET /api/v1/projects/{project_id}/report/{year}/{report_type}/formulas`. Каждая запись SHALL содержать `line_id`, `column`, `expression`, `value`, `updated_by` (`id`, `full_name`) и `updated_at`. Доступ SHALL проверяться так же, как у GET листа (форма) или отчёта (проект): нет доступа к форме или формы нет — 404 «Форма не найдена»; отчёт проекта не найден или нет доступа — та же ошибка, что у PATCH этого отчёта (400 «Отчёт не найден»). #### Scenario: Формулы видны другому пользователю - **WHEN** пользователь А сохранил формулу, а пользователь Б с доступом к форме запрашивает формулы листа