Skip to content

Commit

Permalink
Integration tests for 'file cp --mode' and 'file chmod --mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-psmolenski committed Nov 21, 2024
1 parent 49f35fa commit ad24ed1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions testing/integrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ EXPECTED_NEW_IMMUTABLE="i"
CUR=$(printf "%d\n" "${ORIG_MODE}")
NEW=$((CUR + 1))
EXPECTED_NEW_MODE=$(printf "0%o" "${NEW}")
EXPECTED_NEW_MODE_NO_LEAD_ZERO=$(printf "%o" "${NEW}")

run_a_test false 0 file chown --uid=${EXPECTED_NEW_UID} ${LOGS}/test-file
run_a_test false 0 file chgrp --gid=${EXPECTED_NEW_GID} ${LOGS}/test-file
Expand All @@ -634,6 +635,10 @@ run_a_test false 0 file immutable --state=true ${LOGS}/test-file

check_perms_mode ${LOGS}/test-file

# Should treat mode with and without leading zero the same
run_a_test false 0 file chmod --mode="${EXPECTED_NEW_MODE_NO_LEAD_ZERO}" ${LOGS}/test-file
check_perms_mode ${LOGS}/test-file

# Now do it with username/group args
NOBODY_UID=$(id nobody | awk '{print $1}' | sed -e 's:uid=\([0-9][0-9]*\).*:\1:')
NOBODY_GID=$(id nobody | awk '{print $2}' | sed -e 's:gid=\([0-9][0-9]*\).*:\1:')
Expand Down Expand Up @@ -665,6 +670,10 @@ EXPECTED_NEW_GID=$((ORIG_GID + 1))
run_a_test false 0 file cp --overwrite --uid=${EXPECTED_NEW_UID} --gid=${EXPECTED_NEW_GID} --mode="${EXPECTED_NEW_MODE}" ${LOGS}/hosts ${LOGS}/cp-hosts
check_perms_mode ${LOGS}/cp-hosts

# Should treat mode with and without leading zero the same
run_a_test false 0 file cp --overwrite --uid=${EXPECTED_NEW_UID} --gid=${EXPECTED_NEW_GID} --mode="${EXPECTED_NEW_MODE_NO_LEAD_ZERO}" ${LOGS}/hosts ${LOGS}/cp-hosts
check_perms_mode ${LOGS}/cp-hosts

# Now do it with username/group
EXPECTED_NEW_UID=${NOBODY_UID}
EXPECTED_NEW_GID=${NOBODY_GID}
Expand Down

0 comments on commit ad24ed1

Please sign in to comment.