015c622016
Add 162 integration tests covering authentication flows, TOTP MFA, SSH key/certificate management, organization workflows, multi-org access, self-service features, admin operations, authorization, security edge cases, department/principal management, CA management, policy compliance, WebAuthn passkeys, and ZeroTier network access. Includes: - Reusable API client library with session management - Test fixtures for users, organizations, memberships, and CAs - Helper functions for SSH key generation and verification - Documentation for running and writing tests Also update test configuration to disable conflicting maas plugins and configure WebAuthn/session settings for localhost testing.
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""Users (self-service) client for integration tests."""
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class UsersClient:
|
|
"""Wraps user self-service API calls."""
|
|
|
|
def __init__(self, client):
|
|
self._client = client
|
|
|
|
def get_profile(self) -> dict:
|
|
"""Get the current user's profile."""
|
|
return self._client.get("/users/me")
|
|
|
|
def update_profile(self, **fields) -> dict:
|
|
"""Update profile fields (full_name, avatar_url)."""
|
|
return self._client.patch("/users/me", data=fields)
|
|
|
|
def change_password(self, current_password: str, new_password: str, new_password_confirm: str) -> dict:
|
|
"""Change the current user's password."""
|
|
return self._client.post(
|
|
"/users/me/password",
|
|
data={
|
|
"current_password": current_password,
|
|
"new_password": new_password,
|
|
"new_password_confirm": new_password_confirm,
|
|
},
|
|
)
|
|
|
|
def delete_account(self) -> dict:
|
|
"""Soft-delete the current user's account."""
|
|
return self._client.delete("/users/me")
|
|
|
|
def get_my_organizations(self) -> dict:
|
|
"""List organizations the current user belongs to."""
|
|
return self._client.get("/users/me/organizations")
|
|
|
|
def get_my_memberships(self) -> dict:
|
|
"""List detailed memberships across orgs."""
|
|
return self._client.get("/users/me/memberships")
|
|
|
|
def get_my_principals(self) -> dict:
|
|
"""List principals the current user has access to."""
|
|
return self._client.get("/users/me/principals")
|
|
|
|
def get_my_invites(self) -> dict:
|
|
"""List pending invites for the current user."""
|
|
return self._client.get("/users/me/invites")
|