summaryrefslogtreecommitdiffstats
path: root/debian/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:02 +0000
commit0a354ad0b2c9eaaa204c31db478da109dc6d2a8b (patch)
tree2467caa8ad20a7fca31bef64224e41a4238db0c9 /debian/tests
parentAdding upstream version 2:4.20.0+dfsg. (diff)
downloadsamba-0a354ad0b2c9eaaa204c31db478da109dc6d2a8b.tar.xz
samba-0a354ad0b2c9eaaa204c31db478da109dc6d2a8b.zip
Adding debian version 2:4.20.0+dfsg-1~exp1.debian/2%4.20.0+dfsg-1_exp1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests')
-rw-r--r--debian/tests/cifs-share-access29
-rw-r--r--debian/tests/cifs-share-access-uring31
-rw-r--r--debian/tests/control30
-rw-r--r--debian/tests/python-smoke2
-rw-r--r--debian/tests/reinstall-samba-common-bin11
-rw-r--r--debian/tests/smbclient-anonymous-share-list6
-rw-r--r--debian/tests/smbclient-authenticated-share-list18
-rw-r--r--debian/tests/smbclient-share-access23
-rw-r--r--debian/tests/smbclient-share-access-uring25
-rw-r--r--debian/tests/util68
10 files changed, 243 insertions, 0 deletions
diff --git a/debian/tests/cifs-share-access b/debian/tests/cifs-share-access
new file mode 100644
index 0000000..47ce01a
--- /dev/null
+++ b/debian/tests/cifs-share-access
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -x
+set -e
+
+. debian/tests/util
+
+username="smbtest$$"
+password="$$"
+add_user "${username}" "${password}"
+
+myshare="myshare$$"
+add_share "${myshare}"
+
+echo "Creating file with random data and computing its md5"
+populate_share "${myshare}" "${username}"
+
+echo "Mounting //localhost/${myshare} via CIFS"
+temp_mount=$(mktemp -d)
+mount -t cifs //localhost/"${myshare}" "$temp_mount" -o user="${username}",username="${username}",password="${password}"
+
+echo "Verifying MD5 via cifs"
+cd "$temp_mount"
+md5sum -c data.md5
+result=$?
+cd -
+umount "$temp_mount"
+rmdir "$temp_mount"
+exit "$result"
diff --git a/debian/tests/cifs-share-access-uring b/debian/tests/cifs-share-access-uring
new file mode 100644
index 0000000..fb4b9c5
--- /dev/null
+++ b/debian/tests/cifs-share-access-uring
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+set -x
+set -e
+
+. debian/tests/util
+
+ensure_uring_available
+
+username="smbtest$$"
+password="$$"
+add_user "${username}" "${password}"
+
+myshare="myshare$$"
+add_share "${myshare}" io_uring
+
+echo "Creating file with random data and computing its md5"
+populate_share "${myshare}" "${username}"
+
+echo "Mounting //localhost/${myshare} via CIFS"
+temp_mount=$(mktemp -d)
+mount -t cifs //localhost/"${myshare}" "$temp_mount" -o user="${username}",username="${username}",password="${password}"
+
+echo "Verifying MD5 via cifs"
+cd "$temp_mount"
+md5sum -c data.md5
+result=$?
+cd -
+umount "$temp_mount"
+rmdir "$temp_mount"
+exit "$result"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..d27e025
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,30 @@
+Tests: cifs-share-access
+Depends: samba, coreutils, systemd, cifs-utils, passwd
+Restrictions: needs-root, allow-stderr, isolation-machine
+
+Tests: cifs-share-access-uring
+Depends: samba, samba-vfs-modules, coreutils, systemd, cifs-utils, passwd
+Restrictions: needs-root, allow-stderr, isolation-machine, skippable
+
+Tests: python-smoke
+Depends: python3-samba
+
+Tests: smbclient-anonymous-share-list
+Depends: samba, smbclient
+Restrictions: allow-stderr, isolation-container
+
+Tests: smbclient-authenticated-share-list
+Depends: samba, smbclient, passwd
+Restrictions: needs-root, allow-stderr, isolation-container
+
+Tests: smbclient-share-access
+Depends: samba, smbclient, coreutils, systemd, passwd
+Restrictions: needs-root, allow-stderr, isolation-container
+
+Tests: smbclient-share-access-uring
+Depends: samba, samba-vfs-modules, smbclient, coreutils, systemd, passwd
+Restrictions: needs-root, allow-stderr, isolation-container, skippable
+
+Tests: reinstall-samba-common-bin
+Depends: samba-common, samba-common-bin
+Restrictions: needs-root, needs-reboot, isolation-machine, allow-stderr
diff --git a/debian/tests/python-smoke b/debian/tests/python-smoke
new file mode 100644
index 0000000..94aff44
--- /dev/null
+++ b/debian/tests/python-smoke
@@ -0,0 +1,2 @@
+#!/bin/sh
+python3 -c 'import samba.samba3'
diff --git a/debian/tests/reinstall-samba-common-bin b/debian/tests/reinstall-samba-common-bin
new file mode 100644
index 0000000..ad3ebed
--- /dev/null
+++ b/debian/tests/reinstall-samba-common-bin
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -xe
+
+# Test regression on systemd-tmpfiles /run/samba presence for postinst script
+if [ -z $AUTOPKGTEST_REBOOT_MARK ]; then
+ apt remove -y samba-common-bin
+ /tmp/autopkgtest-reboot reboot_mark
+else
+ apt install -y samba-common-bin
+fi
diff --git a/debian/tests/smbclient-anonymous-share-list b/debian/tests/smbclient-anonymous-share-list
new file mode 100644
index 0000000..e71ef27
--- /dev/null
+++ b/debian/tests/smbclient-anonymous-share-list
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+set -x
+set -e
+
+smbclient -N -L localhost
diff --git a/debian/tests/smbclient-authenticated-share-list b/debian/tests/smbclient-authenticated-share-list
new file mode 100644
index 0000000..9fcaf43
--- /dev/null
+++ b/debian/tests/smbclient-authenticated-share-list
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -x
+set -e
+
+. debian/tests/util
+
+username="smbtest$$"
+password="$$"
+
+add_user "${username}" "${password}"
+
+echo "Testing with incorrect password: must fail"
+smbclient -L localhost -U "${username}"%wrongpass && exit 1
+
+echo "Testing with correct password: must work"
+smbclient -L localhost -U "${username}"%"${password}"
+
diff --git a/debian/tests/smbclient-share-access b/debian/tests/smbclient-share-access
new file mode 100644
index 0000000..b124c0c
--- /dev/null
+++ b/debian/tests/smbclient-share-access
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -x
+set -e
+
+. debian/tests/util
+
+username="smbtest$$"
+password="$$"
+add_user "${username}" "${password}"
+
+myshare="myshare$$"
+add_share "${myshare}"
+
+echo "Creating file with random data and computing its md5"
+populate_share "${myshare}" "${username}"
+
+rm -f downloaded-data
+echo "Downloading file and comparing its md5"
+smbclient //localhost/"${myshare}" -U "${username}"%"${password}" -c "get data downloaded-data"
+
+mv -f downloaded-data data
+md5sum -c data.md5
diff --git a/debian/tests/smbclient-share-access-uring b/debian/tests/smbclient-share-access-uring
new file mode 100644
index 0000000..4b7a205
--- /dev/null
+++ b/debian/tests/smbclient-share-access-uring
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -x
+set -e
+
+. debian/tests/util
+
+ensure_uring_available
+
+username="smbtest$$"
+password="$$"
+add_user "${username}" "${password}"
+
+myshare="myshare$$"
+add_share "${myshare}" io_uring
+
+echo "Creating file with random data and computing its md5"
+populate_share "${myshare}" "${username}"
+
+rm -f downloaded-data
+echo "Downloading file and comparing its md5"
+smbclient //localhost/"${myshare}" -U "${username}"%"${password}" -c "get data downloaded-data"
+
+mv -f downloaded-data data
+md5sum -c data.md5
diff --git a/debian/tests/util b/debian/tests/util
new file mode 100644
index 0000000..4278ee7
--- /dev/null
+++ b/debian/tests/util
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# $1: share name
+# $2: comma separated list of vfs_objects to use, if any
+add_share() {
+ local share="$1"
+ local vfs="$2"
+ if ! testparm -s 2>&1 | grep -E "^\[${share}\]"; then
+ echo "Adding [${share}] share"
+ cat >> /etc/samba/smb.conf <<EOFEOF
+[${share}]
+ read only = no
+ guest ok = no
+ path = /${share}
+EOFEOF
+ if [ -n "${vfs}" ]; then
+ echo "vfs objects = ${vfs}" >> /etc/samba/smb.conf
+ fi
+ systemctl restart smbd.service
+ else
+ echo "Share [${share}] already exists, continuing"
+ fi
+}
+
+# $1: username
+# $2: password
+add_user() {
+ local username="$1"
+ local password="$2"
+
+ echo "Creating a local and samba user called ${username}"
+ useradd -m "${username}"
+ echo "Setting samba password for the ${username} user"
+ printf '%s\n%s\n' "${password}" "${password}" | smbpasswd -s -a ${username}
+}
+
+# $1: share name
+populate_share() {
+ local sharename="$1"
+ local usergroup="$2"
+ local sharepath="/${sharename}"
+
+ mkdir -p "${sharepath}"
+ dd if=/dev/urandom bs=4096 count=1000 2>/dev/null | base64 > "${sharepath}/data"
+ cd "${sharepath}"
+ md5sum data > data.md5
+ chown -R "${usergroup}:${usergroup}" "${sharepath}"
+}
+
+ensure_uring_available() {
+
+ # uring is supported starting with kernel 5.1.x
+ local kver=$(uname -r)
+ case "$kver" in
+ ( [0-4].* | 5.0.* ) # everything before 5.1
+ echo "uring not available in kernel version ${kver%%-*}, skipping test"
+ exit 77
+ ;;
+ esac
+
+ # ubuntu does not build liburing on i386,
+ # so io_uring vfs object is unavailable too
+ : ${DEB_HOST_MULTIARCH:=$(dpkg-architecture -qDEB_BUILD_MULTIARCH)}
+ if [ ! -f /usr/lib/$DEB_HOST_MULTIARCH/samba/vfs/io_uring.so ]; then
+ echo "io_uring vfs object is not available on this architecture, skipping test"
+ exit 77
+ fi
+}