|
| 1 | +#!/usr/bin/env bats |
| 2 | + |
| 3 | +. "$BATS_TEST_DIRNAME"/test_support_functions |
| 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 | +ALICES_PAM_PASSWORD=test123 |
| 11 | + |
| 12 | +setup() |
| 13 | +{ |
| 14 | + setup_pam_login_for_alice $ALICES_PAM_PASSWORD |
| 15 | +} |
| 16 | + |
| 17 | +teardown() |
| 18 | +{ |
| 19 | + finalize_pam_login_for_alice |
| 20 | + test_specific_cleanup |
| 21 | +} |
| 22 | + |
| 23 | +@test f001 { |
| 24 | + |
| 25 | + # Define the core Python to be run, basically a minimal code block ensuring that we can authenticate to iRODS |
| 26 | + # without an exception being raised. |
| 27 | + |
| 28 | + local SCRIPT=" |
| 29 | +import irods.test.helpers as h |
| 30 | +ses = h.make_session() |
| 31 | +ses.collections.get(h.home_collection(ses)) |
| 32 | +print ('env_auth_scheme=%s' % ses.pool.account._original_authentication_scheme) |
| 33 | +" |
| 34 | + |
| 35 | + # Test that the first run of the code in $SCRIPT is successful, i.e. normal authenticated operations are possible. |
| 36 | + |
| 37 | + local OUTPUT=$($PYTHON -c "$SCRIPT") |
| 38 | + |
| 39 | + [[ $OUTPUT = "env_auth_scheme=pam"* ]] |
| 40 | + |
| 41 | + age_out_pam_password "alice" |
| 42 | + |
| 43 | + HOME_COLLECTION=$(ipwd) |
| 44 | + OUTPUT=$($PYTHON -c "$SCRIPT" 2>&1 >/dev/null || true) |
| 45 | + grep 'CAT_PASSWORD_EXPIRED' <<<"$OUTPUT" |
| 46 | + |
| 47 | + # Test that the $SCRIPT, when run with proper settings, can successfully reset the password. |
| 48 | + |
| 49 | + OUTPUT=$($PYTHON -c "import irods.client_configuration as cfg |
| 50 | +cfg.legacy_auth.pam.password_for_auto_renew = '$ALICES_PAM_PASSWORD' |
| 51 | +cfg.legacy_auth.pam.time_to_live_in_hours = 1 |
| 52 | +cfg.legacy_auth.pam.store_password_to_environment = True |
| 53 | +$SCRIPT") |
| 54 | + |
| 55 | + [[ $OUTPUT = "env_auth_scheme=pam"* ]] |
| 56 | + |
| 57 | + # Test that iCommands can authenticate with the newly written .irodsA file |
| 58 | + |
| 59 | + iquest "%s" "select COLL_NAME where COLL_NAME like '%/home/alice%'"| grep "^$HOME_COLLECTION\$" |
| 60 | +} |
0 commit comments