Skip to main content

SmartTest CLI - Execute test scenarios with secure credential handling

Project description

SmartTest CLI

Enterprise-ready CLI for executing test scenarios with secure, zero-credential-exposure architecture.

Features

๐Ÿ”’ Zero Credential Exposure: Auth tokens never leave your network โšก Concurrent Execution: Run up to 5 scenarios simultaneously ๐ŸŽฏ Continue-on-Error: Individual failures don't stop execution ๐Ÿ“Š Real-time Progress: Live progress updates with rich terminal output ๐Ÿ“„ CI Integration: JUnit XML reports for CI/CD pipelines ๐ŸŒ Network Aware: Proxy and custom CA support for enterprise networks

Installation

Install the CLI from PyPI:

pip install smarttest-cli

Get Your PAT Token

  1. Visit the SmartTest platform: https://ai-smart-test.vercel.app/
  2. Sign up or log in to your account
  3. Navigate to Settings โ†’ API Tokens
  4. Click Generate PAT Token
  5. Copy your Personal Access Token (PAT)

What is a PAT Token? A Personal Access Token (PAT) authenticates the CLI with the SmartTest backend. It allows the CLI to fetch test scenarios and submit results securely. This token is separate from any credentials needed to test your APIs.

Quick Start

1. Set Your PAT Token

export SMARTTEST_TOKEN=your_pat_token_here

2. Run Test Scenarios

# Run a specific scenario
python smarttest.py run --scenario-id 123

# Run all scenarios for an endpoint
python smarttest.py run --endpoint-id 456

# Run all scenarios for a system
python smarttest.py run --system-id 789

# With JUnit XML report for CI
python smarttest.py run --system-id 789 --report junit.xml

Configuration

Optional Configuration File

Create .smarttest.yml in your project root for advanced configuration:

# API Configuration
api_url: "https://api.smarttest.com"

# Execution Settings
concurrency: 5
timeout: 30

# Enterprise Network Settings
proxy:
  http_proxy: "http://proxy.company.com:8080"
  https_proxy: "https://proxy.company.com:8080"

tls:
  ca_bundle_path: "/path/to/ca-bundle.pem"
  verify_ssl: true

Configuration Options:

  • api_url: SmartTest API endpoint (default: https://api.smarttest.com)
  • concurrency: Number of scenarios to run in parallel (default: 5)
  • timeout: Request timeout in seconds (default: 30)
  • proxy: HTTP/HTTPS proxy settings for corporate networks
  • tls: Custom CA bundle and SSL verification options

Authentication

SmartTest Authentication (Required)

The CLI requires a Personal Access Token (PAT) to authenticate with SmartTest:

export SMARTTEST_TOKEN=your_pat_token_here

How to get your PAT token:

  1. Visit https://ai-smart-test.vercel.app/
  2. Go to Settings โ†’ API Tokens
  3. Generate a new PAT token
  4. Copy and save it securely

Zero-Credential Exposure (Advanced)

When testing APIs that require authentication, SmartTest uses a zero-credential-exposure model to keep your API credentials secure.

How It Works

  1. SmartTest backend sends auth config references (metadata only, no actual credentials)
  2. CLI resolves credentials locally from your environment variables
  3. Credentials never leave your network or reach SmartTest servers
  4. Requests are made directly from your environment to the target API

Setting Up Target API Credentials

Only needed if you're testing APIs that require authentication:

# Bearer Token Authentication
export AUTH_CONFIG_123_TOKEN=your_api_bearer_token

# Basic Authentication
export AUTH_CONFIG_456_USERNAME=api_username
export AUTH_CONFIG_456_PASSWORD=api_password

# API Key Authentication
export AUTH_CONFIG_789_API_KEY=your_api_key

Pattern: AUTH_CONFIG_{ID}_{CREDENTIAL_TYPE}

  • {ID}: Auth configuration ID from SmartTest dashboard
  • {CREDENTIAL_TYPE}: TOKEN, USERNAME, PASSWORD, or API_KEY

Example Scenario:

  • You're testing your company's API at https://api.company.com
  • The API requires a bearer token for authentication
  • SmartTest knows the API needs auth (config ID: 123)
  • You set: export AUTH_CONFIG_123_TOKEN=company_bearer_token_xyz
  • CLI resolves the token locally and includes it in requests
  • SmartTest never sees company_bearer_token_xyz

CI/CD Integration

GitHub Actions

- name: Run SmartTest
  env:
    SMARTTEST_TOKEN: ${{ secrets.SMARTTEST_TOKEN }}
    API_TOKEN: ${{ secrets.API_TOKEN }}
  run: |
    python smarttest.py run --system-id 123 --report junit.xml

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Install SmartTest CLI
        run: pip install smarttest-cli

      - name: Run API Tests
        env:
          # PAT token for SmartTest authentication
          SMARTTEST_TOKEN: ${{ secrets.SMARTTEST_TOKEN }}
        run: |
          smarttest --system-id 123 --report junit.xml

      - name: Publish Test Results
        uses: dorny/test-reporter@v1
        if: always()
        with:
          name: SmartTest Results
          path: junit.xml
          reporter: java-junit

Jenkins

Basic Pipeline:

pipeline {
    agent any
    environment {
        // PAT token for SmartTest authentication
        SMARTTEST_TOKEN = credentials('smarttest-token')
        API_TOKEN = credentials('api-token')
    }
    stages {
        stage('Test') {
            steps {
                sh 'python smarttest.py run --system-id 123 --report junit.xml'
            }
            post {
                always {
                    junit 'junit.xml'
                }
            }
        }
    }
}

Example Output

$ python smarttest.py run --system-id 123
๐Ÿ” Found 25 scenarios (3 skipped - no validations)
โšก Executing scenarios... โœ… 18 passed, โŒ 3 failed, โš ๏ธ 1 errors [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] 22/22 โ€ข 0:00:15

Results:
โœ… 18 passed
โŒ 3 failed (validation errors)
โš ๏ธ  1 error (network timeout)

Failed scenarios:
  - user_login_invalid: Expected status 401, got 200
  - payment_process: Response missing required field 'transaction_id'

Error scenarios:
  - webhook_callback: Connection timeout after 30s

Summary: 18/22 scenarios passed (81.8% success rate)
Execution time: 15.2s

Error Handling

The CLI provides comprehensive error classification:

  • โœ… Success: HTTP request succeeded, all validations passed
  • โŒ Failed: HTTP request succeeded, but validations failed
  • โš ๏ธ Network Timeout: Request timed out
  • โš ๏ธ Network Error: Connection failed
  • โš ๏ธ Auth Error: Authentication resolution failed
  • โš ๏ธ Unknown Error: Unexpected error occurred

Architecture

โ”Œโ”€ Scenario Discovery (API with rate limiting)
โ”œโ”€ Skip scenarios without validations
โ”œโ”€ Concurrent Execution (max 5)
โ”‚  โ”œโ”€ Fetch definition (auth config references only)
โ”‚  โ”œโ”€ Resolve auth locally (zero credential exposure)
โ”‚  โ”œโ”€ Execute HTTP request (with comprehensive error handling)
โ”‚  โ””โ”€ Submit results (continue on any error)
โ””โ”€ Generate reports and exit

Troubleshooting

Authentication Issues

SmartTest Authentication:

# Verify your PAT token is set
echo $SMARTTEST_TOKEN

# Test connection to SmartTest
curl -H "Authorization: Bearer $SMARTTEST_TOKEN" https://api.smarttest.com/health

Target API Authentication:

# Verify target API credentials are set
echo $AUTH_CONFIG_123_TOKEN

# Check which auth configs your scenarios use in the SmartTest dashboard

Network Issues

# Test with custom config
python smarttest.py run --scenario-id 123 --config .smarttest.yml

# Enable request debugging
SMARTTEST_DEBUG=1 python smarttest.py run --scenario-id 123

Rate Limiting

The CLI automatically handles rate limiting with exponential backoff. If you encounter persistent rate limiting:

  1. Reduce concurrency in .smarttest.yml
  2. Contact support to increase rate limits
  3. Spread execution across longer time periods

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smarttest_cli-0.1.3.tar.gz (85.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smarttest_cli-0.1.3-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file smarttest_cli-0.1.3.tar.gz.

File metadata

  • Download URL: smarttest_cli-0.1.3.tar.gz
  • Upload date:
  • Size: 85.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for smarttest_cli-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c4a80db01abd0400387d09e20b8c41aa379af5e6b062d01e74c99fbffadb5eff
MD5 3bf18787011b6c4cef14c8b80be56c7c
BLAKE2b-256 8d5cf61550d83aceeaa1785032ad04d8f34a1fc085bb1efc17857c30cc7491c8

See more details on using hashes here.

File details

Details for the file smarttest_cli-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: smarttest_cli-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for smarttest_cli-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6f4f0105d452c7a84adce3b1343b4ab92e572753bc78cb2da6373de1f73ce27f
MD5 98914d37b957e498e445388bf4fc5005
BLAKE2b-256 16e41e6578eb74f3d779323d730637d702b8a7e818ae9e3e2dab023a80c2e3cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page