Skip to content

Commit 2e892a7

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

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

irods/test/user_group_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import tempfile
88
import shutil
99
from subprocess import check_output, CalledProcessError
10+
from irods import client_init
1011
from irods import MAX_PASSWORD_LENGTH
1112
from irods.exception import GroupDoesNotExist, UserDoesNotExist
1213
from irods.meta import iRODSMetaCollection, iRODSMeta
@@ -604,6 +605,19 @@ def test_set_and_query_user_quota(self):
604605
if bob:
605606
ses.users.remove(bob.name)
606607

608+
def test_we_cannot_overwrite_irodsA_without_overwrite_option_true__issue_635(self):
609+
# Assert the auth_file exists and store the contents for later reference.
610+
auth_file = os.path.expanduser('~/.irods/.irodsA')
611+
self.assertTrue(os.path.isfile(auth_file))
612+
with open(auth_file,'rb') as f:
613+
auth_file_contents = f.read()
614+
615+
with self.assertRaises(client_init.irodsA_already_exists):
616+
client_init.write_native_credentials_to_secrets_file('somevalue',overwrite=False)
617+
618+
# Assert the auth file's contents haven't changed.
619+
with open(auth_file,'rb') as f:
620+
self.assertEqual(auth_file_contents, f.read())
607621

608622
if __name__ == '__main__':
609623
# let the tests find the parent irods lib

0 commit comments

Comments
 (0)