Skip to content

Commit bdb0558

Browse files
committed
test .irodsA generation via config setting
1 parent 5aaeb61 commit bdb0558

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

irods/test/scripts/test012.bats

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bats
2+
3+
. "$BATS_TEST_DIRNAME"/funcs
4+
PYTHON=python3
5+
6+
# Setup/prerequisites are same as for login_auth_test.
7+
# Run as ubuntu user with sudo; python_irodsclient must be installed (in either ~/.local or a virtualenv)
8+
#
9+
10+
PASSWD=test123
11+
12+
setup()
13+
{
14+
export SKIP_IINIT_FOR_PASSWORD=1
15+
setup_pam_login_for_alice $PASSWD
16+
SKIP_IINIT_FOR_PASSWORD=""
17+
}
18+
19+
teardown()
20+
{
21+
:
22+
# finalize_pam_login_for_alice
23+
# test_specific_cleanup
24+
}
25+
26+
@test f001 {
27+
28+
AUTH_FILE=~/.irods/.irodsA
29+
30+
# Test assertion: No pre-existing authentication file.
31+
! [ -e $AUTH_FILE ]
32+
33+
local SCRIPT="
34+
import irods.test.helpers as h
35+
ses = h.make_session()
36+
ses.collections.get(h.home_collection(ses))
37+
print ('env_auth_scheme=%s' % ses.pool.account._original_authentication_scheme)
38+
"
39+
40+
# First invocation. PRC will both authenticate with pam_password, and write the generated secrets to the auth file,
41+
OUTPUT=$($PYTHON -c "import irods.client_configuration as cfg
42+
cfg.legacy_auth.pam.password_for_auto_renew = '$PASSWD'
43+
cfg.legacy_auth.pam.time_to_live_in_hours = 1
44+
cfg.legacy_auth.pam.store_password_to_environment = True
45+
$SCRIPT")
46+
47+
SECRETS_0=$(cat $AUTH_FILE)
48+
STAT_0=$(stat -c%y $AUTH_FILE)
49+
50+
sleep 1.1
51+
52+
# Second invocation. PRC will use previously generated secrets from the auth file generated in the first invocation.
53+
OUTPUT=$($PYTHON -c "import irods.client_configuration as cfg
54+
#cfg.legacy_auth.pam.password_for_auto_renew = '$PASSWD'
55+
cfg.legacy_auth.pam.time_to_live_in_hours = 1
56+
cfg.legacy_auth.pam.store_password_to_environment = True
57+
$SCRIPT")
58+
59+
SECRETS_1=$(cat $AUTH_FILE)
60+
STAT_1=$(stat -c%y $AUTH_FILE)
61+
62+
# Test assertion: authentication file is the same, before and after, with identical modification date and contents.
63+
[ "$STAT_1" = "$STAT_0" ]
64+
[ "$SECRETS_0" = "$SECRETS_1" ]
65+
66+
# Test assertion: authentication method is pam_password
67+
[[ $OUTPUT = *=pam_password ]]
68+
}

0 commit comments

Comments
 (0)