diff -Nru autofs-5.1.2/debian/changelog autofs-5.1.2/debian/changelog --- autofs-5.1.2/debian/changelog 2018-02-17 19:24:44.000000000 -0200 +++ autofs-5.1.2/debian/changelog 2018-06-14 12:02:42.000000000 -0300 @@ -1,3 +1,11 @@ +autofs (5.1.2-4) unstable; urgency=medium + + * Add DEP8 tests (Closes: #XXXXXX): + - d/tests/control, d/tests/smb-mount: smb automount DEP8 test + - d/tests/control, d/tests/nfs-mount: nfs automount DEP8 test + + -- Andreas Hasenack Thu, 14 Jun 2018 12:02:42 -0300 + autofs (5.1.2-3) unstable; urgency=medium * QA upload. diff -Nru autofs-5.1.2/debian/tests/control autofs-5.1.2/debian/tests/control --- autofs-5.1.2/debian/tests/control 1969-12-31 21:00:00.000000000 -0300 +++ autofs-5.1.2/debian/tests/control 2018-06-14 12:00:53.000000000 -0300 @@ -0,0 +1,7 @@ +Tests: smb-mount +Depends: @, cifs-utils, samba, smbclient +Restrictions: isolation-machine, needs-root, allow-stderr + +Tests: nfs-mount +Depends: @, nfs-common, nfs-server +Restrictions: isolation-machine, needs-root, allow-stderr diff -Nru autofs-5.1.2/debian/tests/nfs-mount autofs-5.1.2/debian/tests/nfs-mount --- autofs-5.1.2/debian/tests/nfs-mount 1969-12-31 21:00:00.000000000 -0300 +++ autofs-5.1.2/debian/tests/nfs-mount 2018-06-14 12:01:01.000000000 -0300 @@ -0,0 +1,25 @@ +#!/bin/sh + +set -x +set -e + +now=$(date --utc) +result=0 + +echo "creating /nfspub nfs export" +mkdir -p /nfspub +echo "${now} - This is an nfs public export" > /nfspub/nfs-public.txt +echo "/nfspub *(ro,no_subtree_check)" > /etc/exports +exportfs -avr + +echo "Configuring automount for nfs on /net" +mkdir -p /etc/auto.master.d +echo '/net -hosts -intr,soft --timeout=180' > /etc/auto.master.d/net.autofs +systemctl restart autofs + +echo "Accessing the autofs mountpoint" +timeout 30s grep -qE "${now}.*nfs public" /net/localhost/nfspub/nfs-public.txt || result=$? +if [ "$result" -ne "0" ]; then + echo "test failed, couldn't access /net/localhost/nfspub/nfs-public.txt" + exit ${result} +fi diff -Nru autofs-5.1.2/debian/tests/smb-mount autofs-5.1.2/debian/tests/smb-mount --- autofs-5.1.2/debian/tests/smb-mount 1969-12-31 21:00:00.000000000 -0300 +++ autofs-5.1.2/debian/tests/smb-mount 2018-06-14 12:01:01.000000000 -0300 @@ -0,0 +1,135 @@ +#!/bin/sh + +set -x + +add_smb_share() { + local share="$1" + local sharepath="$2" + local public="$3" + + if ! testparm -s 2>&1 | grep -qE "^\[${share}\]"; then + echo "Adding [${share}] share" + cat >> /etc/samba/smb.conf <> /etc/samba/smb.conf <> /etc/samba/smb.conf < /pub/hello-public.txt +add_smb_share pub /pub yes + +echo "Setting up a private samba share in /private" +mkdir -p /private +echo "${now} - This is the private samba share." > /private/hello-private.txt +add_smb_share private /private no + +username="smbtest$$" +password="$$" +echo "Creating a local test user called ${username}" +create_user "${username}" "${password}" + +echo "Setting up autofs credentials for the private share" +mkdir -m 0700 -p /etc/creds +cat > /etc/creds/localhost <> /etc/auto.master + systemctl restart autofs +fi + +# We use a trick here. By storing the credentials in /etc/creds/localhost, +# that means the autofs key is "localhost", and the credentials will be used +# when accessing /cifs/localhost. +# If instead we access /cifs/127.0.0.1, since there is no corresponding entry in +# /etc/creds, that access will be as a guest, i.e., with no credentials +echo "Testing authenticated share automount" +timeout 30s grep -qE "${now}.*private" /cifs/localhost/private/hello-private.txt || result=$? +if [ "$result" -ne "0" ]; then + echo "test failed" + exit ${result} +fi + +echo "Confirming with smbstatus that an authenticated connection was used" +output=$(smbstatus 2>&1) +echo "${output}" | grep -q "${username}" || result=$? +if [ "${result}" -ne "0" ]; then + echo "test failed" + echo "smbstatus output:" + echo "${smbstatus}" + exit "${result}" +fi + +echo "Confirming with mount -t cifs that the filesystem is mounted with authentication" +output=$(mount -t cifs 2>&1) +echo "${output}" | grep -qE "on /cifs/localhost/private.*username=${username}" || result=$? +if [ "${result}" -ne "0" ]; then + echo "test failed" + echo "mount -t cifs output:" + echo "${output}" + exit ${result} +fi + +echo "Testing unauthenticated share automount" +timeout 30s grep -q "${now}.*public" /cifs/127.0.0.1/pub/hello-public.txt || result=$? +if [ "$result" -ne "0" ]; then + echo "test failed" + exit ${result} +fi + +echo "Confirming with smbstatus that a guest connection was used" +output=$(smbstatus 2>&1) +echo "${output}" | grep -q nobody || result=$? +if [ "${result}" -ne "0" ]; then + echo "test failed" + echo "smbstatus output:" + echo "${smbstatus}" + exit ${result} +fi + +echo "Confirming with mount -t cifs that the filesystem is mounted without authentication" +output=$(mount -t cifs 2>&1) +echo "${output}" | grep -qE "on /cifs/127.0.0.1/pub.*sec=none" || result=$? +if [ "${result}" -ne "0" ]; then + echo "test failed" + echo "mount -t cifs output:" + echo "${output}" + exit ${result} +fi