summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-05-21 13:16:03 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2022-05-21 13:20:38 +0200
commit6f2bd755a7e639c957a216bf8d1965ecbfb62d0e (patch)
tree0e6aa94c4082d783a8a04f4a98bf7d15ccd5c419
parenta1ccf4af401731ae07ed0e4121b4898c17853193 (diff)
downloadalpine-conf-6f2bd755a7e639c957a216bf8d1965ecbfb62d0e.zip
tests: fix interactive test
apparently atf_check can not run in a subshell so we can not pipe the input. Use a temp file for the answers instead
-rwxr-xr-xtests/setup_sshd_test12
-rwxr-xr-xtests/setup_user_test26
2 files changed, 18 insertions, 20 deletions
diff --git a/tests/setup_sshd_test b/tests/setup_sshd_test
index 23a6f07..19bbda3 100755
--- a/tests/setup_sshd_test
+++ b/tests/setup_sshd_test
@@ -49,13 +49,13 @@ setup_sshd_interactive_body() {
(
echo "openssh"
echo "no"
- ) | atf_check -s exit:0 \
+ ) >answers
+ atf_check -s exit:0 \
-e empty \
- -o match:"Which SSH server" \
- -o match:"^apk add .* openssh" \
- -o match:"^rc-update add sshd" \
- -o match:"^rc-service sshd start" \
- setup-sshd
+ -o match:"Which ssh server" \
+ -o match:"Allow root ssh login" \
+ -o match:"apk add.* openssh" \
+ setup-sshd < answers
grep '^PermitRootLogin no$' etc/ssh/sshd_config || atf_fail "did not set PermitRootLogin"
}
diff --git a/tests/setup_user_test b/tests/setup_user_test
index 2185c0d..f1e0315 100755
--- a/tests/setup_user_test
+++ b/tests/setup_user_test
@@ -35,13 +35,12 @@ setup_user_fullname_body() {
setup_user_interactive_no_body() {
init_env
- (
- echo "no"
- ) | atf_check -s exit:0 \
+ echo "no" >answers
+ atf_check -s exit:0 \
-o match:"Setup a user" \
-o not-match:"adduser.*" \
-e empty \
- setup-user
+ setup-user <answers
}
setup_user_interactive_body() {
@@ -50,39 +49,38 @@ setup_user_interactive_body() {
echo "testuser"
echo "Joe User"
echo "none"
- ) | atf_check -s exit:0 \
+ ) >answers
+ atf_check -s exit:0 \
-o match:"Setup a user" \
-o match:"Full name for user testuser" \
-o not-match:"adduser.* -D .*testuser" \
-o match:"adduser.* -g Joe User .*testuser" \
-e empty \
- setup-user
+ setup-user <answers
}
setup_user_interactive_fullname_body() {
init_env
- (
- echo ""
- ) | atf_check -s exit:0 \
+ echo "" >answers
+ atf_check -s exit:0 \
-o match:"Setup a user.*\[juser\]" \
-o not-match:"Full name for user juser" \
-o not-match:"adduser.* -D .*" \
-o match:"adduser.* -g Joe User .*juser" \
-e empty \
- setup-user -f "Joe User" -k none
+ setup-user -f "Joe User" -k none <answers
}
setup_user_interactive_singlename_body() {
init_env
- (
- echo ""
- ) | atf_check -s exit:0 \
+ echo "" >answers
+ atf_check -s exit:0 \
-o match:"Setup a user.*\[joe\]" \
-o not-match:"Full name for user" \
-o not-match:"adduser.* -D .*" \
-o match:"adduser.* -g Joe .*joe" \
-e empty \
- setup-user -f "Joe" -k none
+ setup-user -f "Joe" -k none <answers
}
setup_user_groups_commas_body() {