-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_sign.sh
62 lines (49 loc) · 1.49 KB
/
test_sign.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
#!/usr/bin/env bats
setup() {
export PATH="$PWD:$PATH"
rm -rf test
mkdir -p test
}
@test 'keygen' {
ichi-keygen -S -b test/id
[ -f test/id.sign.key ]
[ -f test/id.sign.pub ]
}
@test 'sign + unsign (inline)' {
ichi-keygen -S -b test/a
ichi-keygen -S -b test/b
ichi-sign -k test/a.sign.key -o test/signed README.md
ichi-sign -V -p test/a.sign.pub test/signed
run ichi-sign -V -p test/b.sign.pub test/signed
[ "$status" != 0 ]
}
@test 'trim' {
ichi-keygen -S -b test/a
ichi-sign -k test/a.sign.key -o test/signed README.md
ichi-sign -T test/signed -o test/detached
[ "$(cat test/detached)" = "$(cat README.md)" ]
}
@test 'sign + unsign (detached)' {
ichi-keygen -S -b test/a
ichi-keygen -S -b test/b
ichi-sign -k test/a.sign.key -d -o test/sig README.md
ichi-sign -V -p test/a.sign.pub -s test/sig README.md
run ichi-sign -V -p test/b.pub -s test/sig README.md
[ "$status" != 0 ]
}
@test 'keyring' {
ichi-keygen -S -b test/a
ichi-keygen -S -b test/b
ichi-keygen -S -b test/c
ichi-sign -k test/a.sign.key -d -o test/sig README.md
ichi-sign -k test/a.sign.key -o test/signed README.md
for dirname in test test/; do
ICHI_SIGN_KEYRING="$dirname" ichi-sign -V -s test/sig README.md
ICHI_SIGN_KEYRING="$dirname" ichi-sign -V test/signed
done
# unset = fail
run ichi-sign -V -s test/sig README.md
[ "$status" != 0 ]
run ichi-sign -V test/signed
[ "$status" != 0 ]
}