Skip to content

Commit 13dc9da

Browse files
d-w-moorealanking
authored andcommitted
[#635] test against overwriting irodsA in pam case
That is, test the case of overwrite = False for the free function: irods.client_init.write_pam_credentials_to_secrets_file
1 parent 2e892a7 commit 13dc9da

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

irods/test/scripts/test003_write_pam_credentials_to_secrets_file.bats

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,27 @@ teardown()
2525
}
2626

2727
@test create_secrets_file {
28+
auth_file=~/.irods/.irodsA
2829

29-
# Old .irodsA is already created, so we delete it and alter the pam password.
30+
CONTENTS1=$(cat $auth_file)
31+
32+
# Alter the pam password.
3033
sudo chpasswd <<<"alice:$ALICES_NEW_PAM_PASSWD"
31-
rm -f ~/.irods/.irodsA
34+
OUTPUT=$($PYTHON -c "import irods.client_init;
35+
try:
36+
irods.client_init.write_pam_credentials_to_secrets_file('$ALICES_NEW_PAM_PASSWD', overwrite = False)
37+
except irods.client_init.irodsA_already_exists:
38+
print ('CANNOT OVERWRITE')
39+
")
40+
[ "$OUTPUT" = "CANNOT OVERWRITE" ]
41+
# Assert the previous contents of irodsA have not changed, and aren't zero length.
42+
CONTENTS2=$(cat $auth_file)
43+
[ -n "$CONTENTS1" -a "$CONTENTS1" = "$CONTENTS2" ]
44+
45+
# Now delete the already existing irodsA and repeat without negating overwrite.
3246
$PYTHON -c "import irods.client_init; irods.client_init.write_pam_credentials_to_secrets_file('$ALICES_NEW_PAM_PASSWD')"
47+
CONTENTS3=$(cat $auth_file)
48+
[ "$CONTENTS2" != "$CONTENTS3" ]
3349

3450
# Define the core Python to be run, basically a minimal code block ensuring that we can authenticate to iRODS
3551
# without an exception being raised.

0 commit comments

Comments
 (0)