Skip to content

Commit e7b6ece

Browse files
d-w-mooretrel
authored andcommitted
[#362] create manual script test to be run via 'bats'.
1 parent fd03dd1 commit e7b6ece

2 files changed

Lines changed: 65 additions & 1 deletion

File tree

irods/test/PRC_issue_362.bats

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# The tests in this BATS module must be run as a (passwordless) sudo-enabled user.
2+
# It is also required that the python irodsclient be installed under irods' ~/.local environment.
3+
4+
5+
setup() {
6+
local -A chars=(
7+
[semicolon]=";"
8+
[atsymbol]="@"
9+
[equals]="="
10+
[ampersand]="&"
11+
)
12+
[ $BATS_TEST_NUMBER = 1 ] && echo "---" >/tmp/PRC_test_issue_362
13+
local name=${BATS_TEST_DESCRIPTION##*_}
14+
CHR="${chars[$name]}"
15+
}
16+
17+
TEST_THE_TEST=""
18+
19+
prc_test()
20+
{
21+
local USER="alissa"
22+
local PASSWORD=$(tr "." "$CHR" <<<"my.pass")
23+
echo "$USER:$PASSWORD" | sudo chpasswd
24+
if [ "$TEST_THE_TEST" = 1 ]; then
25+
echo -n `date`: "" >&2
26+
{ su - "$USER" -c "id" <<<"$PASSWORD" 2>/dev/null | grep $USER ; } >&2
27+
else
28+
sudo su - irods -c "env PYTHON_IRODSCLIENT_TEST_PAM_PW_OVERRIDE='$PASSWORD' python -m unittest \
29+
irods.test.login_auth_test.TestLogins.test_escaped_pam_password_chars__362"
30+
fi
31+
} 2>> /tmp/PRC_test_issue_362
32+
33+
@test "test_with_atsymbol" { prc_test; }
34+
@test "test_with_semicolon" { prc_test; }
35+
@test "test_with_equals" { prc_test; }
36+
@test "test_with_ampersand" { prc_test; }

irods/test/login_auth_test.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def _setup_rodsuser_and_optional_pw(self, name, make_irods_pw = False):
243243
finally:
244244
self.admin.users.remove( name )
245245

246-
def tst0(self, ssl_opt, auth_opt, env_opt, name=TEST_RODS_USER, make_irods_pw = False):
246+
def tst0(self, ssl_opt, auth_opt, env_opt, name = TEST_RODS_USER, make_irods_pw = False):
247247

248248
with self._setup_rodsuser_and_optional_pw(name = name, make_irods_pw = make_irods_pw):
249249
self.envdirs = self.create_env_dirs()
@@ -346,6 +346,34 @@ def test_7(self):
346346
def test_8(self):
347347
self.tst0 ( ssl_opt = False, auth_opt = 'pam' , env_opt = True )
348348

349+
@unittest.skipUnless(TEST_PAM_PW_OVERRIDE, "Skipping unless pam password is overridden (e.g. to test special characters)")
350+
def test_escaped_pam_password_chars__362(self):
351+
with self._setup_rodsuser_and_optional_pw(name = TEST_RODS_USER):
352+
context = ssl._create_unverified_context(
353+
purpose=ssl.Purpose.SERVER_AUTH, capath=None, cadata=None, cafile=None,
354+
)
355+
ssl_settings = {
356+
'client_server_negotiation': 'request_server_negotiation',
357+
'client_server_policy': 'CS_NEG_REQUIRE',
358+
'encryption_algorithm': 'AES-256-CBC',
359+
'encryption_key_size': 32,
360+
'encryption_num_hash_rounds': 16,
361+
'encryption_salt_size': 8,
362+
'ssl_ca_certificate_file': '/etc/irods/ssl/irods.crt',
363+
'ssl_context': context
364+
}
365+
irods_session = iRODSSession(
366+
host = self.admin.host,
367+
port = self.admin.port,
368+
zone = self.admin.zone,
369+
user = TEST_RODS_USER,
370+
password = TEST_PAM_PW_OVERRIDE,
371+
authentication_scheme = 'pam',
372+
**ssl_settings
373+
)
374+
home_coll = '/{0.zone}/home/{0.username}'.format(irods_session)
375+
self.assertEqual(irods_session.collections.get(home_coll).path, home_coll)
376+
349377
class TestAnonymousUser(unittest.TestCase):
350378

351379
def setUp(self):

0 commit comments

Comments
 (0)