git-sig/test/test.bats

101 lines
2.1 KiB
Plaintext
Raw Normal View History

2020-11-18 23:23:15 +00:00
load test_helper
@test "Outputs help if run without arguments" {
run sig
2020-11-18 23:23:15 +00:00
[ "$status" -eq 0 ]
2020-11-19 00:52:09 +00:00
echo "${output}" | grep "simple multisig trust toolchain"
}
@test "Outputs help if run with help" {
run sig help
2020-11-19 00:52:09 +00:00
[ "$status" -eq 0 ]
echo "${output}" | grep "simple multisig trust toolchain"
}
@test "Outputs version if run with version" {
run sig version
2020-11-19 00:52:09 +00:00
[ "$status" -eq 0 ]
echo "${output}" | grep "v0.0.1"
2020-11-18 23:23:15 +00:00
}
@test "Outputs advice to install missing openssl" {
2020-11-19 21:40:38 +00:00
sudo rm /usr/bin/openssl
run sig version
echo "${output}" | grep "apt install openssl"
}
@test "Outputs advice to install missing gpg" {
2020-11-19 21:40:38 +00:00
sudo rm /usr/bin/gpg
run sig version
echo "${output}" | grep "apt install gnupg"
}
@test "Outputs advice to install missing getopt" {
2020-11-19 21:40:38 +00:00
sudo rm /usr/bin/getopt
run sig version
echo "${output}" | grep "apt install getopt"
}
2020-11-19 21:40:38 +00:00
@test "Can generate manifest for git repo" {
set_identity "user1"
echo "test string" > somefile
2020-11-19 21:40:38 +00:00
git init
git add .
git commit -m "initial commit"
sig manifest
2020-11-19 21:40:38 +00:00
run grep -q "1" <(wc -l .sig/manifest.txt)
[ "$status" -eq 0 ]
run grep 37d2046a395cbfc .sig/manifest.txt
[ "$status" -eq 0 ]
}
@test "Can generate manifest for folder with git not installed" {
2020-11-19 21:40:38 +00:00
sudo rm /usr/bin/git
echo "test string" > somefile
sig manifest
run grep 37d2046a395cbfc .sig/manifest.txt
[ "$status" -eq 0 ]
}
2020-11-19 21:40:38 +00:00
@test "Can generate manifest for folder with git installed" {
echo "test string" > somefile
sig manifest
run grep 37d2046a395cbfc .sig/manifest.txt
[ "$status" -eq 0 ]
}
@test "Can verify git repo has signed commits by anyone" {
set_identity "user1"
echo "test string" > somefile
git init
git add .
git commit -m "initial commit"
run sig verify --method git
[ "$status" -eq 0 ]
}
@test "Can verify git repo has signed commits by three different identities" {
git init
set_identity "user1"
echo "test string 1" > somefile1
git add .
git commit -m "user1 commit"
set_identity "user2"
echo "test string 2" > somefile2
git add .
git commit -m "user2 commit"
set_identity "user3"
echo "test string 3" > somefile3
git add .
git commit -m "user3 commit"
run sig verify --method git --threshold 3
[ "$status" -eq 0 ]
}