shinkan-jinkendo/backend/tests/test_account_onboarding_gate.py
Lars a2f60d3f46
Some checks failed
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 15s
Test Suite / playwright-tests (push) Has been cancelled
Test Suite / k6 /health Baseline (push) Has been cancelled
Update Capability Catalog and Club Membership Documentation
- Revised the status in the Capability Catalog to reflect partial implementation (M3).
- Added a new reference to `MEMBERSHIP_RBAC_DECISIONS_2026-06.md` in both the Capability Catalog and Club Membership documentation.
- Enhanced the Club Membership documentation with details on product decisions and onboarding phases.
- Implemented middleware in the backend to restrict access for unverified users and those pending club membership.
- Updated versioning in `version.py` to reflect changes in account lifecycle management.
2026-06-07 05:57:13 +02:00

59 lines
1.4 KiB
Python

"""Tests für account_onboarding_gate."""
import pytest
from account_onboarding_gate import (
check_api_onboarding_gate,
is_public_api_path,
normalize_api_path,
)
def test_public_directory_is_public():
assert is_public_api_path("/api/clubs/public-directory")
def test_exercises_blocked_for_pending():
allowed, reason = check_api_onboarding_gate(
path="/api/exercises",
method="GET",
profile_id=1,
account_state="verified_pending_club",
)
assert not allowed
assert reason == "account_state_verified_pending_club"
def test_join_request_allowed_for_pending():
allowed, _ = check_api_onboarding_gate(
path="/api/me/club-join-requests",
method="POST",
profile_id=1,
account_state="verified_pending_club",
)
assert allowed
def test_active_member_domain_ok():
allowed, reason = check_api_onboarding_gate(
path="/api/exercises",
method="GET",
profile_id=1,
account_state="active_member",
)
assert allowed
assert reason is None
def test_profile_self_update_allowed_unverified():
allowed, _ = check_api_onboarding_gate(
path="/api/profiles/42",
method="PUT",
profile_id=42,
account_state="unverified",
)
assert allowed
def test_normalize_trailing_slash():
assert normalize_api_path("/api/exercises/") == "/api/exercises"