testzeus-auth#

Authentication, profile management, and session handling for TestZeus.

Category: infrastructure · Version: 1.0.0 · Requires: testzeus-installation

Triggers: login, logout, authenticate, whoami, switch profile, change account, check auth, multiple workspaces, credentials, session, authentication

Overview#

This skill guides you through authentication with TestZeus, including profile management, session handling, and troubleshooting auth issues.

Quick Reference#

# Login
testzeus auth login

# Check status
testzeus auth whoami

# Logout
testzeus auth logout

# Use profile
testzeus --profile dev tests list

Authentication Methods#

1. Interactive Login (CLI)#

# Basic login
testzeus auth login

# Login with specific profile
testzeus auth login --profile work

# Login to specific API endpoint
testzeus auth login --api-url https://prod.testzeus.app/api

You’ll be prompted for:

  • Email address

  • Password (hidden input)

2. Environment Variables (SDK/CI)#

export TESTZEUS_EMAIL="[email protected]"
export TESTZEUS_PASSWORD="your-password"

Or in your Python code:

import os
os.environ["TESTZEUS_EMAIL"] = "[email protected]"
os.environ["TESTZEUS_PASSWORD"] = "your-password"

3. Programmatic Login (SDK)#

from testzeus_sdk import TestZeusClient

# Direct credentials
client = TestZeusClient(
    email="[email protected]",
    password="your-password"
)

# Or with custom base URL
client = TestZeusClient(
    email="[email protected]",
    password="your-password",
    base_url="https://prod.testzeus.app/api"
)

Profile Management#

Creating Profiles#

Profiles allow you to switch between different TestZeus environments/accounts:

# Create new profile
testzeus auth login --profile dev

# Profile for staging environment
testzeus auth login --profile staging

# Profile for production
testzeus auth login --profile prod

Using Profiles#

# Run commands with specific profile
testzeus --profile dev tests list
testzeus --profile prod tests list

# Set default profile
# Edit ~/.testzeus/config.yaml

Listing Profiles#

# View config file
cat ~/.testzeus/config.yaml

Sample config:

default:
  base_url: https://prod.testzeus.app/api

profiles:
  dev:
    base_url: https://prod.testzeus.app/api
  staging:
    base_url: https://prod.testzeus.app/api

Session Management#

Check Current Session#

testzeus auth whoami

Output:

Logged in as: user@example.com
Tenant: My Company
Profile: default
Session expires: 2025-12-31 23:59:59

Logout#

# Logout from current profile
testzeus auth logout

# Logout from specific profile
testzeus --profile dev auth logout

Session Persistence#

  • Credentials stored in system keyring (secure)

  • Session tokens cached locally

  • Automatic token refresh when possible

SDK Authentication#

Async Client#

import asyncio
from testzeus_sdk import TestZeusClient

async def main():
    async with TestZeusClient() as client:
        # Client is now authenticated
        tests = await client.tests.get_list(limit=10)
        print(f"Found {tests['total']} tests")

asyncio.run(main())

Context Manager Pattern#

from testzeus_sdk import TestZeusClient

# Automatically handles login/logout
async with TestZeusClient(email="[email protected]", password="pass") as client:
    # Work with authenticated client
    pass

Manual Authentication#

from testzeus_sdk import TestZeusClient

client = TestZeusClient()
await client.authenticate("[email protected]", "password")
# ... use client ...
client.logout()

Troubleshooting#

Authentication Failed#

Error: Authentication failed: Invalid credentials

Solutions:

  1. Check email/password are correct

  2. Reset password at https://app.testzeus.ai/reset-password

  3. Ensure Caps Lock is off

  4. Try re-entering credentials

Session Expired#

Error: Session expired, please login again

Solutions:

# Re-authenticate
testzeus auth logout
testzeus auth login

# Or force token refresh
testzeus --force-auth tests list

Profile Issues#

Error: Profile 'xyz' not found

Solutions:

# List available profiles
cat ~/.testzeus/config.yaml

# Create missing profile
testzeus auth login --profile xyz

Wrong Tenant/Workspace#

Issue: Seeing tests/data from wrong workspace

Solutions:

# Check current tenant
testzeus auth whoami

# Login to correct tenant
testzeus auth login --profile work

# Or explicitly specify
testzeus --profile work tests list

API Key Authentication (Advanced)#

If your organization uses API keys:

export TESTZEUS_API_KEY="your-api-key"
testzeus tests list

SDK:

client = TestZeusClient(api_key="your-api-key")

Security Best Practices#

  1. Never commit credentials - Use environment variables

  2. Use profiles - Separate dev/prod credentials

  3. Rotate passwords - Regularly update passwords

  4. Use keyring - CLI stores credentials securely

  5. Audit sessions - Check whoami before sensitive operations

Environment Variable Reference#

Variable

Description

Required

TESTZEUS_EMAIL

User email

For SDK

TESTZEUS_PASSWORD

User password

For SDK

TESTZEUS_BASE_URL

API base URL

No (has default)

TESTZEUS_API_KEY

API key

Alternative to password

TESTZEUS_PROFILE

Default profile

No

Component Schema#

Use the AuthStatus component:

{
  "component": "AuthStatus",
  "props": {
    "authenticated": true,
    "email": "[email protected]",
    "tenant": "My Company",
    "profile": "default",
    "expires_at": "2025-12-31T23:59:59Z"
  }
}