Fix test-electron tests on Windows runner
This commit is contained in:
parent
06f9c4ffe1
commit
1773ad1e11
1 changed files with 26 additions and 29 deletions
|
@ -23,11 +23,8 @@ import { DataWriter } from '../../sql/Client';
|
||||||
import { getRandomBytes } from '../../Crypto';
|
import { getRandomBytes } from '../../Crypto';
|
||||||
import { APPLICATION_OCTET_STREAM, VIDEO_MP4 } from '../../types/MIME';
|
import { APPLICATION_OCTET_STREAM, VIDEO_MP4 } from '../../types/MIME';
|
||||||
import { createName, getRelativePath } from '../../util/attachmentPath';
|
import { createName, getRelativePath } from '../../util/attachmentPath';
|
||||||
import {
|
import { encryptAttachmentV2, generateKeys } from '../../AttachmentCrypto';
|
||||||
encryptAttachmentV2,
|
import { SECOND } from '../../util/durations';
|
||||||
generateKeys,
|
|
||||||
safeUnlinkSync,
|
|
||||||
} from '../../AttachmentCrypto';
|
|
||||||
|
|
||||||
const TRANSIT_CDN = 2;
|
const TRANSIT_CDN = 2;
|
||||||
const TRANSIT_CDN_FOR_NEW_UPLOAD = 42;
|
const TRANSIT_CDN_FOR_NEW_UPLOAD = 42;
|
||||||
|
@ -37,7 +34,8 @@ const RELATIVE_ATTACHMENT_PATH = getRelativePath(createName());
|
||||||
const LOCAL_ENCRYPTION_KEYS = Bytes.toBase64(generateKeys());
|
const LOCAL_ENCRYPTION_KEYS = Bytes.toBase64(generateKeys());
|
||||||
const ATTACHMENT_SIZE = 3577986;
|
const ATTACHMENT_SIZE = 3577986;
|
||||||
|
|
||||||
describe('AttachmentBackupManager/JobManager', () => {
|
describe('AttachmentBackupManager/JobManager', function attachmentBackupManager(this: Mocha.Suite) {
|
||||||
|
this.timeout(10 * SECOND);
|
||||||
let backupManager: AttachmentBackupManager | undefined;
|
let backupManager: AttachmentBackupManager | undefined;
|
||||||
let runJob: sinon.SinonSpy;
|
let runJob: sinon.SinonSpy;
|
||||||
let backupMediaBatch: sinon.SinonStub;
|
let backupMediaBatch: sinon.SinonStub;
|
||||||
|
@ -97,8 +95,24 @@ describe('AttachmentBackupManager/JobManager', () => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
const { getAbsoluteAttachmentPath } = window.Signal.Migrations;
|
||||||
|
const absolutePath = getAbsoluteAttachmentPath(RELATIVE_ATTACHMENT_PATH);
|
||||||
|
await ensureFile(absolutePath);
|
||||||
|
await DataWriter.ensureFilePermissions();
|
||||||
|
await encryptAttachmentV2({
|
||||||
|
plaintext: {
|
||||||
|
absolutePath: join(__dirname, '../../../fixtures/ghost-kitty.mp4'),
|
||||||
|
},
|
||||||
|
keys: Bytes.fromBase64(LOCAL_ENCRYPTION_KEYS),
|
||||||
|
sink: createWriteStream(absolutePath),
|
||||||
|
getAbsoluteAttachmentPath,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await DataWriter.removeAll();
|
await DataWriter.removeAll();
|
||||||
|
|
||||||
await window.storage.put('masterKey', Bytes.toBase64(getRandomBytes(32)));
|
await window.storage.put('masterKey', Bytes.toBase64(getRandomBytes(32)));
|
||||||
|
|
||||||
sandbox = sinon.createSandbox();
|
sandbox = sinon.createSandbox();
|
||||||
|
@ -140,27 +154,11 @@ describe('AttachmentBackupManager/JobManager', () => {
|
||||||
shouldHoldOffOnStartingQueuedJobs: isInCall,
|
shouldHoldOffOnStartingQueuedJobs: isInCall,
|
||||||
runJob,
|
runJob,
|
||||||
});
|
});
|
||||||
|
|
||||||
const absolutePath = getAbsoluteAttachmentPath(RELATIVE_ATTACHMENT_PATH);
|
|
||||||
await ensureFile(absolutePath);
|
|
||||||
await encryptAttachmentV2({
|
|
||||||
plaintext: {
|
|
||||||
absolutePath: join(__dirname, '../../../fixtures/ghost-kitty.mp4'),
|
|
||||||
},
|
|
||||||
keys: Bytes.fromBase64(LOCAL_ENCRYPTION_KEYS),
|
|
||||||
sink: createWriteStream(absolutePath),
|
|
||||||
getAbsoluteAttachmentPath,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
delete window.textsecure.server;
|
|
||||||
safeUnlinkSync(
|
|
||||||
window.Signal.Migrations.getAbsoluteAttachmentPath(
|
|
||||||
RELATIVE_ATTACHMENT_PATH
|
|
||||||
)
|
|
||||||
);
|
|
||||||
await backupManager?.stop();
|
await backupManager?.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -318,12 +316,11 @@ describe('AttachmentBackupManager/JobManager', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('without transitCdnInfo, will permanently remove job if file not found at path', async () => {
|
it('without transitCdnInfo, will permanently remove job if file not found at path', async () => {
|
||||||
const [job] = await addJobs(1, { transitCdnInfo: undefined });
|
const [job] = await addJobs(1, {
|
||||||
safeUnlinkSync(
|
transitCdnInfo: undefined,
|
||||||
window.Signal.Migrations.getAbsoluteAttachmentPath(
|
path: 'nothing/here',
|
||||||
RELATIVE_ATTACHMENT_PATH
|
});
|
||||||
)
|
|
||||||
);
|
|
||||||
await backupManager?.start();
|
await backupManager?.start();
|
||||||
await waitForJobToBeCompleted(job);
|
await waitForJobToBeCompleted(job);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue