§7 of the groups/project-tool design. A group node is now authoritatively managed by exactly one project-root; `pic apply --dir` claims, conflicts, takes over, and (with --prune) structurally reaps owned nodes. - Migration 0052: `projects(id, key UNIQUE)` + promote the inert `groups.owner_project` (0047) to a real FK (ON DELETE SET NULL) + index. - CLI mints a stable, gitignored project key in `.picloud/project.json` (`pic init`, or lazily on first tree plan/apply) and presents it on every tree request; `pic apply --dir --takeover` flag. - Server: prepare_tree resolves ownership read-only (plan surfaces conflicts + prune candidates; token folds each group's owner key). apply_tree upserts the project in-tx, claims created groups on insert, reconciles existing-group ownership under the per-node advisory lock (first-commit-wins), and prunes owned-but-undeclared groups leaf-first (delete=RESTRICT, never another repo's or a UI-owned node). - Authz (§7.4, ownership ⟂ RBAC): takeover requires GroupAdmin per contested node — enforced in authz_tree (pre-tx) AND re-verified in-tx at the ownership decision, so --force (which waives the staleness token) can't open a takeover-without-admin window. The attacker-supplied project key is length/charset-validated server-side. - Tests: tests/ownership.rs (claim → conflict → takeover → flip; non-admin takeover → 403; prune-owned-only); format_conflicts unit test; schema golden reblessed. tree_shape M2 journey updated to reparent in-place (a fresh dir is now a distinct project and would correctly conflict). Closes the M3 milestone; reviewed (4 findings: 1 authz-bypass via --force + key validation + 2 LOW, all fixed). M4 (trigger/route templates) remains. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
48 lines
983 B
Rust
48 lines
983 B
Rust
//! Integration-test binary for the `pic` CLI.
|
|
//!
|
|
//! Every `#[test]` in this binary routes through `common::fixture()`, a
|
|
//! `LazyLock` that spawns picloud once on a private port and reuses it
|
|
//! across all journey modules. Mirrors the dashboard Playwright suite,
|
|
//! which spins backend + Vite up once for 63 specs.
|
|
//!
|
|
//! Gated on `DATABASE_URL`. To run:
|
|
//!
|
|
//! docker compose up -d postgres
|
|
//! DATABASE_URL=postgres://picloud:picloud@127.0.0.1:15432/picloud \
|
|
//! cargo test -p picloud-cli --test cli -- --include-ignored
|
|
|
|
mod common;
|
|
|
|
mod admins;
|
|
mod api_keys;
|
|
mod apply;
|
|
mod apps;
|
|
mod auth;
|
|
mod config;
|
|
mod dead_letters;
|
|
mod email_queue;
|
|
mod enabled;
|
|
mod env_overlay;
|
|
mod extension_points;
|
|
mod group_modules;
|
|
mod group_scripts;
|
|
mod group_secrets;
|
|
mod groups;
|
|
mod init;
|
|
mod invoke;
|
|
mod logs;
|
|
mod output;
|
|
mod ownership;
|
|
mod plan;
|
|
mod prune;
|
|
mod pull;
|
|
mod roles;
|
|
mod routes;
|
|
mod scripts;
|
|
mod secrets;
|
|
mod staleness;
|
|
mod tree;
|
|
mod tree_shape;
|
|
mod triggers;
|
|
mod vars;
|