feat(torrents): add encryption policy

This commit is contained in:
NimBold
2026-08-02 10:05:39 +03:30
parent b4da68655a
commit 1d27b5b0bf
19 changed files with 378 additions and 18 deletions
+15
View File
@@ -8,6 +8,7 @@ import {
canonicalizeDownloadFileName,
isValidTorrentExcludeTrackerList,
isValidTorrentTrackerList,
normalizeTorrentEncryptionPolicy,
normalizeTorrentPrioritizePiece,
redactDownloadForPersistence,
resolveDownloadConnections
@@ -92,6 +93,20 @@ describe('Torrent piece priority validation', () => {
});
});
describe('Torrent encryption policy validation', () => {
it('accepts only the canonical policy states', () => {
expect(normalizeTorrentEncryptionPolicy('disabled')).toBe('disabled');
expect(normalizeTorrentEncryptionPolicy('require-crypto')).toBe('require-crypto');
expect(normalizeTorrentEncryptionPolicy('force-encryption')).toBe('force-encryption');
});
it('clears unknown or malformed persisted values', () => {
expect(normalizeTorrentEncryptionPolicy(undefined)).toBeUndefined();
expect(normalizeTorrentEncryptionPolicy('arc4')).toBeUndefined();
expect(normalizeTorrentEncryptionPolicy(true)).toBeUndefined();
});
});
describe('download connection resolution', () => {
it('uses a clamped fallback for legacy rows without a saved value', () => {
expect(resolveDownloadConnections(undefined, 8)).toBe(8);