import type { SupabaseApiKey } from '../../supabase'
import { TEST_ORGS } from './organizations'

/**
 * Test API key fixtures using actual Supabase types
 * Note: key_hash is bcrypt hash of the plaintext key shown in comments
 */
export const TEST_API_KEYS: Record<string, SupabaseApiKey> = {
  acmeKey: {
    id: '00000000-0000-0000-0000-000000000030',
    organization_id: TEST_ORGS.acme.id,
    name: 'Acme Production Key',
    // Plaintext: sk_test_acme_12345
    key_hash: '$2b$10$abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOP',
    created_at: '2025-01-01T00:00:00Z',
    last_used_at: null
  },
  betaKey: {
    id: '00000000-0000-0000-0000-000000000031',
    organization_id: TEST_ORGS.beta.id,
    name: 'Beta Development Key',
    // Plaintext: sk_test_beta_67890
    key_hash: '$2b$10$zyxwvutsrqponmlkjihgfedcba0987654321ZYXWVUTSRQPONMLKJIH',
    created_at: '2025-01-01T00:00:00Z',
    last_used_at: '2025-01-02T00:00:00Z'
  }
}

/**
 * Plaintext API keys for testing (matches hashes above conceptually)
 * In real tests, use these for Authorization: Bearer headers
 */
export const TEST_API_KEY_PLAINTEXTS: Record<string, string> = {
  acmeKey: 'sk_test_acme_12345',
  betaKey: 'sk_test_beta_67890',
  invalid: 'sk_test_invalid_99999'
}

/**
 * Helper to create custom API key fixture
 */
export function createTestApiKey(overrides: Partial<SupabaseApiKey>): SupabaseApiKey {
  return {
    id: '00000000-0000-0000-0000-999999999999',
    organization_id: TEST_ORGS.acme.id,
    name: 'Custom Test Key',
    key_hash: '$2b$10$customhashvalue1234567890',
    created_at: '2025-01-01T00:00:00Z',
    last_used_at: null,
    ...overrides
  }
}
