1
use asuran::prelude::*;
2
use tempfile::tempdir;
3

4 1
async fn create_multifile_repository(encryption: Encryption, compression: Compression, hmac: HMAC) {
5 1
    let directory = tempdir().expect("Unable to open temporary directory.");
6

7 1
    let repo_dir = directory.path();
8

9 1
    let key = Key::random(encryption.key_length());
10
    let encrypted_key = EncryptedKey::encrypt_defaults(
11 1
        &key,
12 1
        encryption,
13
        "And then there was silence, Just a voice from the other world".as_bytes(),
14
    );
15

16
    let settings = ChunkSettings {
17
        compression,
18
        encryption,
19
        hmac,
20
    };
21

22 1
    let mut mf = MultiFile::open_defaults(repo_dir, Some(settings), &key, 4)
23
        .await
24
        .expect("Unable to create the multifile repository");
25 1
    mf.write_key(&encrypted_key)
26
        .await
27
        .expect("Unable to write encrypted key");
28 1
    mf.close().await;
29
}
30

31
// Attempts to create a multifile repository with no encryption.
32
// Specifically addresses gitlab issue #56
33
#[test]
34
fn create_multifile_noencryption() {
35
    smol::block_on(async {
36
        create_multifile_repository(
37
            Encryption::NoEncryption,
38
            Compression::NoCompression,
39
            HMAC::Blake3,
40
        )
41
        .await
42
    });
43
}
44

45
// Attempts to reproduce gitlab issue #58
46
#[test]
47
fn create_lzma_9() {
48
    smol::block_on(async {
49
        create_multifile_repository(
50
            Encryption::new_aes256ctr(),
51
            Compression::LZMA { level: 9 },
52
            HMAC::Blake3,
53
        )
54
        .await
55
    });
56
}

Read our documentation on viewing source code .

Loading