Export/import attachments in integration tests

This commit is contained in:
Fedor Indutny 2024-10-11 12:14:28 -07:00 committed by GitHub
parent d42df4b201
commit 9ff6c75eb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 292 additions and 116 deletions

View file

@ -110,17 +110,22 @@ export type HardcodedIVForEncryptionType =
digestToMatch: Uint8Array;
};
type EncryptAttachmentV2PropsType = {
type EncryptAttachmentV2OptionsType = Readonly<{
dangerousIv?: HardcodedIVForEncryptionType;
dangerousTestOnlySkipPadding?: boolean;
getAbsoluteAttachmentPath: (relativePath: string) => string;
keys: Readonly<Uint8Array>;
needIncrementalMac: boolean;
plaintext: PlaintextSourceType;
};
}>;
export type EncryptAttachmentV2ToDiskOptionsType =
EncryptAttachmentV2OptionsType &
Readonly<{
getAbsoluteAttachmentPath: (relativePath: string) => string;
}>;
export async function encryptAttachmentV2ToDisk(
args: EncryptAttachmentV2PropsType
args: EncryptAttachmentV2ToDiskOptionsType
): Promise<EncryptedAttachmentV2 & { path: string }> {
// Create random output file
const relativeTargetPath = getRelativePath(createName());
@ -152,7 +157,7 @@ export async function encryptAttachmentV2({
needIncrementalMac,
plaintext,
sink,
}: EncryptAttachmentV2PropsType & {
}: EncryptAttachmentV2OptionsType & {
sink?: Writable;
}): Promise<EncryptedAttachmentV2> {
const logId = 'encryptAttachmentV2';
@ -580,7 +585,6 @@ export async function decryptAndReencryptLocally(
const [result] = await Promise.all([
decryptAttachmentV2ToSink(options, passthrough),
await encryptAttachmentV2({
getAbsoluteAttachmentPath: options.getAbsoluteAttachmentPath,
keys,
needIncrementalMac: false,
plaintext: {