From 6f5c7822c137b9ef4b8c50bb6ea35a0ae775a4cb Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Mon, 15 Sep 2025 15:17:31 +0200 Subject: [PATCH] Fix jwt-token --- server/tests/debug-tenant.js | 50 +++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/server/tests/debug-tenant.js b/server/tests/debug-tenant.js index 8f9d40b..263329d 100644 --- a/server/tests/debug-tenant.js +++ b/server/tests/debug-tenant.js @@ -8,7 +8,7 @@ async function debugTenant() { const sequelize = new Sequelize({ dialect: 'sqlite', storage: ':memory:', - logging: console.log + logging: false // Disable logging for cleaner output }); // Load models @@ -18,15 +18,51 @@ async function debugTenant() { // Sync database await sequelize.sync({ force: true }); - console.log('Attempting to create tenant...'); - const tenant = await Tenant.create({ - name: 'Debug Tenant', - slug: 'debug-tenant-' + Date.now(), - domain: 'debug.example.com', + console.log('Attempting to create tenant1...'); + const tenant1 = await Tenant.create({ + name: 'Test Tenant 1', + slug: 'tenant1', + domain: 'test1.example.com', is_active: true }); + console.log('✅ Tenant1 created successfully:', tenant1.id); - console.log('✅ Tenant created successfully:', tenant.id); + console.log('Attempting to create tenant2...'); + const tenant2 = await Tenant.create({ + name: 'Test Tenant 2', + slug: 'tenant2', + domain: 'test2.example.com', + is_active: true + }); + console.log('✅ Tenant2 created successfully:', tenant2.id); + + // Try to create a tenant with same slug (should fail) + console.log('Attempting to create duplicate slug (should fail)...'); + try { + await Tenant.create({ + name: 'Duplicate Tenant', + slug: 'tenant1', // This should fail + domain: 'test3.example.com', + is_active: true + }); + console.log('❌ ERROR: Duplicate slug should have failed!'); + } catch (error) { + console.log('✅ Correctly caught duplicate slug error:', error.message); + } + + // Try to create a tenant with same domain (should fail) + console.log('Attempting to create duplicate domain (should fail)...'); + try { + await Tenant.create({ + name: 'Duplicate Domain Tenant', + slug: 'tenant3', + domain: 'test1.example.com', // This should fail + is_active: true + }); + console.log('❌ ERROR: Duplicate domain should have failed!'); + } catch (error) { + console.log('✅ Correctly caught duplicate domain error:', error.message); + } } catch (error) { console.log('❌ Error creating tenant:');