fix: route IM clients through current origin
Deploy im-webapp production / deploy (push) Successful in 1m35s
Deploy im-webapp production / deploy (push) Successful in 1m35s
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { migrateFixedTenant } from '../src/stores/session-migration.ts';
|
||||
|
||||
test('migrates a persisted default tenant to the current frontend origin', () => {
|
||||
const migrated = migrateFixedTenant(
|
||||
{
|
||||
code: 'default',
|
||||
name: 'Default tenant',
|
||||
host: 'im-api.yuexuan.shop',
|
||||
secure: true,
|
||||
endpoints: {
|
||||
api: 'https://im-api.yuexuan.shop/v1/im',
|
||||
file: 'https://im-api.yuexuan.shop/v0/file',
|
||||
},
|
||||
passwordPolicy: { minLength: 8, maxLength: 64 },
|
||||
},
|
||||
{ origin: 'https://www.yuexuan2.shop', host: 'www.yuexuan2.shop', protocol: 'https:' },
|
||||
);
|
||||
|
||||
assert.deepEqual(migrated, {
|
||||
code: 'default',
|
||||
name: 'Default tenant',
|
||||
host: 'www.yuexuan2.shop',
|
||||
secure: true,
|
||||
endpoints: {
|
||||
api: 'https://www.yuexuan2.shop/v1/im',
|
||||
file: 'https://www.yuexuan2.shop/v0/file',
|
||||
},
|
||||
passwordPolicy: { minLength: 8, maxLength: 64 },
|
||||
});
|
||||
});
|
||||
|
||||
test('does not rewrite a non-default tenant', () => {
|
||||
const tenant = {
|
||||
code: 'enterprise-a',
|
||||
name: 'Enterprise A',
|
||||
host: 'tenant.example.com',
|
||||
secure: true,
|
||||
endpoints: { api: 'https://tenant.example.com/v1/im', file: 'https://tenant.example.com/v0/file' },
|
||||
};
|
||||
|
||||
assert.equal(
|
||||
migrateFixedTenant(tenant, { origin: 'https://www.yuexuan1.shop', host: 'www.yuexuan1.shop', protocol: 'https:' }),
|
||||
tenant,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user