Tork Testing Suite
A comprehensive CLI-driven testing framework for verifying SDK integrations with session-based workflows and automated certifications.
How It Works
The Testing Suite uses a session-based workflow that allows your CLI tools to run tests locally while reporting results to the Tork API for certification.
API Endpoints
POST/api/v1/testing/register
Register a new test session. Returns a session ID and test token for authentication.
POST /api/v1/testing/register
Content-Type: application/json
{
"api_key": "tork_prod_xxx", // optional, for tracking
"client_id": "my-app-v1",
"sdk_type": "python", // python|javascript|go|rust|ruby|java|mcp|docker
"sdk_version": "2.4.1",
"platform": {
"os": "darwin",
"arch": "arm64",
"runtime_version": "3.11.5"
}
}{
"session_id": "sess_abc123xyz",
"test_token": "tok_secret_token_here",
"status": "active",
"sdk_type": "python",
"sdk_version": "2.4.1",
"test_config": {
"required_tests": [
"download.package_available",
"install.pip_install",
"connectivity.api_reachable",
"authentication.api_key_valid",
"pii_detection.email",
"pii_detection.phone",
"pii_detection.ssn",
"policy.load_policies",
"policy.evaluate_request"
],
"optional_tests": [...],
"test_endpoints": { ... },
"timeout_ms": 30000,
"retry_count": 3
},
"api_base_url": "https://api.tork.ai",
"started_at": "2026-01-26T10:00:00Z",
"expires_at": "2026-01-27T10:00:00Z"
}POST/api/v1/testing/submit
Submit test results from your CLI. Can be called multiple times during a session.
POST /api/v1/testing/submit
Content-Type: application/json
{
"session_id": "sess_abc123xyz",
"test_token": "tok_secret_token_here",
"results": [
{
"category": "connectivity",
"test_name": "api_reachable",
"status": "pass", // pass|fail|skip|error
"duration_ms": 85,
"details": { "latency": 42 }
},
{
"category": "pii_detection",
"test_name": "email",
"status": "pass",
"duration_ms": 45,
"details": { "detected": true, "confidence": 0.99 }
},
{
"category": "authentication",
"test_name": "api_key_valid",
"status": "fail",
"duration_ms": 150,
"error_message": "Invalid API key format"
}
],
"complete": false // Set true when all tests are done
}GET/api/v1/testing/session/:id
Get current session status and results summary.
{
"session": {
"id": "sess_abc123xyz",
"client_id": "my-app-v1",
"sdk_type": "python",
"status": "completed",
"started_at": "2026-01-26T10:00:00Z",
"completed_at": "2026-01-26T10:01:30Z"
},
"summary": {
"total_tests": 10,
"passed": 8,
"failed": 1,
"skipped": 1,
"errors": 0,
"duration_ms": 45000,
"pass_rate": 80
},
"results_by_category": {
"connectivity": [...],
"authentication": [...],
"pii_detection": [...]
},
"certification": {
"id": "cert_xyz789",
"grade": "B",
"score": 85,
"badge_url": "/api/v1/badges/cert_xyz789"
}
}POST/api/v1/testing/certify
Request a certification after completing all tests.
POST /api/v1/testing/certify
Content-Type: application/json
{
"session_id": "sess_abc123xyz",
"test_token": "tok_secret_token_here"
}{
"certification": {
"id": "cert_xyz789abc",
"session_id": "sess_abc123xyz",
"verification_id": "ver_123456",
"grade": "A",
"score": 92,
"total_tests": 10,
"passed_tests": 9,
"failed_tests": 1,
"skipped_tests": 0,
"badge_url": "/api/v1/badges/ver_123456?type=grade-badge",
"report_url": "/verify/ver_123456",
"valid_until": "2026-02-25T10:00:00Z",
"created_at": "2026-01-26T10:01:30Z"
},
"embed_code": {
"markdown": "[](https://tork.ai/verify/ver_123456)",
"html": "<a href=\"https://tork.ai/verify/ver_123456\"><img src=\"https://tork.ai/api/v1/badges/ver_123456?type=grade-badge\" alt=\"Tork Verified A\"></a>"
}
}GET/api/v1/testing/config
Get test configuration for a specific SDK type.
GET /api/v1/testing/config?sdk_type=pythonTest Categories
Each SDK is tested across multiple categories. Required tests must pass for certification.
| Category | Tests | Weight | Description |
|---|---|---|---|
| download | package_available | 5% | Package availability on registry |
| install | pip_install, import_module | 15% | Installation verification |
| connectivity | api_reachable, ssl_valid | 20% | API connectivity checks |
| authentication | api_key_valid, permissions | 20% | API key validation |
| pii_detection | email, phone, ssn, credit_card | 20% | PII detection tests |
| policy | load_policies, evaluate_request | 15% | Policy engine tests |
| rate_limiting | retry_logic, backoff | 5% | Rate limit handling (optional) |
| webhook | delivery, signature | 5% | Webhook tests (optional) |
| mcp | tool_registration, invocation | 20% | MCP protocol tests |
| framework | langchain, openai, express | 5% | Framework integrations |
Scoring & Grades
Certification grades are based on weighted test scores:
CLI Implementation Example
Here's how to implement the testing flow in your SDK's CLI tool:
import httpx
import platform
from tork import __version__
API_BASE = "https://tork.network"
def run_verification(api_key: str = None):
# 1. Register session
session = httpx.post(f"{API_BASE}/api/v1/testing/register", json={
"api_key": api_key,
"client_id": f"tork-cli-{platform.node()}",
"sdk_type": "python",
"sdk_version": __version__,
"platform": {
"os": platform.system().lower(),
"arch": platform.machine(),
"runtime_version": platform.python_version()
}
}).json()
session_id = session["session_id"]
test_token = session["test_token"]
test_config = session["test_config"]
print(f"Started test session: {session_id}")
# 2. Run tests locally
results = []
for test in test_config["required_tests"]:
category, test_name = test.split(".")
result = run_test(category, test_name)
results.append(result)
# Submit results in batches
if len(results) >= 5:
submit_results(session_id, test_token, results)
results = []
# 3. Submit final results with complete=True
submit_results(session_id, test_token, results, complete=True)
# 4. Request certification
cert = httpx.post(f"{API_BASE}/api/v1/testing/certify", json={
"session_id": session_id,
"test_token": test_token
}).json()
print(f"\nCertification: Grade {cert['certification']['grade']}")
print(f"Score: {cert['certification']['score']}/100")
print(f"Badge: {cert['embed_code']['markdown']}")
return cert
def submit_results(session_id, test_token, results, complete=False):
httpx.post(f"{API_BASE}/api/v1/testing/submit", json={
"session_id": session_id,
"test_token": test_token,
"results": results,
"complete": complete
})Session Lifecycle
Related
Ready to Test?
Install the Tork SDK and run the verification command to get started.

