2020-11-18 23:23:15 +00:00
|
|
|
load test_helper
|
|
|
|
|
|
|
|
@test "Outputs help if run without arguments" {
|
2020-11-19 03:22:08 +00:00
|
|
|
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" {
|
2020-11-19 03:22:08 +00:00
|
|
|
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" {
|
2020-11-19 03:22:08 +00:00
|
|
|
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
|
|
|
}
|
2020-11-19 03:22:08 +00:00
|
|
|
|
|
|
|
@test "Outputs advice to install missing openssl" {
|
2020-11-19 21:40:38 +00:00
|
|
|
sudo rm /usr/bin/openssl
|
2020-11-19 03:22:08 +00:00
|
|
|
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
|
2020-11-19 03:22:08 +00:00
|
|
|
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
|
2020-11-19 03:22:08 +00:00
|
|
|
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"
|
2020-11-19 03:22:08 +00:00
|
|
|
echo "test string" > somefile
|
2020-11-19 21:40:38 +00:00
|
|
|
git init
|
|
|
|
git add .
|
|
|
|
git commit -m "initial commit"
|
2020-11-19 03:22:08 +00:00
|
|
|
sig manifest
|
2020-11-19 21:40:38 +00:00
|
|
|
run grep -q "1" <(wc -l .sig/manifest.txt)
|
|
|
|
[ "$status" -eq 0 ]
|
2020-11-19 03:22:08 +00:00
|
|
|
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
|
2020-11-19 03:22:08 +00:00
|
|
|
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" {
|
2020-11-19 03:22:08 +00:00
|
|
|
echo "test string" > somefile
|
|
|
|
sig manifest
|
|
|
|
run grep 37d2046a395cbfc .sig/manifest.txt
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2020-11-20 10:32:45 +00:00
|
|
|
|
2020-12-08 03:10:52 +00:00
|
|
|
@test "Verify fails if git is in use and tree is dirty" {
|
|
|
|
set_identity "user1"
|
|
|
|
echo "test string" > somefile
|
|
|
|
git init
|
|
|
|
git add .
|
|
|
|
git commit -m "initial commit"
|
|
|
|
echo "dirty" > somefile
|
|
|
|
run sig verify --method="git"
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Exit 1 if git method requested but not a repo" {
|
|
|
|
run sig verify --method="git"
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
2020-11-21 04:50:12 +00:00
|
|
|
@test "Verify succeeds when 1 unique git sig requirement is satisifed" {
|
2020-11-20 10:32:45 +00:00
|
|
|
set_identity "user1"
|
|
|
|
echo "test string" > somefile
|
|
|
|
git init
|
|
|
|
git add .
|
|
|
|
git commit -m "initial commit"
|
|
|
|
run sig verify --method git
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2020-11-21 04:50:12 +00:00
|
|
|
@test "Verify succeeds when 3 unique git sig requirement is satisfied" {
|
2020-11-20 10:32:45 +00:00
|
|
|
git init
|
|
|
|
set_identity "user1"
|
|
|
|
echo "test string 1" > somefile1
|
|
|
|
git add .
|
|
|
|
git commit -m "user1 commit"
|
|
|
|
set_identity "user2"
|
2020-12-04 04:56:38 +00:00
|
|
|
git log
|
|
|
|
sig add
|
2020-11-20 10:32:45 +00:00
|
|
|
set_identity "user3"
|
2020-12-04 04:56:38 +00:00
|
|
|
sig add
|
2020-11-20 10:32:45 +00:00
|
|
|
run sig verify --method git --threshold 3
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2020-11-21 04:50:12 +00:00
|
|
|
@test "Verify fails when 2 unique git sig requirement is not satisfied" {
|
2020-11-20 10:46:33 +00:00
|
|
|
git init
|
|
|
|
set_identity "user1"
|
|
|
|
echo "test string 1" > somefile1
|
|
|
|
git add .
|
|
|
|
git commit -m "user1 commit"
|
2020-12-08 03:10:52 +00:00
|
|
|
sig add
|
2020-11-20 10:46:33 +00:00
|
|
|
run sig verify --method git --threshold 2
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
2020-11-21 04:50:12 +00:00
|
|
|
|
|
|
|
@test "Verify succeeds when 1 group git sig requirement is satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
echo "test string" > somefile
|
|
|
|
git init
|
|
|
|
git add .
|
|
|
|
git commit -m "initial commit"
|
|
|
|
sig fetch --group maintainers AE08157232C35F04309FA478C5EBC4A7CF55A2D0
|
|
|
|
run sig verify --method git --group maintainers
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify succeeds when 3 group git sig requirement is satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
echo "test string" > somefile1
|
|
|
|
git init
|
|
|
|
git add .
|
|
|
|
git commit -m "User 1 Commit"
|
|
|
|
set_identity "user2"
|
2020-12-04 04:56:38 +00:00
|
|
|
sig add
|
2020-11-21 04:50:12 +00:00
|
|
|
set_identity "user3"
|
2020-12-04 04:56:38 +00:00
|
|
|
sig add
|
2020-11-21 04:50:12 +00:00
|
|
|
sig fetch --group maintainers AE08157232C35F04309FA478C5EBC4A7CF55A2D0
|
|
|
|
sig fetch --group maintainers BE4D60F6CFD2237A8AF978583C51CADD33BD0EE8
|
|
|
|
sig fetch --group maintainers 3E45AC9E190B4EE32BAE9F61A331AFB540761D69
|
|
|
|
run sig verify --method git --threshold 3 --group maintainers
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify fails when 2 group git sig requirement is not satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
echo "test string" > somefile
|
|
|
|
git init
|
|
|
|
git add .
|
|
|
|
git commit -m "initial commit"
|
|
|
|
run sig verify --method git --threshold 2 --group maintainers
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify succeeds when 1 unique detached sig requirement is satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
run sig add
|
|
|
|
run sig verify --method detached
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify succeeds when 2 unique detached sig requirement is satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
run sig add
|
|
|
|
set_identity "user2"
|
|
|
|
run sig add
|
|
|
|
run sig verify --threshold 2 --method detached
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify fails when 2 unique detached sig requirement is not satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
run sig add
|
|
|
|
run sig verify --threshold 2 --method detached
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify succeeds when 1 group detached sig requirement is satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
sig add
|
|
|
|
sig fetch --group maintainers AE08157232C35F04309FA478C5EBC4A7CF55A2D0
|
|
|
|
run sig verify --method detached --group maintainers
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify succeeds when 3 group detached sig requirement is satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
sig add
|
|
|
|
set_identity "user2"
|
|
|
|
sig add
|
|
|
|
set_identity "user3"
|
|
|
|
sig add
|
|
|
|
sig fetch --group maintainers AE08157232C35F04309FA478C5EBC4A7CF55A2D0
|
|
|
|
sig fetch --group maintainers BE4D60F6CFD2237A8AF978583C51CADD33BD0EE8
|
|
|
|
sig fetch --group maintainers 3E45AC9E190B4EE32BAE9F61A331AFB540761D69
|
|
|
|
run sig verify --method detached --threshold 3 --group maintainers
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Verify fails when 2 group detached sig requirement is not satisifed" {
|
|
|
|
set_identity "user1"
|
|
|
|
sig add
|
|
|
|
run sig verify --method detached --threshold 2 --group maintainers
|
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
}
|
2020-11-25 02:16:50 +00:00
|
|
|
|
|
|
|
@test "Verify diff shows changes between feature branch and verified master" {
|
|
|
|
git init
|
|
|
|
|
|
|
|
set_identity "user1"
|
|
|
|
echo "test string" > testfile
|
|
|
|
git add .
|
|
|
|
git commit -m "User 1 Commit"
|
|
|
|
|
|
|
|
set_identity "user2"
|
|
|
|
sig add
|
|
|
|
|
|
|
|
set_identity "user1"
|
|
|
|
git checkout -b feature_branch
|
|
|
|
echo "updated test string" > somefile1
|
|
|
|
git add .
|
|
|
|
git commit -m "User 1 Update Commit"
|
|
|
|
|
2020-12-04 04:56:38 +00:00
|
|
|
run sig verify --diff master --threshold 2
|
2020-11-25 02:16:50 +00:00
|
|
|
[ "$status" -eq 1 ]
|
|
|
|
echo "${output}" | grep "updated test string"
|
|
|
|
}
|