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