|
| 1 | +#!/usr/bin/env bats |
| 2 | +# |
| 3 | +# Test creation of .irodsA for iRODS native authentication using the free function, |
| 4 | +# irods.client_init.write_native_credentials_to_secrets_file |
| 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 | +@test create_irods_secrets_file { |
| 14 | + |
| 15 | + rm -fr ~/.irods |
| 16 | + mkdir ~/.irods |
| 17 | + cat > ~/.irods/irods_environment.json <<-EOF |
| 18 | + { "irods_host":"$(hostname)", |
| 19 | + "irods_port":1247, |
| 20 | + "irods_user_name":"rods", |
| 21 | + "irods_zone_name":"tempZone" |
| 22 | + } |
| 23 | + EOF |
| 24 | + $PYTHON -c "import irods.client_init; irods.client_init.write_native_irodsA_file('rods')" |
| 25 | + |
| 26 | + # Define the core Python to be run, basically a minimal code block ensuring that we can authenticate to iRODS |
| 27 | + # without an exception being raised. |
| 28 | + |
| 29 | + local SCRIPT=" |
| 30 | +import irods.test.helpers as h |
| 31 | +ses = h.make_session() |
| 32 | +ses.collections.get(h.home_collection(ses)) |
| 33 | +print ('env_auth_scheme=%s' % ses.pool.account._original_authentication_scheme) |
| 34 | +" |
| 35 | + OUTPUT=$($PYTHON -c "$SCRIPT") |
| 36 | + # Assert passing value |
| 37 | + [ $OUTPUT = "env_auth_scheme=native" ] |
| 38 | + |
| 39 | + # New starting point with no .irodsA, assert iCommands not working |
| 40 | + rm -fr ~/.irods/.irodsA |
| 41 | + if ! ils 2>/tmp/stderr ; then |
| 42 | + true |
| 43 | + else |
| 44 | + echo 2>/tmp/stderr "ils should fail when no .irodsA is present" |
| 45 | + exit 2 |
| 46 | + fi |
| 47 | + |
| 48 | + # Write another .irodsA |
| 49 | + prc_write_irodsA.py native <<<"rods" |
| 50 | + |
| 51 | + # Verify new .irodsA for both iCommands and PRC use. |
| 52 | + ils >/tmp/stdout |
| 53 | + OUTPUT=$($PYTHON -c "$SCRIPT") |
| 54 | + [ $OUTPUT = "env_auth_scheme=native" ] |
| 55 | + |
| 56 | +} |
0 commit comments