-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·64 lines (49 loc) · 1.73 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
test () {
# Create the `./test` directory and cd into it
mkdir test
cd test
# Create a random $1 MB file
dd if=/dev/urandom of=$1 bs=1M count=$1 status=progress
# Encrypt the file with `lockdown`
../target/release/lockdown encrypt $1 $1.lockdown
# Check it was altered
diff $1 $1.lockdown > /dev/null && echo "Test failed!" || echo "Test passed!"
# Decrypt the file with `lockdown`
../target/release/lockdown decrypt $1.lockdown $1.decrypted
# Check if the decrypted file is the same as the original file
diff $1 $1.decrypted && echo "Test passed!" || echo "Test failed!"
# # Clean up
rm $1 $1.lockdown $1.decrypted
cd ..
rm -r test
}
test_folder() {
# Create the `./test` directory and cd into it
mkdir test
cd test
mkdir decrypted
cd decrypted
# Create 3 files at once
dd if=/dev/urandom of=1 bs=1M count=1 status=progress
dd if=/dev/urandom of=2 bs=1M count=1 status=progress
dd if=/dev/urandom of=3 bs=1M count=1 status=progress
# Encrypt the files with `lockdown`
cd ..
../target/release/lockdown encrypt decrypted encrypted
# Decrypt the files with `lockdown`
../target/release/lockdown decrypt encrypted recovered
# Check if the decrypted files are the same as the original files
diff decrypted/1 recovered/1 && echo "Test passed!" || echo "Test failed!"
diff decrypted/2 recovered/2 && echo "Test passed!" || echo "Test failed!"
diff decrypted/3 recovered/3 && echo "Test passed!" || echo "Test failed!"
# Clean up
rm -r decrypted encrypted recovered
cd ..
rm -r test
}
# Test with 16MB, 128MB and 1GB files
test 16
test 128
test 1024
# Test with a folder containing 3 files, each 1MB
test_folder