Platform Testing & Validationg

Pre-Flight Checklist

Before going live, verify each integration point:

  • Database

    • All three tables exist (tenants, employees, sessions)
    • Indexes created for performance
    • clear_user_id column exists on employees table
    • initial_project_id and reverification_project_id exist on tenants table
  • API Credentials

    • CLEAR API key validates (test with create_session call)
    • Initial project ID exists and is not archived
    • Reverification project ID exists and is not archived
    • Environment variables load correctly
  • Test Data

    • Test tenant exists with valid CLEAR credentials
    • Test employees exist with matching first/last names
    • At least one employee has clear_user_id NULL (for UPM test)
    • At least one employee has clear_user_id populated (for Known User Key test)
  • Endpoints

    • POST /api/[company]/create-session returns token
    • GET /api/[company]/verification/[sessionId] returns status
    • Error responses include helpful messages
  • UI

    • Verification page loads tenant logo
    • Employee ID input validates format
    • CLEAR redirect works with token
    • Confirmation page polls for results

Test Scenarios

Scenario 1: First-Time Verification (User Profile Matching)

Setup:

  • Employee record with clear_user_id = NULL
  • First name: "John"
  • Last name: "Doe"
  • Employee ID: "123456"

Steps:

  1. Navigate to /{company}/verify
  2. Enter employee ID: "123456"
  3. Click "Verify with CLEAR"
  4. Complete CLEAR verification with selfie + ID
  5. Redirected to confirmation page

Expected Results:

  • ✅ Session created with initial_project_id
  • user_profile_information sent with first_name and last_name
  • ✅ CLEAR matches biometric to provided name
  • ✅ Status changes from pendingcomplete
  • user_id returned from CLEAR (e.g., user_abc123)
  • clear_user_id saved to employee record in database
  • ✅ Confirmation page shows "Thank you, John!"

How to Verify:

-- Check employee record
SELECT employee_id, clear_user_id FROM employees WHERE employee_id = '123456';
-- Should show: clear_user_id = 'user_abc123' (not NULL)

-- Check session record
SELECT status, clear_user_id FROM sessions WHERE employee_id = (SELECT id FROM employees WHERE employee_id = '123456') ORDER BY created_at DESC LIMIT 1;
-- Should show: status = 'complete', clear_user_id = 'user_abc123'

Scenario 2: Return Verification (Known User Key)

Setup:

  • Same employee from Scenario 1 (now has clear_user_id = 'user_abc123')

Steps:

  1. Navigate to /{company}/verify
  2. Enter employee ID: "123456"
  3. Click "Verify with CLEAR"
  4. Complete CLEAR verification (selfie only, faster)
  5. Redirected to confirmation page

Expected Results:

  • ✅ Session created with reverification_project_id
  • user_id sent (not user_profile_information)
  • ✅ CLEAR skips ID capture, only takes selfie
  • ✅ Verification completes faster (~10-15 seconds vs 30-45 seconds)
  • ✅ Status changes from pendingcomplete
  • ✅ Same user_id returned
  • ✅ Confirmation page shows "Thank you, John!"

How to Verify:

-- Check routing logic worked
SELECT clear_session_id FROM sessions WHERE employee_id = (SELECT id FROM employees WHERE employee_id = '123456') ORDER BY created_at DESC LIMIT 1;
-- Then use CLEAR API to check which project_id was used

Scenario 3: Employee Not Found

Steps:

  1. Navigate to /{company}/verify
  2. Enter employee ID: "999999" (doesn't exist)
  3. Click "Verify with CLEAR"

Expected Results:

  • ✅ Error message: "Employee not found. Please contact your administrator."
  • ✅ No CLEAR session created
  • ✅ No redirect happens

Scenario 4: Invalid API Credentials

Setup:

  • Temporarily change API key to invalid value

Expected Results:

  • ✅ Error message: "Failed to create verification session"
  • ✅ Error logged with 401 response from CLEAR
  • ✅ User sees helpful error message

Scenario 5: Biometric Mismatch

Setup:

  • Employee with first_name "Jane", last_name "Smith"
  • User completes CLEAR verification but name on ID is "John Doe"

Expected Results:

  • ✅ CLEAR returns status: 'failed'
  • ✅ No user_id returned
  • clear_user_id remains NULL on employee record
  • ✅ User sees error message explaining verification failed

Scenario 6: User Abandons Verification

Setup:

  • User starts verification but closes browser before completing

Expected Results:

  • ✅ Session status remains pending
  • ✅ When user returns and starts new session, old session stays pending
  • ✅ New session can be created without issues

Common Integration Bugs

BugSymptomRoot CauseFix
user_id not savingSecond verification still requires IDResults endpoint not saving user_id to employee recordCheck that clear_user_id update happens after status='complete'
Wrong project usedAlways shows ID capture, even on second verificationRouting logic not checking clear_user_idEnsure isReverification = !!employee.clear_user_id check works
Biometric matching failsStatus returns 'failed' on valid verificationFirst/last name mismatch between employee record and IDEnsure employee.first_name and employee.last_name match ID exactly
API returns 401"Invalid authentication" errorWrong API key or missing Bearer prefixCheck Authorization header: Bearer ${apiKey}
API returns 400"Project does not exist"Wrong project_id or project archivedVerify project_id in CLEAR dashboard, check for typos
Redirect failsUser stuck on verification pageInvalid redirect_url or CORS issueEnsure redirect_url is publicly accessible, matches protocol (http/https)
Polling times outConfirmation page never loadsResults endpoint not polling CLEAR APICheck that getVerificationSession() is called in polling loop
Duplicate employeesSame employee_id exists twiceNo UNIQUE constraint on (tenant_id, employee_id)Add constraint: UNIQUE(tenant_id, employee_id)
Session status stuckStatus never changes from pendingCLEAR session never completedCheck CLEAR dashboard for session status, verify user completed flow
No traits returnedVerified data missing from responseProject configuration doesn't request traitsUpdate project settings in CLEAR dashboard to request specific traits

Troubleshooting Decision Trees

Decision Tree 1: Verification Session Creation Fails

Session creation fails
├─ HTTP 401 "Invalid authentication"
│  ├─ Check: API key correct in .env?
│  ├─ Check: Authorization header includes "Bearer " prefix?
│  └─ Fix: Verify credentials in CLEAR dashboard
│
├─ HTTP 400 "Project does not exist or is archived"
│  ├─ Check: Project ID matches CLEAR dashboard?
│  ├─ Check: Project archived or deleted?
│  └─ Fix: Use correct project_id or create new project
│
├─ HTTP 400 "Traits for user profile matching do not match project configuration"
│  ├─ Check: Sending first_name and last_name?
│  ├─ Check: Project configured for User Profile Matching?
│  └─ Fix: Update project settings or send correct traits
│
└─ HTTP 500 or network error
   ├─ Check: Can reach https://verified.clearme.com?
   ├─ Check: Firewall/proxy blocking requests?
   └─ Fix: Check network connectivity, update firewall rules

Decision Tree 2: user_id Not Saving to Employee Record

Second verification still requires ID capture
├─ Check database: Does employee.clear_user_id have value?
│  ├─ YES → Routing logic broken
│  │  ├─ Check: isReverification = !!employee.clear_user_id?
│  │  ├─ Check: Sending user_id instead of user_profile_information?
│  │  └─ Fix: Update create-session routing logic
│  │
│  └─ NO → user_id never saved
│     ├─ Check: First verification completed successfully?
│     │  ├─ Query sessions table: status = 'complete'?
│     │  └─ If pending: User never finished CLEAR flow
│     │
│     ├─ Check: CLEAR returned user_id in response?
│     │  ├─ Call GET /verification_sessions/{id}
│     │  └─ If no user_id: CLEAR session failed
│     │
│     └─ Check: Results endpoint saving user_id?
│        ├─ Add logging to update query
│        ├─ Check for SQL errors
│        └─ Fix: Ensure update happens when status='complete' AND user_id exists

Decision Tree 3: Biometric Matching Fails

Verification returns status='failed'
├─ Check CLEAR response for failure reason
│  ├─ "Biometric match failed"
│  │  ├─ Name on ID doesn't match user_profile_information
│  │  ├─ Check: employee.first_name exactly matches ID?
│  │  ├─ Check: employee.last_name exactly matches ID?
│  │  └─ Fix: Update employee record or ask user to use correct ID
│  │
│  ├─ "ID verification failed"
│  │  ├─ ID expired or invalid
│  │  ├─ ID photo quality too low
│  │  └─ Fix: Ask user to use valid government-issued ID
│  │
│  └─ "Liveness detection failed"
│     ├─ Selfie appeared to be photo of photo
│     ├─ Multiple faces detected
│     └─ Fix: Ask user to complete selfie in good lighting, alone
│
└─ No failure reason in response
   ├─ Check project configuration
   ├─ Contact CLEAR support
   └─ Provide session_id for debugging


Did this page help you?