Fix jwt-token
This commit is contained in:
@@ -4,6 +4,7 @@ const sinon = require('sinon');
|
||||
const request = require('supertest');
|
||||
const express = require('express');
|
||||
const { setupTestEnvironment, teardownTestEnvironment, cleanDatabase, createTestUser, createTestTenant, generateTestToken } = require('../setup');
|
||||
const { createTenantRequest, TEST_TENANTS } = require('../utils/testDomains');
|
||||
const authRoutes = require('../../routes/auth');
|
||||
|
||||
describe('Auth Routes', () => {
|
||||
@@ -28,16 +29,18 @@ describe('Auth Routes', () => {
|
||||
|
||||
describe('POST /auth/login', () => {
|
||||
it('should login with valid credentials', async () => {
|
||||
const tenant = await createTestTenant({ slug: 'test-tenant' });
|
||||
const tenant = await createTestTenant({ slug: TEST_TENANTS.DEFAULT });
|
||||
console.log('🔧 TEST: Created tenant:', { id: tenant.id, slug: tenant.slug });
|
||||
|
||||
const user = await createTestUser({
|
||||
username: 'testuser',
|
||||
password: '$2b$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
tenant_id: tenant.id
|
||||
});
|
||||
console.log('🔧 TEST: Created user:', { id: user.id, username: user.username, tenant_id: user.tenant_id });
|
||||
|
||||
const response = await request(app)
|
||||
const response = await createTenantRequest(request, app, TEST_TENANTS.DEFAULT)
|
||||
.post('/auth/login')
|
||||
.set('Host', 'test-tenant.example.com') // Use fake domain for subdomain extraction
|
||||
.send({
|
||||
username: 'testuser',
|
||||
password: 'password'
|
||||
|
||||
Reference in New Issue
Block a user