9a49ab44d8
Backend
- RegisterDto — username and password both become Option<String> with #[serde(default)] so JSON can omit them entirely.
- AuthApplicationService::register — username uniqueness check skipped when None (multiple NULLs OK under the UNIQUE index); password hashing skipped when None; User::new called with the actual Options instead of forcing Some(...).
- auth_handler::register — branches on dto.password.is_none(). With password → existing 201 + UserDto. Without → triggers MagicLinkInviteService::send_login_link(&email) best-effort, then returns 200 + {"message": "Check your email…"}. The
OIDC-mode-disables-password-registration gate now only fires for the password path (email-only signup is still allowed even in OIDC-only mode, because it doesn't store a password).
- magic_link_handler::redirect_target — new 3-way decision tree:
- Resource target (folder invitation) → /#/files/folder/{id} (existing)
- NULL resource + is_external = false → /#/files (the welcome path for new internal users — they have a home folder)
- NULL resource + is_external = true → /#/sharedwithme (the existing external-user landing)
Tests
- New tests/api/registration.hurl with 9 requests covering: classic (with-password) register → 201 + UserDto, email-only register → 200 + uniform message + welcome magic-link captured, redemption → 302 to /#/files + cookies set, profile read → username
absent + is_external: false, resend magic-link works (eligible while passwordless), cleanup deletes both new users.
- Wired into tests/api/run.sh right after auth_login.hurl.
Plan additions
- auth-simplification.md gained PR 22 at the bottom of the PR sequence — device-bound magic-link redemption via challenge cookie + asymmetric TTLs (login: 10 min, invitation: 24 h). Full design recap, schema migration, config knobs
(OXICLOUD_MAGIC_LINK_LOGIN_TTL_MINUTES / _INVITE_TTL_HOURS), and Hurl coverage outline are in the plan. Slots in before PR 21's docs so the architecture page describes the final state from the start.
Checks — cargo fmt, cargo clippy --all-features --all-targets -- -D warnings, cargo test --lib (297 passed), biome, stylelint, tsc, full Hurl suite (16 files) all green.
114 lines
3.8 KiB
Bash
Executable File
114 lines
3.8 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/auth_login.hurl" \
|
|
"$API_DIR/registration.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" \
|
|
"$API_DIR/external_users.hurl"
|
|
|
|
#bash "$API_DIR/dedup_bulk_upload.sh"
|
|
|
|
bash "$API_DIR/storage_cleanup_check.sh"
|
|
|
|
log "All tests passed."
|