Skip to content

Commit 858374b

Browse files
committed
misc__
add/refine options - workdir etc options include dummy_script called from experiment.sh move to test-script-parameters more utility funcs directory name change
1 parent a360b70 commit 858374b

8 files changed

Lines changed: 70 additions & 10 deletions

File tree

irods/test/dummy_script

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo "hello from script [$0]"

irods/test/harness/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Examples of options in driver script
1919
------------------------------------
2020

2121
1. To start container and run test script:
22-
C=$( ./docker_container_driver.sh -c -L -u testuser ../pam.bats/experiment.sh )
22+
C=$( ./docker_container_driver.sh -c -L -u testuser ../scripts/experiment.sh )
2323

2424
2. To manually examine results afterward:
2525
docker exec -it $C bash

irods/test/harness/docker_container_driver.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ KILL_TEST_CONTAINER=1
44
RUN_AS_USER=""
55
ECHO_CONTAINER=""
66

7+
EXPLICIT_WORKDIR=""
78
while [[ $1 = -* ]]; do
89
if [ "$1" = -c ]; then
910
ECHO_CONTAINER=1
@@ -17,6 +18,10 @@ while [[ $1 = -* ]]; do
1718
RUN_AS_USER="$2"
1819
shift 2
1920
fi
21+
if [ "$1" = -w ]; then
22+
EXPLICIT_WORKDIR="$2"
23+
shift 2
24+
fi
2025
done
2126

2227
if [ "$1" = "" ]; then
@@ -29,15 +34,25 @@ testscript=${1}
2934
testscript_abspath=$(realpath "$testscript")
3035
DIR=$(dirname $0)
3136
cd $DIR
37+
. ./test_script_parameters
38+
39+
image_basename=$(basename $testscript)
40+
image=${images[$image_basename]}
41+
42+
if [ -z "$RUN_AS_USER" ]; then
43+
RUN_AS_USER=${user[$image_basename]}
44+
fi
45+
46+
# Tests are run as testuser by default
47+
: ${RUN_AS_USER:='testuser'}
48+
49+
WORKDIR=""
50+
if [ -n "$EXPLICIT_WORKDIR" ]; then
51+
WORKDIR="$EXPLICIT_WORKDIR"
52+
else
53+
WORKDIR=${workdirs[$RUN_AS_USER]}
54+
fi
3255

33-
declare -A images=(
34-
[test_1.sh]=install-irods
35-
[test_2.sh]=bats-python3
36-
[test_3.bats]=bats-python3
37-
[experiment.sh]=ssl-and-pam
38-
[fail.sh]=ssl-and-pam
39-
)
40-
image=${images[$(basename $testscript)]}
4156
reporoot=$(realpath ./tests/repo)
4257

4358
INNER_MOUNT=/prc
@@ -55,7 +70,10 @@ while :; do
5570
break
5671
done
5772

58-
docker exec ${RUN_AS_USER:+"-u$RUN_AS_USER"} $CONTAINER $INNER_MOUNT/$(realpath --relative-to $reporoot "$testscript_abspath")
73+
docker exec ${RUN_AS_USER:+"-u$RUN_AS_USER"} \
74+
${WORKDIR:+"-w$WORKDIR"} \
75+
$CONTAINER \
76+
$INNER_MOUNT/$(realpath --relative-to $reporoot "$testscript_abspath")
5977
STATUS=$?
6078

6179
if [ $((0+KILL_TEST_CONTAINER)) -ne 0 ]; then
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
declare -A images=(
3+
[test_1.sh]=install-irods
4+
[test_2.sh]=bats-python3
5+
[test_3.bats]=bats-python3
6+
[experiment.sh]=ssl-and-pam
7+
[fail.sh]=ssl-and-pam
8+
)
9+
10+
declare -A user=(
11+
)
12+
13+
declare -A workdirs=(
14+
[testuser]=/home/testuser
15+
[irods]=/var/lib/irods
16+
[root]=/
17+
)
18+
19+
declare -A wrappers=(
20+
[login_auth_test.py]=./login_auth_test.sh
21+
)

irods/test/login_auth_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
. $(dirname $0)/scripts/funcs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ DIR=$(dirname $0)
33
. $DIR/funcs
44
cd "$DIR"
55
set_up_ssl sudo
6+
add_irods_to_system_pam_configuration
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,19 @@ age_out_pam_password() {
128128
local new_time=$((mtime - offset))
129129
sudo su - postgres -c "psql ICAT -c 'update r_user_password set create_ts=$new_time, modify_ts=$new_time where user_id=$id'"
130130
}
131+
132+
add_irods_to_system_pam_configuration() {
133+
local tempfile=/tmp/irods-pam-config.$$
134+
cat <<-EOF >$tempfile
135+
auth required pam_env.so
136+
auth sufficient pam_unix.so
137+
auth requisite pam_succeed_if.so uid >= 500 quiet
138+
auth required pam_deny.so
139+
EOF
140+
sudo chown root.root $tempfile
141+
sudo mv $tempfile /etc/pam.d/irods
142+
}
143+
144+
setup_preconnect_preference() {
145+
sudo su irods -c "sed -i.orig 's/\(^\s*acPreConnect.*CS_NEG\)\([A-Z_]*\)/\1_$1/' /etc/irods/core.re"
146+
}

irods/test/pam.bats/test001_pam_password_expiration.bats renamed to irods/test/scripts/test001_pam_password_expiration.bats

File renamed without changes.

0 commit comments

Comments
 (0)