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