From 54e60dcf8e7acae130ec84e1bf9b48f5cd333231 Mon Sep 17 00:00:00 2001 From: Andrey Epifancev Date: Wed, 11 Nov 2026 21:06:53 +0400 Subject: [PATCH] =?UTF-8?q?test(formulas):=20GET=20formulas=20=D0=B1=D0=B5?= =?UTF-8?q?=D0=B7=20=D0=B4=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B0,=20=D1=81?= =?UTF-8?q?=D0=BF=D0=B5=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BA=20=D0=BA=D0=BE=D0=B4=D1=83=20(AUROR?= =?UTF-8?q?A-1896,=20M-5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../integration/test_cell_formula_integration.py | 15 +++++++++++++++ .../specs/cell-formula/spec.md | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) 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** пользователь А сохранил формулу, а пользователь Б с доступом к форме запрашивает формулы листа