2021-04-28 08:22:24 +00:00
|
|
|
setup() {
|
|
|
|
export ABUILD_KEYGEN="$PWD/../abuild-keygen"
|
|
|
|
export ABUILD_SHAREDIR="$PWD/.."
|
|
|
|
tmpdir="$BATS_TMPDIR"/abuild-keygen
|
|
|
|
export ABUILD_USERDIR="$tmpdir"/user
|
|
|
|
mkdir -p "$ABUILD_USERDIR"
|
2021-05-06 11:58:23 +00:00
|
|
|
|
|
|
|
# provide a fake git
|
|
|
|
mkdir -p "$tmpdir"/bin
|
|
|
|
cat >"$tmpdir"/bin/git <<-EOF
|
|
|
|
#!/bin/sh
|
|
|
|
exit 1
|
|
|
|
EOF
|
|
|
|
chmod +x "$tmpdir"/bin/git
|
|
|
|
export PATH="$tmpdir/bin:$PATH"
|
2021-04-28 08:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
rm -rf "$tmpdir"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "abuild-keygen: help text" {
|
|
|
|
$ABUILD_KEYGEN --help
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "abuild-keygen: generate key non-interactively" {
|
|
|
|
$ABUILD_KEYGEN -n
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "abuild-keygen: --append option" {
|
2021-05-06 12:00:40 +00:00
|
|
|
PACKAGER="Test User <user@example.com>" $ABUILD_KEYGEN --append -n
|
|
|
|
grep '^PACKAGER_PRIVKEY=.*user@example.com' "$ABUILD_USERDIR"/abuild.conf
|
2021-04-28 08:22:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "abuild-keygen: --install option fails without SUDO" {
|
|
|
|
run SUDO=false $ABUILD_KEYGEN --install
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
}
|
|
|
|
|