Files
BetterDesk/web-nodejs/tests/dbAdapter.singleStore.test.js
T
UNITRONIX 1b240543bd feat(auth): implement SQLite auth consolidation and admin password validation
- Added functionality for safely consolidating legacy auth.db into the selected SQLite database, with options for dry runs and rollbacks.
- Introduced command-line flags for SQLite auth consolidation, including backup directory and rollback options.
- Enhanced admin interface security by requiring a password when the admin port is enabled, preventing unauthorized access.
- Updated related tests to ensure proper handling of admin password requirements and relay authorization logic.
2026-08-05 23:49:42 +02:00

40 lines
1.3 KiB
JavaScript

'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const Database = require('better-sqlite3');
describe('dbAdapter SQLite single-store topology', () => {
let tempDir;
beforeEach(() => {
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'betterdesk-single-store-'));
process.env.DATA_DIR = path.join(tempDir, 'panel-data');
process.env.DB_PATH = path.join(tempDir, 'db_v2.sqlite3');
process.env.DB_TYPE = 'sqlite';
jest.resetModules();
});
afterEach(() => {
delete process.env.DATA_DIR;
delete process.env.DB_PATH;
delete process.env.DB_TYPE;
fs.rmSync(tempDir, { recursive: true, force: true });
});
it('uses db_v2.sqlite3 on a fresh install and never creates auth.db', async () => {
const { getAdapter } = require('../services/dbAdapter');
const adapter = getAdapter();
await adapter.init();
const legacyAuthPath = path.join(process.env.DATA_DIR, 'auth.db');
expect(fs.existsSync(legacyAuthPath)).toBe(false);
const main = new Database(process.env.DB_PATH, { readonly: true });
expect(main.prepare(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'users'`).get()).toBeTruthy();
main.close();
await adapter.close();
});
});