Compare commits
2 Commits
a92147939d
...
a56594b1df
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a56594b1df | ||
|
|
9305d806b0 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "multi-hoster-uploader",
|
||||
"version": "2.3.4",
|
||||
"version": "2.3.5",
|
||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@ -49,6 +49,18 @@ describe('backup-crypto', () => {
|
||||
assert.deepStrictEqual(result, sampleConfig);
|
||||
});
|
||||
|
||||
it('encrypt rejects empty password', () => {
|
||||
assert.throws(() => encrypt(sampleConfig, ''), /Passwort/);
|
||||
assert.throws(() => encrypt(sampleConfig, null), /Passwort/);
|
||||
assert.throws(() => encrypt(sampleConfig, undefined), /Passwort/);
|
||||
});
|
||||
|
||||
it('decrypt rejects empty password', () => {
|
||||
const buf = encrypt(sampleConfig, 'valid');
|
||||
assert.throws(() => decrypt(buf, ''), /Passwort/);
|
||||
assert.throws(() => decrypt(buf, null), /Passwort/);
|
||||
});
|
||||
|
||||
it('each encryption produces different output (random salt/iv)', () => {
|
||||
const a = encrypt(sampleConfig, 'same');
|
||||
const b = encrypt(sampleConfig, 'same');
|
||||
|
||||
@ -131,4 +131,27 @@ describe('ConfigStore', () => {
|
||||
assert.equal(config.globalSettings.scaleParallelUploads, false);
|
||||
assert.equal(config.globalSettings.logFilePath, '');
|
||||
});
|
||||
|
||||
it('concurrent saves preserve both sections', async () => {
|
||||
const save1 = store.save({ hosters: { 'doodstream.com': [{ id: 'c1', enabled: true, authType: 'api', apiKey: 'concurrent-key' }] } });
|
||||
const save2 = store.save({ globalSettings: { alwaysOnTop: true } });
|
||||
await Promise.all([save1, save2]);
|
||||
const config = store.load();
|
||||
assert.equal(config.hosters['doodstream.com'][0].apiKey, 'concurrent-key');
|
||||
assert.equal(config.globalSettings.alwaysOnTop, true);
|
||||
});
|
||||
|
||||
it('backup recovery when main file is corrupted', () => {
|
||||
// Write valid config first
|
||||
fs.writeFileSync(store.filePath, JSON.stringify({
|
||||
hosters: { 'doodstream.com': [{ id: 'bak-1', authType: 'api', apiKey: 'from-backup' }] },
|
||||
hosterSettings: {}, globalSettings: {}, history: []
|
||||
}), 'utf-8');
|
||||
// Copy to backup
|
||||
fs.copyFileSync(store.filePath, store.filePath + '.bak');
|
||||
// Corrupt main file
|
||||
fs.writeFileSync(store.filePath, 'CORRUPTED!!!', 'utf-8');
|
||||
const config = store.load();
|
||||
assert.equal(config.hosters['doodstream.com'][0].apiKey, 'from-backup');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user