diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2011-03-18 15:33:50 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2011-03-18 15:33:50 +0100 |
commit | e7c95cfdb8698109dce244c748dd292e0dcd5dd3 (patch) | |
tree | 78646728a6e44fe25e4e896bf87e33b6ea80d5aa /tests/in_testenv.sh | |
parent | 2927aaa0b3796443821fff5b9043faafe2ffd542 (diff) |
implement test cases for some of the common PAM actions (test environment required for this)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1398 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'tests/in_testenv.sh')
-rwxr-xr-x | tests/in_testenv.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/in_testenv.sh b/tests/in_testenv.sh new file mode 100755 index 0000000..5137140 --- /dev/null +++ b/tests/in_testenv.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +# in_testenv.sh - script to check whether we are running in test environment +# +# Copyright (C) 2011 Arthur de Jong +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA + +# This script expects to be run in an environment where nss-pam-ldapd +# is deployed with an LDAP server with the proper content (and nslcd running). +# It's probably best to run this in an environment without nscd (this breaks +# the services tests). + +# check if LDAP is configured correctly +cfgfile="/etc/nslcd.conf" +if [ -r "$cfgfile" ] +then + : +else + echo "$0: $cfgfile: not found" + exit 77 +fi + +uri=`sed -n 's/^uri *//p' "$cfgfile" | head -n 1` +base="dc=test,dc=tld" + +# try to fetch the base DN (fail with exit 77 to indicate problem) +ldapsearch -b "$base" -s base -x -H "$uri" > /dev/null 2>&1 || { + echo "$0: LDAP server $uri not available for $base" + exit 77 +} + +# basic check to see if nslcd is running +if [ -S /var/run/nslcd/socket ] && \ + [ -f /var/run/nslcd/nslcd.pid ] && \ + kill -s 0 `cat /var/run/nslcd/nslcd.pid` > /dev/null 2>&1 +then + : +else + echo "$0: nslcd not running" + exit 77 +fi + +# TODO: check if nscd is running + +# TODO: check if /etc/nsswitch.conf is correct + +echo "$0: using LDAP server $uri" |