2022-06-15 08:55:55 +00:00
|
|
|
#!/usr/bin/env atf-sh
|
|
|
|
|
|
|
|
. $(atf_get_srcdir)/test_env.sh
|
|
|
|
init_tests \
|
|
|
|
abuild_keygen_help \
|
|
|
|
abuild_keygen_invalid_opts \
|
|
|
|
abuild_keygen_invalid_arg \
|
|
|
|
abuild_keygen_non_interactive \
|
|
|
|
abuild_keygen_append \
|
|
|
|
abuild_keygen_install_without_sudo \
|
|
|
|
abuild_keygen_install_interactive \
|
2022-06-22 14:38:55 +00:00
|
|
|
abuild_keygen_install_non_interactive \
|
|
|
|
abuild_keygen_install_doas
|
2022-06-15 08:55:55 +00:00
|
|
|
|
|
|
|
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
|
|
|
|
export GIT=false
|
|
|
|
|
|
|
|
abuild_keygen_help_body() {
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o not-empty \
|
|
|
|
-e empty \
|
|
|
|
abuild-keygen --help
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_keygen_invalid_opts_body() {
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-o empty \
|
|
|
|
-e not-empty \
|
|
|
|
abuild-keygen -INVALID
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_keygen_invalid_arg_body() {
|
|
|
|
atf_check -s exit:2 \
|
|
|
|
-o empty \
|
|
|
|
-e not-empty \
|
|
|
|
abuild-keygen INVALID
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_keygen_non_interactive_body() {
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o empty \
|
2022-08-05 13:19:21 +00:00
|
|
|
-e match:"(Generating|writing) RSA" \
|
2022-06-15 08:55:55 +00:00
|
|
|
abuild-keygen -n
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_keygen_append_body() {
|
|
|
|
PACKAGER="Test User <user@example.com>" \
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
\
|
|
|
|
-o empty \
|
2022-08-05 13:19:21 +00:00
|
|
|
-e match:"(Generating|writing) RSA" \
|
2022-06-15 08:55:55 +00:00
|
|
|
abuild-keygen --append -n
|
|
|
|
grep '^PACKAGER_PRIVKEY=.*user@example.com' "$HOME"/.abuild/abuild.conf \
|
|
|
|
|| atf_fail 'PACKAGER_PRIVKEY not set in abuild.conf'
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_keygen_install_without_sudo_body() {
|
|
|
|
SUDO=false \
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
\
|
|
|
|
-o empty \
|
2022-08-05 13:19:21 +00:00
|
|
|
-e match:"(Generating|writing) RSA" \
|
2022-06-15 08:55:55 +00:00
|
|
|
abuild-keygen --install -n
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_keygen_install_interactive_body() {
|
|
|
|
echo | abuild_keygen_install_root="$PWD" SUDO= \
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
\
|
|
|
|
-o match:"Enter file" \
|
2022-08-05 13:19:21 +00:00
|
|
|
-e match:"(Generating|writing) RSA" \
|
2022-06-15 08:55:55 +00:00
|
|
|
abuild-keygen --install
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_keygen_install_non_interactive_body() {
|
|
|
|
abuild_keygen_install_root="$PWD" SUDO= \
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
\
|
|
|
|
-o empty \
|
2022-08-05 13:19:21 +00:00
|
|
|
-e match:"(Generating|writing) RSA" \
|
2022-06-15 08:55:55 +00:00
|
|
|
abuild-keygen --install -n
|
|
|
|
}
|
2022-06-22 14:38:55 +00:00
|
|
|
|
|
|
|
abuild_keygen_install_doas_body() {
|
|
|
|
mkdir bin
|
|
|
|
cat >bin/doas<<-EOF
|
|
|
|
#!/bin/sh
|
|
|
|
echo "fake doas"
|
|
|
|
"\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x bin/doas
|
|
|
|
|
|
|
|
PATH="$PWD/bin:$PATH" abuild_keygen_install_root="$PWD" \
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
\
|
|
|
|
-o match:"fake doas" \
|
2022-08-05 13:19:21 +00:00
|
|
|
-e match:"(Generating|writing) RSA" \
|
2022-06-22 14:38:55 +00:00
|
|
|
abuild-keygen --install -n
|
|
|
|
}
|
|
|
|
|