test descriptions
This commit is contained in:
@@ -24,6 +24,8 @@ HIVE_SECRET = "test-hive-secret"
|
||||
|
||||
|
||||
def test_first_account_is_admin_then_users():
|
||||
"First account is admin then users\n\nTags: accounts, auth, http"
|
||||
|
||||
store = AccountStore()
|
||||
first = store.register(email="admin@example.com", password="secret-123")
|
||||
second = store.register(email="user@example.com", password="secret-123")
|
||||
@@ -32,6 +34,8 @@ def test_first_account_is_admin_then_users():
|
||||
|
||||
|
||||
def test_register_requires_email_or_wallet_and_password_length():
|
||||
"Register requires email or wallet and password length\n\nTags: accounts, auth, http, security, wallet"
|
||||
|
||||
store = AccountStore()
|
||||
with pytest.raises(ValueError, match="email or a wallet"):
|
||||
store.register(password="secret-123")
|
||||
@@ -42,6 +46,8 @@ def test_register_requires_email_or_wallet_and_password_length():
|
||||
|
||||
|
||||
def test_register_rejects_duplicate_identifiers():
|
||||
"Register rejects duplicate identifiers\n\nTags: accounts, auth, http"
|
||||
|
||||
store = AccountStore()
|
||||
store.register(email="dup@example.com", password="secret-123")
|
||||
with pytest.raises(ValueError, match="already exists"):
|
||||
@@ -49,6 +55,8 @@ def test_register_rejects_duplicate_identifiers():
|
||||
|
||||
|
||||
def test_register_and_update_nickname():
|
||||
"Register and update nickname\n\nTags: accounts, auth, http"
|
||||
|
||||
store = AccountStore()
|
||||
account = store.register(
|
||||
email="nick@example.com",
|
||||
@@ -63,6 +71,8 @@ def test_register_and_update_nickname():
|
||||
|
||||
|
||||
def test_nickname_replicates_across_stores():
|
||||
"Nickname replicates across stores\n\nTags: accounts, auth, http"
|
||||
|
||||
leader = AccountStore()
|
||||
follower = AccountStore()
|
||||
account = leader.register(
|
||||
@@ -79,6 +89,8 @@ def test_nickname_replicates_across_stores():
|
||||
|
||||
|
||||
def test_login_by_email_or_wallet():
|
||||
"Login by email or wallet\n\nTags: accounts, auth, http, security, wallet"
|
||||
|
||||
store = AccountStore()
|
||||
account = store.register(
|
||||
email="both@example.com", wallet="WalletXYZ", password="secret-123"
|
||||
@@ -90,6 +102,8 @@ def test_login_by_email_or_wallet():
|
||||
|
||||
|
||||
def test_sessions_resolve_and_destroy():
|
||||
"Sessions resolve and destroy\n\nTags: accounts, auth, http"
|
||||
|
||||
store = AccountStore()
|
||||
account = store.register(email="s@example.com", password="secret-123")
|
||||
token = store.create_session(account["account_id"])
|
||||
@@ -100,6 +114,8 @@ def test_sessions_resolve_and_destroy():
|
||||
|
||||
|
||||
def test_sessions_persist_across_restart(tmp_path):
|
||||
"Sessions persist across restart\n\nTags: accounts, auth, http, persistence"
|
||||
|
||||
db = str(tmp_path / "accounts.db")
|
||||
store = AccountStore(db_path=db)
|
||||
account = store.register(email="cookie@example.com", password="secret-123")
|
||||
@@ -111,6 +127,8 @@ def test_sessions_persist_across_restart(tmp_path):
|
||||
|
||||
|
||||
def test_api_key_lifecycle():
|
||||
"Api key lifecycle\n\nTags: accounts, auth, http"
|
||||
|
||||
store = AccountStore()
|
||||
account = store.register(email="k@example.com", password="secret-123")
|
||||
other = store.register(email="other@example.com", password="secret-123")
|
||||
@@ -125,6 +143,8 @@ def test_api_key_lifecycle():
|
||||
|
||||
|
||||
def test_accounts_persist_across_restart(tmp_path):
|
||||
"Accounts persist across restart\n\nTags: accounts, auth, http, persistence"
|
||||
|
||||
db = str(tmp_path / "accounts.db")
|
||||
store = AccountStore(db_path=db)
|
||||
account = store.register(email="p@example.com", password="secret-123")
|
||||
@@ -137,6 +157,8 @@ def test_accounts_persist_across_restart(tmp_path):
|
||||
|
||||
|
||||
def test_account_events_replicate_and_dedupe():
|
||||
"Account events replicate and dedupe\n\nTags: accounts, auth, http"
|
||||
|
||||
leader = AccountStore()
|
||||
follower = AccountStore()
|
||||
account = leader.register(email="r@example.com", password="secret-123")
|
||||
@@ -182,6 +204,8 @@ def account_tracker():
|
||||
|
||||
|
||||
def test_register_login_and_account_view(account_tracker):
|
||||
"Register login and account view\n\nTags: accounts, auth, http"
|
||||
|
||||
url, _ = account_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "admin@example.com", "password": "secret-123"})
|
||||
@@ -201,6 +225,8 @@ def test_register_login_and_account_view(account_tracker):
|
||||
|
||||
|
||||
def test_account_usage_endpoint_returns_records(account_tracker):
|
||||
"Account usage endpoint returns records\n\nTags: accounts, auth, http"
|
||||
|
||||
url, ledger = account_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "usage@example.com", "password": "secret-123"})
|
||||
@@ -213,6 +239,8 @@ def test_account_usage_endpoint_returns_records(account_tracker):
|
||||
|
||||
|
||||
def test_account_nickname_register_and_profile_update(account_tracker):
|
||||
"Account nickname register and profile update\n\nTags: accounts, auth, http"
|
||||
|
||||
url, _ = account_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST", {
|
||||
"email": "nick@example.com",
|
||||
@@ -234,6 +262,8 @@ def test_account_nickname_register_and_profile_update(account_tracker):
|
||||
|
||||
|
||||
def test_login_sets_cookie_and_cookie_auth_survives_tracker_restart(tmp_path):
|
||||
"Login sets cookie and cookie auth survives tracker restart\n\nTags: accounts, auth, http, security"
|
||||
|
||||
accounts_db = str(tmp_path / "accounts.db")
|
||||
tracker = TrackerServer(
|
||||
billing=BillingLedger(starting_credit=0.0, default_price_per_1k=0.02),
|
||||
@@ -287,6 +317,8 @@ def test_login_sets_cookie_and_cookie_auth_survives_tracker_restart(tmp_path):
|
||||
|
||||
|
||||
def test_bad_credentials_and_missing_session_are_401(account_tracker):
|
||||
"Bad credentials and missing session are 401\n\nTags: accounts, auth, http"
|
||||
|
||||
url, _ = account_tracker
|
||||
_call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "a@example.com", "password": "secret-123"})
|
||||
@@ -300,6 +332,8 @@ def test_bad_credentials_and_missing_session_are_401(account_tracker):
|
||||
|
||||
|
||||
def test_key_create_revoke_and_revoked_key_rejected_by_proxy(account_tracker):
|
||||
"Key create revoke and revoked key rejected by proxy\n\nTags: accounts, auth, http"
|
||||
|
||||
url, _ = account_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "k@example.com", "password": "secret-123"})
|
||||
@@ -318,6 +352,8 @@ def test_key_create_revoke_and_revoked_key_rejected_by_proxy(account_tracker):
|
||||
|
||||
|
||||
def test_admin_listing_requires_admin_role(account_tracker):
|
||||
"Admin listing requires admin role\n\nTags: accounts, auth, http"
|
||||
|
||||
url, _ = account_tracker
|
||||
admin = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "admin@example.com", "password": "secret-123"})
|
||||
@@ -337,6 +373,8 @@ def test_admin_listing_requires_admin_role(account_tracker):
|
||||
|
||||
|
||||
def test_accounts_gossip_endpoint_applies_events(account_tracker):
|
||||
"Accounts gossip endpoint applies events\n\nTags: accounts, auth, gossip, http, network"
|
||||
|
||||
url, _ = account_tracker
|
||||
peer = AccountStore()
|
||||
peer.register(email="remote@example.com", password="secret-123")
|
||||
@@ -356,6 +394,8 @@ def test_accounts_gossip_endpoint_applies_events(account_tracker):
|
||||
|
||||
|
||||
def test_accounts_endpoints_404_when_disabled():
|
||||
"Accounts endpoints 404 when disabled\n\nTags: accounts, auth, http"
|
||||
|
||||
tracker = TrackerServer() # no accounts, no billing
|
||||
port = tracker.start()
|
||||
try:
|
||||
@@ -387,6 +427,8 @@ def funded_tracker():
|
||||
|
||||
|
||||
def test_caller_credit_granted_once_per_account(funded_tracker):
|
||||
"Caller credit granted once per account\n\nTags: accounts, auth, http"
|
||||
|
||||
url, ledger = funded_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "c@example.com", "password": "secret-123"})
|
||||
@@ -405,6 +447,8 @@ def test_caller_credit_granted_once_per_account(funded_tracker):
|
||||
|
||||
|
||||
def test_unknown_bearer_key_rejected_by_proxy(funded_tracker):
|
||||
"Unknown bearer key rejected by proxy\n\nTags: accounts, auth, http"
|
||||
|
||||
url, ledger = funded_tracker
|
||||
with pytest.raises(urllib.error.HTTPError) as exc_info:
|
||||
_call(f"{url}/v1/chat/completions", "POST",
|
||||
@@ -416,6 +460,8 @@ def test_unknown_bearer_key_rejected_by_proxy(funded_tracker):
|
||||
|
||||
|
||||
def test_devnet_topup_credits_own_key_only(funded_tracker):
|
||||
"Devnet topup credits own key only\n\nTags: accounts, auth, http"
|
||||
|
||||
url, ledger = funded_tracker
|
||||
owner = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "own@example.com", "password": "secret-123"})
|
||||
@@ -438,6 +484,8 @@ def test_devnet_topup_credits_own_key_only(funded_tracker):
|
||||
|
||||
|
||||
def test_topup_404_when_disabled(account_tracker):
|
||||
"Topup 404 when disabled\n\nTags: accounts, auth, http"
|
||||
|
||||
url, _ = account_tracker
|
||||
reg = _call(f"{url}/v1/auth/register", "POST",
|
||||
{"email": "t@example.com", "password": "secret-123"})
|
||||
|
||||
Reference in New Issue
Block a user