Fix jwt-token
This commit is contained in:
38
server/tests/utils/testDomains.js
Normal file
38
server/tests/utils/testDomains.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Test Domain Utilities
|
||||
* Standardizes fake domain usage across all tests for multi-tenant scenarios
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate a fake domain for a tenant slug
|
||||
* @param {string} tenantSlug - The tenant slug (e.g., 'test-tenant')
|
||||
* @returns {string} - The fake domain (e.g., 'test-tenant.example.com')
|
||||
*/
|
||||
function getTenantDomain(tenantSlug) {
|
||||
return `${tenantSlug}.example.com`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a supertest request with proper tenant domain
|
||||
* @param {Object} app - Express app instance
|
||||
* @param {string} tenantSlug - The tenant slug
|
||||
* @returns {Object} - Request object with Host header set
|
||||
*/
|
||||
function createTenantRequest(request, app, tenantSlug) {
|
||||
return request(app).set('Host', getTenantDomain(tenantSlug));
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard test tenant configurations
|
||||
*/
|
||||
const TEST_TENANTS = {
|
||||
DEFAULT: 'test-tenant',
|
||||
SECONDARY: 'test-tenant-2',
|
||||
ADMIN: 'admin-tenant'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getTenantDomain,
|
||||
createTenantRequest,
|
||||
TEST_TENANTS
|
||||
};
|
||||
Reference in New Issue
Block a user