23 KiB
stepsCompleted, lastStep, lastSaved, workflowType, storyId, storyKey, storyFile, atddChecklistPath, generatedTestFiles, inputDocuments, acceptanceCriteria
| stepsCompleted | lastStep | lastSaved | workflowType | storyId | storyKey | storyFile | atddChecklistPath | generatedTestFiles | inputDocuments | acceptanceCriteria | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
step-05-validate-and-complete | 2026-10-03 | testarch-atdd | 2.11 | 2-11-security-mapping-ui | _bmad-output/implementation-artifacts/spec-2-11-security-mapping-ui.md | _bmad-output/test-artifacts/atdd-checklist-2-11-security-mapping-ui.md |
|
|
|
ATDD Checklist — Story 2.11: Выбирать security mappings в OpenAPI UI
Date: 2026-10-03
Author: Bsodfather
Primary test level: E2E (Playwright Chromium, P1; epic scenario 2.11-E2E-A,B, risks E2-R2/E2-R4)
Story summary
Администратор выбирает security alternative и безопасный Auth Profile в OpenAPI import UI. Существующий ImportPlan API остаётся единственным источником решения о binding; UI показывает его результат и безопасные подсказки, не вводя и не храня raw credentials.
As a администратор I want выбирать profile и security alternative в OpenAPI UI So that вижу unresolved/resolved/blocker state без раскрытия secrets.
Approved acceptance criteria snapshot
IDs ниже назначены детерминированно в порядке source AC: в спецификации supplied AC-<n> IDs отсутствуют.
| ID | ID source | Acceptance criterion |
|---|---|---|
| AC-1 | generated | Given preview сохраняет OR alternatives и required authentication, when администратор выбирает alternative либо совместимый Auth Profile текущего workspace, then UI передаёт выбор существующему import API и показывает authoritative resolved/unresolved/blocker status; raw credentials не вводятся в mapping state и не копируются в IR/plan. |
| AC-2 | generated | Given смена alternative, удалённый/недоступный profile либо stale preview response, when API повторно валидирует binding, then UI показывает safe blocker/revalidation guidance и не выдаёт предыдущий resolved state за текущий; OR/AND semantics, workspace validation и redaction остаются в API Story 2.10. |
| AC-3 | generated | Given security-mapping UI на RU и EN, when пользователь выбирает profile, меняет alternative или получает unsupported scheme, then UI показывает required/unresolved/resolved status, safe profile metadata и blocker findings; loading, empty, error и stale-response states не раскрывают secrets. |
Story integration metadata
- Story ID:
2.11 - Story key:
2-11-security-mapping-ui - Story file:
_bmad-output/implementation-artifacts/spec-2-11-security-mapping-ui.md - Checklist:
_bmad-output/test-artifacts/atdd-checklist-2-11-security-mapping-ui.md - Test file:
apps/ui/tests/e2e/openapi-security-mapping.spec.js - Context: spec →
_bmad-output/implementation-artifacts/epic-2-context.md; canonical Epic 2 test design says 2.11 owns former security AC group 11 plus UI perspectives of groups 3 and 5.
Preflight and generation decisions
- Baseline:
b18a84b2c5a70b150d8c6a0749478bd13753308b. - Stack:
frontend; Playwright config isapps/ui/playwright.config.js, test directory isapps/ui/tests/e2e, Chromium is configured. - Existing patterns reused:
tests/e2e/openapi-import-plan.spec.jsfor plan mocking andtests/e2e/operations.spec.jsfor the preview upload flow; common login/localization helpers come fromtests/e2e/helpers.js. @seontechnologies/playwright-utilsis absent fromapps/ui/package.json; the Playwright Utils applicability gate therefore stays closed despite the preference flag. Existing suite uses@playwright/testandpage.route.- Generation mode: AI specification mode, unattended. Recording was unnecessary because all target selectors are proposed accessible labels for not-yet-implemented controls. Endpoint/payload shapes are grounded in the approved spec and
apps/admin-api/src/dto.rs; response security fields are grounded incrates/crank-import/src/rest/model.rs. - No production source, sibling helper, or sprint status file was modified.
Scenario-to-AC mapping
Each criterion has exactly one primary RED-phase leaf. The extra matrix branches below are secondary green-phase automation work and do not create additional primary scaffolds.
| Approved spec scenario | AC | Existing coverage | New primary scaffold / follow-up branch |
|---|---|---|---|
| Required OR: select supported alternative/profile; use current API result | AC-1 | openapi-import-plan.spec.js covers ordinary plan/apply decisions, but not security selections or their authority |
New AC-1 E2E leaf sends security_alternative_index and auth_profile_id, then checks server-returned resolved state. Extend green coverage for every compatible AuthKind. |
| Anonymous/no-auth alternative | AC-1, AC-2 | No security mapping UI test found | Green branch: explicit no-profile choice sends only alternative index; plan must not add an incompatible profile binding. |
| Unsupported AND/OAuth | AC-3 | Backend/UI mapping test absent; API owns support semantics | Green branch: preserve visible unsupported sibling and blocker/manual guidance; never silently select another OR alternative. |
| Empty/unavailable profiles; API rejects removed/revoked profile | AC-2, AC-3 | Existing E2E suite does not exercise Auth Profile mapping | New AC-2 leaf sends typed reference, receives import_plan_auth_unavailable, and asserts safe blocker with no previous resolved state. Green branches: no compatible profile, unavailable Secret, incompatible scheme. |
| Alternative/profile selection changed | AC-2 | Existing import suite tests stale request authority, not security mapping invalidation | Green branch: old plan/resolved status is cleared immediately, profile reset when alternative changes, and new plan result alone restores authority. |
| Stale preview after replacement/workspace/language/close | AC-2, AC-3 | operations.spec.js covers generic stale preview request identity, not security mapping state |
Green branch: delayed prior preview cannot change current selection/status; retain abort and revision guards. |
| RU/EN required/unresolved/resolved/blocker; no secret canary | AC-3 | Existing suite covers other OpenAPI localization but not security labels/findings | New AC-3 leaf checks safe metadata and blocker guidance in both locales, and checks DOM/storage/error rendering for a canary. Green branches: loading, empty, API error, unsupported security findings, keyboard/focus/status announcements. |
Red-phase E2E scaffolds
File: apps/ui/tests/e2e/openapi-security-mapping.spec.js (212 lines).
| Test leaf | AC | Expected failing behavior after activation | Baseline status |
|---|---|---|---|
[P1] AC-1 sends the selected OR alternative and Auth Profile, then renders API authority |
AC-1 | Current UI has no accessible security-alternative/profile controls and does not submit either plan decision field. | Activated (test.skip removed); RED confirmed: failed on missing Security alternative label, EXIT=1; now GREEN. |
[P1] AC-2 replaces a prior resolved plan with a blocker after profile revalidation fails |
AC-2 | Current UI cannot submit the profile reference or render the typed API blocker after returning from a successful plan. | Activated; RED confirmed (missing controls), EXIT=1; now GREEN. |
[P1] AC-3 shows safe security guidance in RU and EN without exposing error or secret canaries |
AC-3 | Current UI does not render security metadata/status/findings and safe localized revalidation guidance. | Activated; RED confirmed (missing safe metadata), EXIT=1; now GREEN. |
The leaf bodies use accessible labels Security alternative / Вариант безопасности and Auth Profile / Профиль авторизации. These are intended stable accessible names for the new controls. The security status oracle is the proposed data-testid="openapi-security-status" with exact localized values Resolved / Разрешено, Blocked / Заблокировано, and Unresolved. Unsupported alternatives must remain visible and disabled. The API fixtures use only safe {id,name,kind} profile metadata; the secret canary exists only in the hostile mock error message and is asserted absent from page/storage output. This browser assertion does not prove the backend IR or persisted plan contains no raw credentials; Story 2.10 owns that authority and must supply real API evidence.
Minimal mock contract
POST **/imports/openapi/previewreturns the existing preview shape plussecurity_profile_choices: [{operation_key, alternative_index, schemes, profiles: [{id,name,kind}]}].POST **/imports/openapi/*/planscapturesdecisions[]; success reflects API candidatestate: actionableand chosen profile/index. Negative branches return typed 422 codes such asimport_plan_auth_unavailableorimport_plan_security_alternative_required.- No live API or fixture helper is added. Plan/apply regressions remain in existing
openapi-import-plan.spec.js.
Required accessibility/DOM contract
- Accessible labeled comboboxes for security alternative and Auth Profile, keyboard operable with visible focus.
- Required/unresolved/resolved/blocker result announced using semantic status content.
- Profile options expose only safe
id,name, andkind; do not add raw credentials to controls, mappings, plans, local/session storage, or rendered error details. - Add
data-testid="openapi-security-status"to the dedicated status output; accessible labels and existing modal IDs identify the inputs and flow controls.
Implementation checklist (Story 2.11 stage — completed 2026-10-03)
- Read
security_profile_choicesand each operation'ssecurity_requirements.alternativesfrom preview; preserve OR/AND meanings and unsupported findings. - Add accessible controls for alternative/profile using only safe profile metadata; explicitly represent no-auth and empty-profile choices (placeholder
value=""; anonymous option; unsupported options disabled with safe finding copy). - Store only alternative index/profile ID in mapping state; clear profile on alternative change (and stale plan); never add security fields to
skipdecisions (local guardopenapi.error.security_with_skip). - Submit selected decision fields through the existing CreatePlan endpoint; consume candidate plan state/reason as authority (
Resolved/Blocked/Unresolvedonly from plan API result). - Invalidate old resolved/plan state on selection, replacement, stale response, workspace/language change, close, or API rejection; keep AbortController and identity/revision guards (delayed-preview test covers cancelled stale response).
- Map blocker/finding codes to safe RU/EN copy (
import_plan_auth_unavailable,import_plan_auth_incompatible,import_plan_security_alternative_required, candidate reasonauth_profile_required,unsupported_security_scheme,unsupported_security_and_requirement); preserve keyboard labels, visible focus, and screen-reader status (role=status,aria-live=polite). - Add/retain the dedicated security status test id (
data-testid="openapi-security-status") and exact localized state values so the E2E oracle cannot confuseunresolvedwith a substring match onresolved(Unresolved/Разрешено/Blocked/Заблокировано). - Activate scaffolds (all 3, EXIT=1 RED) before implementation; then make them pass and complete the secondary branches (anonymous, empty-profile, alternative-change invalidation, stale-preview cancel, keyboard/focus/live status).
- Run
cd apps/ui && npx playwright test tests/e2e/openapi-security-mapping.spec.js tests/e2e/openapi-import-plan.spec.js tests/e2e/operations.spec.js --workers=1(20 passed, EXIT=0, no skipped mandatory cases) and story-requiredjust verify(PASS recorded below). - Run the key alternative/profile selection against the real Playwright stack: real Secret + bearer Auth Profile created via existing API, real upload → real preview → UI alternative/profile selection → real
POST …/plans→ 200 actionable/Resolved, payload carries onlyauth_profile_id+security_alternative_index, secret value asserted absent from DOM. Real negative revalidation limitation: the API has no Auth Profile delete/disable endpoint and referenced Secrets are guarded (409secret_referenced_by_auth_profile), so real negative evidence beyond Story 2.10 stays covered by the mandatory mock leaves (import_plan_auth_unavailableas a typed top-level rejection andauth_profile_requiredas an API-authored blocked candidate reason) — recorded honestly, no backend surface extended. - Preserve separate API-owned evidence that raw credentials are absent from normalized IR and plan/persisted outputs: real test additionally asserts the created Secret value never reaches the browser DOM; browser storage canary assertions cover local surfaces.
- Mandatory matrix expansion before story acceptance: anonymous/no-auth; unsupported AND/OAuth visible and disabled; empty compatible-profile list; unavailable Secret/profile rejection (mock, API-code-authoritative); alternative change clears prior profile and plan; stale preview after cancel cannot restore status; loading and API error recovery (AC-3 retry); keyboard/focus/screen-reader behavior.
Test execution evidence
Discovery command: cd apps/ui && npx playwright test tests/e2e/openapi-security-mapping.spec.js --list
RED evidence (before UI implementation): all three activated leaves failed against the same-revision stack because the accessible Security alternative / Профиль авторизации controls and safe metadata were absent; command cd apps/ui && npx playwright test tests/e2e/openapi-security-mapping.spec.js --workers=1 finished 3 failed, EXIT=1.
GREEN evidence (after implementation, same revision):
cd apps/ui && npm run build— PASS (EXIT=0).cd apps/ui && npx playwright test tests/e2e/openapi-security-mapping.spec.js --workers=1— 9 passed, EXIT=0.cd apps/ui && npx playwright test tests/e2e/openapi-security-mapping.spec.js tests/e2e/openapi-import-plan.spec.js tests/e2e/operations.spec.js --workers=1— 20 passed, EXIT=0, no skipped mandatory cases.
Runtime outcome: run and passed for every mandatory leaf and branch plus one real-API happy-path evidence test; no RED or GREEN is claimed without execution evidence. The three primary leaves were explicit activated tests first (EXIT=1), then activated green leaves.
Full just verify gate (2026-10-03): PASS, exit 0 (lead-run; log /tmp/crank211-lead-verify-final.log). Two earlier attempts failed on environment/harness issues, not on Story 2.11 code:
- First run (
/tmp/crank211-verify.log,VERIFY_EXIT=101):crates/crank-artifacts/tests/artifact_store_io.rsreal_process_write_limit_leaves_no_partial_final_blobfailed atassert!(status.success()). The test re-executes itself withRLIMIT_FSIZE=1while its stdout was redirected to a regular file (the run log), so the child's own write exceeded the one-byte file-size limit and exited non-zero. The same test passes in isolation; no product defect. - Second run (
/tmp/crank211-lead-verify.log,VERIFY_EXIT=101):crank-observability --test prometheusdefault_service_ports_bind_and_serve_real_metrics_listenersfailed withdefault metrics port must bind: Bind— a port conflict with a parallel browser/e2e process holding the metrics port; unrelated to Story 2.11. - Final clean run (
/tmp/crank211-lead-verify-final.log): all test binaries ok,just verifyexit 0. Story 2.11 diff touches onlyapps/ui/*anddocs/openapi-import.md; no Rust source is changed.
Follow-up authority/lifecycle stage (2026-10-03): fixed lead-found gaps — OR-alternative profile filtering (safe union only while unspecified), anonymous alternative offers no profile control, per-operation authoritative unresolved/required/no-auth/resolved/blocked state from the exact plan candidate with an aggregate summary that never calls a non-auth/excluded candidate resolved, reset on edit/back/Apply rejection, typed-rejection vs transport-error distinction, skip auto-clears security fields, and language-change guards that preserve Apply locks.
Evidence:
node --check apps/ui/js/openapi-import.js apps/ui/js/i18n.js apps/ui/tests/e2e/openapi-security-mapping.spec.js— OK.- Targeted RED: current
apps/ui/js/openapi-import.jssaved to/tmp/crank211-logs/openapi-import.js.current, then the pre-fix version restored from the Git index (git show :apps/ui/js/openapi-import.js, index untouched) andnpx playwright test tests/e2e/openapi-security-mapping.spec.js --workers=1→8 failed, 8 passed, EXIT=1 (log/tmp/crank211-logs/security-red-index.log). Failures map to the specific gaps (profile filtering/anonymous profile hidden, per-operation required/authoritative status, blocked-reset on edit, skip clearing security controls, rejected-Apply clearing resolved); current file restored byte-identical afterwards. cd apps/ui && npm run build— PASS (EXIT=0).cd apps/ui && npx playwright test tests/e2e/openapi-security-mapping.spec.js tests/e2e/openapi-import-plan.spec.js tests/e2e/operations.spec.js --workers=1— 27 passed, EXIT=0, no skipped mandatory cases (log/tmp/crank211-logs/three-suites-3.log). Security spec then grew to 19 active tests (3 primary AC + matrix/lifecycle/stale-context branches + real-API happy path).- Review-fix iteration: per-operation status lookup now compares
data-openapi-security-op-statusdataset values against a constant selector (quoted/backslash operation keys covered by a regression), per-operation status nodes exposerole=status/aria-live=polite, the API candidate reasonauth_profile_requiredmaps to safe translated guidance (empty-profile case now uses a real 200 blocked candidate, not a synthesized error code), and the stale-context coverage includes language and workspace changes.node --checkOK;npx playwright test tests/e2e/openapi-security-mapping.spec.js --workers=1→ 19 passed, EXIT=0 (log/tmp/crank211-logs/security-review-fixes-2.log). - New deterministic stale tests replace
waitForTimeout: preview and plan stale responses are held/ released through a handler-settlement barrier. just verifywas run by the lead (not re-run by this worker); final result is PASS exit 0 above.
Knowledge fragments applied
data-factories.md: use valid contract data and keep fixtures scoped; no new factory needed for the fixed one-operation preview.component-tdd.md,test-quality.md: one primary leaf per AC, meaningful status/payload oracle, separate transition branches for later green automation.test-healing-patterns.md,timing-debugging.md: deterministic network boundary and no hard waits.selector-resilience.md: accessible role/name selectors rather than styling classes.fixture-architecture.md: reuse existing pure login helper; no unnecessary fixture abstraction.network-first.md: install preview/plan routes before navigation.playwright-cli.md: available for later selector/trace diagnosis if needed; no live recording session launched.
Handoff
ATDD-only output is ready for the separate implementation stage. Keep this checklist as the approved AC snapshot and activate a single leaf before changing production code. The Epic 2 test design requires eventual same-revision browser and real API evidence and does not treat source presence or skipped scaffolds as coverage qualification.
Final lead verification
После review fixes: build PASS exit 0; три mandatory browser suites — 30 passed, exit 0 (19 security + 11 regressions), skipped mandatory 0; just verify — PASS exit 0, tooling 152, Rust 945 passed / 0 failed / 1 existing ignored stress-test. Все строки frozen I/O matrix покрыты выполненными PASS cases. Финальный verdict основан на diff, независимом review и фактическом прогоне, не на sprint bookkeeping.