@@ -10,28 +10,28 @@ PYTHON=python3
1010# Run as ubuntu user with sudo; python_irodsclient must be installed (in either ~/.local or a virtualenv)
1111#
1212
13- ALICES_PAM_PASSWORD=test123
13+ ALICES_ORIGINAL_PAM_PASSWORD=test123
14+ ALICES_NEW_PASSWORD=test_1234
1415
1516setup ()
1617{
1718 export SKIP_IINIT_FOR_PASSWORD=1
18- setup_pam_login_for_alice " $ALICES_PAM_PASSWORD "
19+ setup_pam_login_for_alice " $ALICES_ORIGINAL_PAM_PASSWORD "
1920 unset SKIP_IINIT_FOR_PASSWORD
2021}
2122
2223teardown ()
2324{
24- :
25- # finalize_pam_login_for_alice
26- # test_specific_cleanup
25+ finalize_pam_login_for_alice
26+ test_specific_cleanup
2727}
2828
2929@test f001 {
3030
31- AUTH_FILE=~ /.irods/.irodsA
31+ local AUTH_FILE=~ /.irods/.irodsA
3232
3333 # Test assertion: No pre-existing authentication file.
34- ! [ -e $AUTH_FILE ]
34+ [ ! -e $AUTH_FILE ]
3535
3636 local SCRIPT="
3737import irods.test.helpers as h
@@ -42,30 +42,54 @@ print ('env_auth_scheme=%s' % ses.pool.account._original_authentication_scheme)
4242
4343 # First invocation. PRC will both authenticate with pam_password, and write the generated secrets to the auth file,
4444 OUTPUT=$( $PYTHON -c " import irods.client_configuration as cfg
45- cfg.legacy_auth.pam.password_for_auto_renew = '$ALICES_PAM_PASSWORD '
45+ cfg.legacy_auth.pam.password_for_auto_renew = '$ALICES_ORIGINAL_PAM_PASSWORD '
4646cfg.legacy_auth.pam.time_to_live_in_hours = 1
4747cfg.legacy_auth.pam.store_password_to_environment = True
4848$SCRIPT " )
4949
50+ # Test assertion: Python script has
51+ [ -e $AUTH_FILE ]
52+ [[ $OUTPUT = " env_auth_scheme=pam" * ]]
53+
5054 SECRETS_0=$( cat $AUTH_FILE )
51- STAT_0=$( stat -c%y $AUTH_FILE )
55+ STAT_0=$( stat -c%Y $AUTH_FILE )
56+
57+ # -----
5258
5359 sleep 1.1
5460
5561 # Second invocation. PRC will use previously generated secrets from the auth file generated in the first invocation.
5662 OUTPUT=$( $PYTHON -c " import irods.client_configuration as cfg
57- #cfg.legacy_auth.pam.password_for_auto_renew = '$ALICES_PAM_PASSWORD '
58- cfg.legacy_auth.pam.time_to_live_in_hours = 1
59- cfg.legacy_auth.pam.store_password_to_environment = True
6063$SCRIPT " )
6164
6265 SECRETS_1=$( cat $AUTH_FILE )
63- STAT_1=$( stat -c%y $AUTH_FILE )
66+ STAT_1=$( stat -c%Y $AUTH_FILE )
6467
6568 # Test assertion: authentication file is the same, before and after, with identical modification date and contents.
6669 [ " $STAT_1 " = " $STAT_0 " ]
6770 [ " $SECRETS_0 " = " $SECRETS_1 " ]
6871
72+ [[ $OUTPUT = " env_auth_scheme=pam" * ]]
73+
74+ # -----
75+
76+ age_out_pam_password " alice"
77+ sudo chpasswd <<< " alice:$ALICES_NEW_PASSWORD"
78+
79+ # Third invocation. PRC will generate new auth file as TTL has run out.
80+ OUTPUT=$( $PYTHON -c " import irods.client_configuration as cfg
81+ cfg.legacy_auth.pam.password_for_auto_renew = '$ALICES_NEW_PASSWORD '
82+ cfg.legacy_auth.pam.time_to_live_in_hours = 1
83+ cfg.legacy_auth.pam.store_password_to_environment = True
84+ $SCRIPT " )
85+
86+ # Assert .irodsA timestamp and contents have changed.
87+ SECRETS_2=$( cat $AUTH_FILE )
88+ STAT_2=$( stat -c%Y $AUTH_FILE )
89+
90+ [ " $STAT_2 " -gt " $STAT_1 " ]
91+ [ " $SECRETS_2 " != " $SECRETS_1 " ]
92+
6993 # Test assertion: authentication method is pam_password
70- [ $OUTPUT = " env_auth_scheme=pam_password " ]
94+ [[ $OUTPUT = " env_auth_scheme=pam " * ] ]
7195}
0 commit comments