From e8a347d1e88bd5692ca20523d48bdae68c91f943 Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Tue, 15 Mar 2022 17:33:30 +0100 Subject: [PATCH] test/api.sh: do not use `/tmp`, but `$WORKDIR` Do not create files directly in `/tmp`, but use `$WORKDIR`, which is a temporary directory for transient files, which gets cleaned up when the test case finishes. Without this change, running `api.sh` twice fails the second time. Signed-off-by: Tomas Hozza --- test/cases/api.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/cases/api.sh b/test/cases/api.sh index e757c71a5..ff318c6ec 100755 --- a/test/cases/api.sh +++ b/test/cases/api.sh @@ -503,7 +503,7 @@ else fi # generate a temp key for user tests -ssh-keygen -t rsa-sha2-512 -f /tmp/usertest -C "usertest" -N "" +ssh-keygen -t rsa-sha2-512 -f "${WORKDIR}/usertest" -C "usertest" -N "" function createReqFileAWS() { AWS_SNAPSHOT_NAME=${TEST_ID} @@ -531,11 +531,11 @@ function createReqFileAWS() { { "name": "user1", "groups": ["wheel"], - "key": "$(cat /tmp/usertest.pub)" + "key": "$(cat "${WORKDIR}/usertest.pub")" }, { "name": "user2", - "key": "$(cat /tmp/usertest.pub)" + "key": "$(cat "${WORKDIR}/usertest.pub")" } ] }, @@ -576,11 +576,11 @@ function createReqFileAWSS3() { { "name": "user1", "groups": ["wheel"], - "key": "$(cat /tmp/usertest.pub)" + "key": "$(cat "${WORKDIR}/usertest.pub")" }, { "name": "user2", - "key": "$(cat /tmp/usertest.pub)" + "key": "$(cat "${WORKDIR}/usertest.pub")" } ] }, @@ -977,14 +977,14 @@ function verifyInAWS() { _instanceCheck "$_ssh" # Check access to user1 and user2 - check_groups=$(ssh -oStrictHostKeyChecking=no -i /tmp/usertest "user1@$HOST" -t 'groups') + check_groups=$(ssh -oStrictHostKeyChecking=no -i "${WORKDIR}/usertest" "user1@$HOST" -t 'groups') if [[ $check_groups =~ "wheel" ]]; then echo "✔️ user1 has the group wheel" else echo 'user1 should have the group wheel 😢' exit 1 fi - check_groups=$(ssh -oStrictHostKeyChecking=no -i /tmp/usertest "user2@$HOST" -t 'groups') + check_groups=$(ssh -oStrictHostKeyChecking=no -i "${WORKDIR}/usertest" "user2@$HOST" -t 'groups') if [[ $check_groups =~ "wheel" ]]; then echo 'user2 should not have group wheel 😢' exit 1