Skip to content

Commit 05f344f

Browse files
committed
[_519] review corrections
1 parent aea66e4 commit 05f344f

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

irods/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def make_ssl_context(irods_account):
188188
# See https://stackoverflow.com/questions/30461969/disable-default-certificate-verification-in-python-2-7-9/49040695#49040695
189189
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=CAfile, capath=CApath)
190190
# Note: check_hostname must be assigned prior to verify_mode property or Python library complains!
191-
ctx.check_hostname = (verify_server.startswith('host') and verify != ssl.CERT_NONE)
191+
ctx.check_hostname = (verify_server == 'hostname' and verify != ssl.CERT_NONE)
192192
ctx.verify_mode = verify
193193
return ctx
194194

irods/test/login_auth_test.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def create_env_dirs(self):
202202
@classmethod
203203
def setUpClass(cls):
204204
cls.admin = helpers.make_session()
205-
if cls.admin.server_version > (4,3):
205+
if cls.admin.server_version >= (4,3):
206206
cls.PAM_SCHEME_STRING = cls.user_auth_envs['.irods.pam']['AUTH'] = 'pam_password'
207207

208208
@classmethod
@@ -244,7 +244,7 @@ def _setup_rodsuser_and_optional_pw(self, name, make_irods_pw = False):
244244

245245
def tst0(self, ssl_opt, auth_opt, env_opt, name = TEST_RODS_USER, make_irods_pw = False):
246246
_auth_opt = auth_opt
247-
if auth_opt.startswith('pam'):
247+
if auth_opt in ('pam', 'pam_password'):
248248
auth_opt = self.PAM_SCHEME_STRING
249249
with self._setup_rodsuser_and_optional_pw(name = name, make_irods_pw = make_irods_pw):
250250
self.envdirs = self.create_env_dirs()
@@ -328,7 +328,7 @@ def test_4(self):
328328
self.tst0 ( ssl_opt = False, auth_opt = 'native' , env_opt = True, make_irods_pw = True)
329329

330330
# == test explicit scheme 'pam'
331-
331+
332332
def test_5(self):
333333
self.tst0 ( ssl_opt = True, auth_opt = 'pam' , env_opt = False )
334334

@@ -509,20 +509,25 @@ def setUp(self):
509509

510510
def test_ssl_with_server_verify_set_to_none_281(self):
511511
env_file = os.path.expanduser('~/.irods/irods_environment.json')
512-
with helpers.file_backed_up(env_file):
513-
with open(env_file) as env_file_handle:
514-
env = json.load( env_file_handle )
515-
my_ssl_directory = os.path.expanduser("~/some")
516-
# Elect for efficiency in DH param generation, eg. when setting up for testing.
517-
create_ssl_dir(ssl_dir = my_ssl_directory, use_strong_primes_for_dh_generation = False)
518-
keys_to_update = {key:value.replace("/etc/irods/ssl",my_ssl_directory)
519-
for key,value in env.items() if type(value) is str and value.startswith("/etc/irods/ssl")}
520-
keys_to_update["irods_ssl_verify_server"] = "none"
521-
env.update( keys_to_update )
522-
with open(env_file,'w') as f:
523-
json.dump(env,f)
524-
with helpers.make_session() as session:
525-
session.collections.get('/{session.zone}/home/{session.username}'.format(**locals()))
512+
my_ssl_directory = ''
513+
try:
514+
with helpers.file_backed_up(env_file):
515+
with open(env_file) as env_file_handle:
516+
env = json.load( env_file_handle )
517+
my_ssl_directory = tempfile.mkdtemp(dir = os.path.expanduser("~"))
518+
# Elect for efficiency in DH param generation, eg. when setting up for testing.
519+
create_ssl_dir(ssl_dir = my_ssl_directory, use_strong_primes_for_dh_generation = False)
520+
settings_to_update = {key:value.replace("/etc/irods/ssl",my_ssl_directory)
521+
for key,value in env.items() if type(value) is str and value.startswith("/etc/irods/ssl")}
522+
settings_to_update["irods_ssl_verify_server"] = "none"
523+
env.update( settings_to_update )
524+
with open(env_file,'w') as f:
525+
json.dump(env,f)
526+
with helpers.make_session() as session:
527+
session.collections.get('/{session.zone}/home/{session.username}'.format(**locals()))
528+
finally:
529+
if my_ssl_directory:
530+
shutil.rmtree(my_ssl_directory)
526531

527532
if __name__ == '__main__':
528533
# let the tests find the parent irods lib

irods/test/test_ssl_context.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ teardown() {
143143
# THE TESTS THEMSELVES
144144

145145
@test "basic_test" {
146-
json_config -i $IRODS_LOCAL_ENV 'verify_server="host"'
146+
json_config -i $IRODS_LOCAL_ENV 'verify_server="hostname"'
147147
python3 $REPO_SCRIPTS/ssl_test_client.py
148148
}
149149

0 commit comments

Comments
 (0)