mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00

* feat: send the LibreChat user ID as a query param when fetching the list of models * chore: update bun * chore: change bun command for building data-provider * refactor: prefer use of `getCustomConfig` to access custom config, also move to `server/services/Config` * refactor: make endpoints/custom option for the config optional, add userIdQuery, and use modelQueries log store in ModelService * refactor(ModelService): use env variables at runtime, use default models from data-provider, and add tests * docs: add `userIdQuery` * fix(ci): import changed
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
const getCustomConfig = require('~/server/services/Config/getCustomConfig');
|
|
const { isDomainAllowed } = require('./AuthService');
|
|
|
|
jest.mock('~/server/services/Config/getCustomConfig', () => jest.fn());
|
|
|
|
describe('isDomainAllowed', () => {
|
|
it('should allow domain when customConfig is not available', async () => {
|
|
getCustomConfig.mockResolvedValue(null);
|
|
await expect(isDomainAllowed('test@domain1.com')).resolves.toBe(true);
|
|
});
|
|
|
|
it('should allow domain when allowedDomains is not defined in customConfig', async () => {
|
|
getCustomConfig.mockResolvedValue({});
|
|
await expect(isDomainAllowed('test@domain1.com')).resolves.toBe(true);
|
|
});
|
|
|
|
it('should reject an email if it is falsy', async () => {
|
|
getCustomConfig.mockResolvedValue({});
|
|
await expect(isDomainAllowed('')).resolves.toBe(false);
|
|
});
|
|
|
|
it('should allow a domain if it is included in the allowedDomains', async () => {
|
|
getCustomConfig.mockResolvedValue({
|
|
registration: {
|
|
allowedDomains: ['domain1.com', 'domain2.com'],
|
|
},
|
|
});
|
|
await expect(isDomainAllowed('user@domain1.com')).resolves.toBe(true);
|
|
});
|
|
|
|
it('should reject a domain if it is not included in the allowedDomains', async () => {
|
|
getCustomConfig.mockResolvedValue({
|
|
registration: {
|
|
allowedDomains: ['domain1.com', 'domain2.com'],
|
|
},
|
|
});
|
|
await expect(isDomainAllowed('user@domain3.com')).resolves.toBe(false);
|
|
});
|
|
});
|