diff options
author | Isis Lovecruft <isis@torproject.org> | 2013-02-19 05:55:39 +0000 |
---|---|---|
committer | Isis Lovecruft <isis@torproject.org> | 2013-02-19 05:55:39 +0000 |
commit | a7b6446dd82ccedad2b16c9a7deae58d701ab2d7 (patch) | |
tree | 3617aa66a615b78232b0247ed0e5ebea6cc72d59 | |
parent | 9788a37e04ade4224a9b947171b5504ffdf266af (diff) |
Add unittest script, test_bootstrap, to verify that bootstrap is able to buildfix/no-suid-for-virtualenv
and execute virtualenv, pip, and python correctly.
-rwxr-xr-x | test_bootstrap | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test_bootstrap b/test_bootstrap new file mode 100755 index 0000000..f072d10 --- /dev/null +++ b/test_bootstrap @@ -0,0 +1,39 @@ +#!/bin/bash +############################################################################## +# +# test_bootstrap +# -------------- +# Test that the bootstrap script works correctly by making a temporary new +# user. +# +# @author Isis Agora Lovecruft, 0x2cdb8b35 +# @date 18 February 2013 +# @version 0.0.1 +############################################################################## + +set -ex - + +HERE=$(pwd) +TEST_USER=bootstraptester + +echo "Creating new user: "'"'"${TEST_USER}"'"'"" +sudo adduser --home /home/${TEST_USER} --shell /bin/bash ${TEST_USER} && \ + echo -e "notsecure\nnotsecure\n" | sudo passwd ${TEST_USER} + +echo 'Copying boostrap script to new user home directory...' +sudo cp ${HERE}/bootstrap /home/${TEST_USER}/bootstrap && \ + sudo chown ${TEST_USER}:${TEST_USER} /home/${TEST_USER}/bootstrap + +echo 'Logging in as new user and executing bootstrap script...' +echo 'Executing test of bootstrap script...' +## -S pulls password from stdin +echo -e "notsecure\n" | sudo -S -H -u ${TEST_USER} -i /home/${TEST_USER}/bootstrap + +if [[ "$?" != 0 ]] ; then + echo 'Error while testing bootstrap...' +else + echo 'Test of bootstrap successful.' +fi + +echo "Deleting user: "'"'"${TEST_USER}"'"'"" +sudo deluser --remove-home ${TEST_USER} |