09985f8a95
this implements first version (manageable only by admin right now)
routes:
GET /api/groups
List subject groups (paginated). Admin-only.
POST /api/groups
Create a new ReBAC subject group. Admin-only. The name must match the RFC 5321 local-part shape and be globally unique (case-insensitive).
GET /api/groups/search
Search non-virtual groups by name substring. Authenticated only (no admin role required) — backs the share-dialog recipient autocomplete.
GET /api/groups/{id}
Fetch a single group's details. Admin-only.
DELETE /api/groups/{id}
Delete a group. Cascades to `subject_group_members` (FK) and to `access_grants` rows referencing this group as a subject. Admin-only.
PATCH /api/groups/{id}
Update a group's metadata. Admin-only. v1 only persists name renames.
GET /api/groups/{id}/effective-members
List every user transitively reached through this group (members of members of members, etc.). Used by admin / audit tooling. Admin-only.
GET /api/groups/{id}/members
List the *direct* members of a group (one level only). Admin-only.
POST /api/groups/{id}/members
Add a member to a group. Exactly one of `user_id` / `group_id` must be provided. Adding a group-member runs a write-time cycle check and a nesting-depth check (max 8). Admin-only.
DELETE /api/groups/{id}/members/group/{gid}
Remove a nested group-member from a group. Admin-only.
DELETE /api/groups/{id}/members/user/{uid}
Remove a user-member from a group. Admin-only.
fix hurl
groups
round
groups
111 lines
3.7 KiB
Bash
Executable File
111 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Full Hurl API test runner.
|
|
# Starts postgres + OxiCloud server, runs Hurl tests, tears everything down.
|
|
#
|
|
# Usage (from repo root):
|
|
# bash tests/api/run.sh
|
|
#
|
|
# Prerequisites: docker, cargo, hurl ≥ 4.0
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
COMMON="$REPO_ROOT/tests/common"
|
|
API_DIR="$REPO_ROOT/tests/api"
|
|
|
|
# test.env is the single source of truth for connection details and credentials.
|
|
# shellcheck source=test.env
|
|
source "$API_DIR/test.env"
|
|
|
|
# Derive server port from base_url (e.g. http://localhost:8087 → 8087)
|
|
SERVER_PORT="${base_url##*:}"
|
|
|
|
# ── Helpers ───────────────────────────────────────────────────────────────────
|
|
|
|
log() { echo "[api-test] $*"; }
|
|
die() { echo "[api-test] ERROR: $*" >&2; exit 1; }
|
|
|
|
wait_for_http() {
|
|
local url="$1" timeout="${2:-60}"
|
|
local deadline=$(( $(date +%s) + timeout ))
|
|
until curl -sf "$url" >/dev/null 2>&1; do
|
|
[[ $(date +%s) -ge $deadline ]] && die "Timeout waiting for $url"
|
|
sleep 1
|
|
done
|
|
}
|
|
|
|
# ── Teardown (always runs on exit) ────────────────────────────────────────────
|
|
|
|
SERVER_PID=""
|
|
|
|
cleanup() {
|
|
if [[ -n "$SERVER_PID" ]]; then
|
|
log "Stopping OxiCloud server (pid $SERVER_PID)..."
|
|
kill "$SERVER_PID" 2>/dev/null || true
|
|
wait "$SERVER_PID" 2>/dev/null || true
|
|
fi
|
|
bash "$COMMON/stop-db.sh"
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
# ── 1. Start postgres ─────────────────────────────────────────────────────────
|
|
|
|
bash "$COMMON/spawn-db.sh"
|
|
|
|
# ── 2. Load shared server env + port from .env ───────────────────────────────
|
|
|
|
set -a
|
|
# shellcheck source=../common/server.env
|
|
source "$COMMON/server.env"
|
|
OXICLOUD_SERVER_PORT=$SERVER_PORT
|
|
OXICLOUD_STORAGE_PATH="$REPO_ROOT/tests/api/storage"
|
|
set +a
|
|
|
|
# ensure storage is empty before starting
|
|
echo "Wipe $OXICLOUD_STORAGE_PATH to ensure clean startup"
|
|
rm -rf "$OXICLOUD_STORAGE_PATH"
|
|
mkdir -p "$OXICLOUD_STORAGE_PATH"
|
|
|
|
# ── 3. Start OxiCloud server ──────────────────────────────────────────────────
|
|
|
|
BUILD_TARGET="${BUILD_TARGET:-debug}"
|
|
OXICLOUD_BIN="$REPO_ROOT/target/$BUILD_TARGET/oxicloud"
|
|
|
|
if [[ -x "$OXICLOUD_BIN" ]]; then
|
|
log "Starting pre-built OxiCloud server ($BUILD_TARGET) on port $SERVER_PORT..."
|
|
"$OXICLOUD_BIN" &
|
|
else
|
|
log "Building and starting OxiCloud server on port $SERVER_PORT..."
|
|
cd "$REPO_ROOT"
|
|
cargo run &
|
|
fi
|
|
SERVER_PID=$!
|
|
log "Waiting for server at $base_url..."
|
|
wait_for_http "$base_url/ready" 120
|
|
log "Server is ready."
|
|
|
|
# ── 4. Run Hurl tests ─────────────────────────────────────────────────────────
|
|
|
|
log "Running Hurl tests..."
|
|
hurl --variables-file "$API_DIR/test.env" --file-root "$REPO_ROOT/tests" --test --jobs 1 \
|
|
"$API_DIR/setup.hurl" \
|
|
"$API_DIR/files-folders.hurl" \
|
|
"$API_DIR/favorites.hurl" \
|
|
"$API_DIR/trash.hurl" \
|
|
"$API_DIR/trash_resources.hurl" \
|
|
"$API_DIR/recent.hurl" \
|
|
"$API_DIR/batch_folder_copy.hurl" \
|
|
"$API_DIR/dedup_blob_cleanup.hurl" \
|
|
"$API_DIR/contacts.hurl" \
|
|
"$API_DIR/permissions.hurl" \
|
|
"$API_DIR/grants.hurl" \
|
|
"$API_DIR/subject_groups.hurl" \
|
|
"$API_DIR/grants_nested_groups.hurl"
|
|
|
|
#bash "$API_DIR/dedup_bulk_upload.sh"
|
|
|
|
bash "$API_DIR/storage_cleanup_check.sh"
|
|
|
|
log "All tests passed."
|