Fix jwt-token

This commit is contained in:
2025-09-15 10:21:49 +02:00
parent c099715540
commit caac0e59cd

View File

@@ -129,13 +129,12 @@ async function createTestUser(userData = {}) {
}); });
} }
// Generate a simple UUID-like string for testing // Generate a unique username to avoid conflicts
const testId = 'test-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9); const uniqueSuffix = Date.now() + '-' + Math.random().toString(36).substr(2, 5);
const defaultUserData = { const defaultUserData = {
id: testId, // Use explicit test ID username: userData.username || 'testuser-' + uniqueSuffix,
username: 'testuser', email: userData.email || 'test-' + uniqueSuffix + '@example.com',
email: 'test@example.com',
password_hash: '$2b$10$example.hash.for.testing.purposes.only', password_hash: '$2b$10$example.hash.for.testing.purposes.only',
role: 'admin', role: 'admin',
tenant_id: tenant.id, tenant_id: tenant.id,
@@ -215,13 +214,9 @@ async function createTestDetection(detectionData = {}) {
async function createTestTenant(tenantData = {}) { async function createTestTenant(tenantData = {}) {
const { Tenant } = models; const { Tenant } = models;
// Generate a simple test ID for tenant
const testId = 'tenant-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9);
const defaultTenantData = { const defaultTenantData = {
id: testId, // Use explicit test ID
name: 'Test Tenant', name: 'Test Tenant',
slug: 'test-tenant-' + Date.now(), slug: 'test-tenant-' + Date.now() + '-' + Math.random().toString(36).substr(2, 5),
domain: 'test.example.com', domain: 'test.example.com',
is_active: true, is_active: true,
...tenantData ...tenantData