218 lines
5.3 KiB
ReStructuredText
218 lines
5.3 KiB
ReStructuredText
@base = http://localhost:3000
|
|
@apiKey = bnt_727d2f4f72bd03ed96da5278bb971a00cb0a2454d4d70f9748b5c39f3f69d88d
|
|
|
|
###############################################################################
|
|
# LIVE URL & SCOPE MANAGEMENT TESTS
|
|
# Tests: Live generation with caching, Scope management
|
|
#
|
|
# Test Coverage:
|
|
# 1. Create live scope
|
|
# 2. List all scopes
|
|
# 3. Get scope details
|
|
# 4. Update scope settings
|
|
# 5. Live URL - basic generation
|
|
# 6. Regenerate scope images
|
|
# 7. Delete scope
|
|
###############################################################################
|
|
|
|
|
|
###############################################################################
|
|
# TEST 1: Create Live Scope
|
|
###############################################################################
|
|
|
|
### Step 1.1: Create scope
|
|
# @name createScope
|
|
POST {{base}}/api/v1/live/scopes
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{
|
|
"slug": "test-scope",
|
|
"allowNewGenerations": true,
|
|
"newGenerationsLimit": 50
|
|
}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns scope object
|
|
# - slug = "test-scope"
|
|
# - allowNewGenerations = true
|
|
# - newGenerationsLimit = 50
|
|
|
|
|
|
###############################################################################
|
|
# TEST 2: List All Scopes
|
|
###############################################################################
|
|
|
|
### Step 2.1: List scopes
|
|
# @name listScopes
|
|
GET {{base}}/api/v1/live/scopes
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns array of scopes
|
|
# - Contains "test-scope"
|
|
|
|
|
|
###############################################################################
|
|
# TEST 3: Get Scope Details
|
|
###############################################################################
|
|
|
|
### Step 3.1: Get scope by slug
|
|
# @name getScope
|
|
GET {{base}}/api/v1/live/scopes/test-scope
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns scope object
|
|
# - slug = "test-scope"
|
|
# - currentGenerations is number
|
|
|
|
|
|
###############################################################################
|
|
# TEST 4: Update Scope Settings
|
|
###############################################################################
|
|
|
|
### Step 4.1: Disable new generations
|
|
# @name updateScopeDisable
|
|
PUT {{base}}/api/v1/live/scopes/test-scope
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{
|
|
"allowNewGenerations": false,
|
|
"newGenerationsLimit": 100
|
|
}
|
|
|
|
###
|
|
# Verify:
|
|
# - allowNewGenerations = false
|
|
# - newGenerationsLimit = 100
|
|
|
|
|
|
### Step 4.2: Re-enable for testing
|
|
# @name updateScopeEnable
|
|
PUT {{base}}/api/v1/live/scopes/test-scope
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{
|
|
"allowNewGenerations": true
|
|
}
|
|
|
|
###
|
|
|
|
|
|
###############################################################################
|
|
# TEST 5: Live URL - Basic Generation
|
|
# GET /api/v1/live?prompt=...
|
|
# Returns image bytes directly with cache headers
|
|
###############################################################################
|
|
|
|
### Step 5.1: Generate via live URL
|
|
# @name liveGenerate
|
|
GET {{base}}/api/v1/live?prompt=A%20simple%20blue%20square%20on%20white%20background
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns 200
|
|
# - Response is image bytes (Content-Type: image/*)
|
|
# - X-Cache-Status header (HIT or MISS)
|
|
|
|
|
|
### Step 5.2: Same prompt again (should be cached)
|
|
# @name liveGenerateCached
|
|
GET {{base}}/api/v1/live?prompt=A%20simple%20blue%20square%20on%20white%20background
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - X-Cache-Status: HIT
|
|
# - Faster response time
|
|
|
|
|
|
### Step 5.3: Different prompt
|
|
# @name liveGenerateNew
|
|
GET {{base}}/api/v1/live?prompt=A%20red%20circle%20on%20black%20background
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - X-Cache-Status: MISS (new prompt)
|
|
|
|
|
|
### Step 5.4: With aspect ratio
|
|
# @name liveGenerateWithAspect
|
|
GET {{base}}/api/v1/live?prompt=A%20landscape%20scene&aspectRatio=16:9
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
|
|
###############################################################################
|
|
# TEST 6: Regenerate Scope Images
|
|
###############################################################################
|
|
|
|
### Step 6.1: Trigger regeneration
|
|
# @name regenerateScope
|
|
POST {{base}}/api/v1/live/scopes/test-scope/regenerate
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns 200
|
|
# - Regeneration triggered
|
|
|
|
|
|
###############################################################################
|
|
# TEST 7: Delete Scope
|
|
###############################################################################
|
|
|
|
### Step 7.1: Delete scope
|
|
# @name deleteScope
|
|
DELETE {{base}}/api/v1/live/scopes/test-scope
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns 200
|
|
|
|
|
|
### Step 7.2: Verify deleted (should 404)
|
|
# @name verifyScopeDeleted
|
|
GET {{base}}/api/v1/live/scopes/test-scope
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Expected: 404 Not Found
|
|
|
|
|
|
###############################################################################
|
|
# NOTES
|
|
###############################################################################
|
|
#
|
|
# Live URL Endpoint:
|
|
# - GET /api/v1/live?prompt=...
|
|
# - Returns image bytes directly (not JSON)
|
|
# - Supports prompt caching via SHA-256 hash
|
|
#
|
|
# Response Headers:
|
|
# - Content-Type: image/jpeg (or image/png, etc.)
|
|
# - X-Cache-Status: HIT | MISS
|
|
# - X-Cache-Hit-Count: number (on HIT)
|
|
# - X-Generation-Id: UUID (on MISS)
|
|
# - X-Image-Id: UUID
|
|
# - Cache-Control: public, max-age=31536000
|
|
#
|
|
# Scope Management:
|
|
# - Scopes group generations for management
|
|
# - allowNewGenerations controls if new prompts generate
|
|
# - newGenerationsLimit caps generations per scope
|
|
#
|