-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_lock.sh
57 lines (48 loc) · 1.46 KB
/
test_lock.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
#!/usr/bin/env bats
setup() {
export PATH="$PWD:$PATH"
rm -rf test
mkdir -p test
}
@test 'keygen' {
ichi-keygen -L -b test/id
[ -f test/id.lock.key ]
[ -f test/id.lock.pub ]
}
@test 'encrypt (pubkey)' {
ichi-keygen -L -b test/x
ichi-keygen -L -b test/a
ichi-keygen -L -b test/b
ichi-keygen -L -b test/c
ichi-lock -E -r test/a.lock.pub \
-r test/b.lock.pub \
-r test/c.lock.pub \
-k test/x.lock.key \
-o test/enc \
README.md
[ -f test/enc ]
# each recepient should be able to decrypt
for key in a b c; do
ichi-lock -D -v test/x.lock.pub \
-k "test/${key}.lock.key" \
-o test/out \
test/enc
[ "$(cat test/out)" = "$(cat README.md)" ]
done
# incorrect sender verification
run ichi-lock -D -v test/a.lock.pub -k test/a.lock.key test/enc
[ "$status" != 0 ]
# epehemeral keypair
ichi-lock -E -r test/x.lock.pub \
-o test/enc \
README.md
ichi-lock -D -k test/x.lock.key -o test/dec test/enc
[ "$(cat test/dec)" = "$(cat README.md)" ]
}
@test 'password encryption' {
ichi-lock -E -p <(echo 123) -o test/enc README.md
ichi-lock -D -p <(echo 123) -o test/dec test/enc
[ "$(cat test/dec)" = "$(cat README.md)" ]
run ichi-lock -D -p <(echo abc) -o test/dec test/enc
[ "$status" != 0 ]
}