Fix jwt-token

This commit is contained in:
2025-09-15 12:22:01 +02:00
parent 5b0c0bdd51
commit 64a5229025

View File

@@ -118,14 +118,15 @@ async function cleanDatabase() {
async function createTestUser(userData = {}) {
const { User, Tenant } = models;
// Create default tenant if not exists
let tenant = await Tenant.findOne({ where: { slug: 'test-tenant' } });
// Create default tenant if not exists with unique domain
const userUniqueSuffix = Date.now() + '-' + Math.random().toString(36).substr(2, 5);
let tenant = await Tenant.findOne({ where: { slug: 'test-tenant-' + userUniqueSuffix } });
if (!tenant) {
try {
tenant = await Tenant.create({
name: 'Test Tenant',
slug: 'test-tenant',
domain: 'test.example.com',
slug: 'test-tenant-' + userUniqueSuffix,
domain: 'test-' + userUniqueSuffix + '.example.com',
is_active: true
});
} catch (error) {
@@ -157,13 +158,14 @@ async function createTestUser(userData = {}) {
async function createTestDevice(deviceData = {}) {
const { Device, Tenant } = models;
// Create default tenant if not exists
let tenant = await Tenant.findOne({ where: { slug: 'test-tenant' } });
// Create default tenant if not exists with unique domain
const deviceUniqueSuffix = Date.now() + '-' + Math.random().toString(36).substr(2, 5);
let tenant = await Tenant.findOne({ where: { slug: 'test-tenant-' + deviceUniqueSuffix } });
if (!tenant) {
tenant = await Tenant.create({
name: 'Test Tenant',
slug: 'test-tenant',
domain: 'test.example.com',
slug: 'test-tenant-' + deviceUniqueSuffix,
domain: 'test-' + deviceUniqueSuffix + '.example.com',
is_active: true
});
}
@@ -220,10 +222,12 @@ async function createTestDetection(detectionData = {}) {
async function createTestTenant(tenantData = {}) {
const { Tenant } = models;
const uniqueSuffix = Date.now() + '-' + Math.random().toString(36).substr(2, 5);
const defaultTenantData = {
name: 'Test Tenant',
slug: 'test-tenant-' + Date.now() + '-' + Math.random().toString(36).substr(2, 5),
domain: 'test.example.com',
slug: 'test-tenant-' + uniqueSuffix,
domain: 'test-' + uniqueSuffix + '.example.com',
is_active: true,
...tenantData
};