summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorSam Hartman <hartmans@debian.org>2023-01-04 13:39:01 -0700
committerSam Hartman <hartmans@debian.org>2023-01-04 13:39:01 -0700
commitf50670072b02d355fdd54efd50e0388d1721b6ad (patch)
treee744a20ee7e8567e8f0e81d3ddb43273d6b6d78a /debian
parentb33771f7a9f1a55ef082470a34a9c93e8b287535 (diff)
Add autopkgtests
* Add pam-auth-update test to tests --disable and parameter preservation of pam-auth-update * Add pam-test to test password setting and basic pam functionality
Diffstat (limited to 'debian')
-rw-r--r--debian/tests/control7
-rw-r--r--debian/tests/pam-auth-update34
-rw-r--r--debian/tests/pam-test10
-rw-r--r--debian/tests/pam-test.py33
4 files changed, 84 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 00000000..07797e1d
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,7 @@
+Tests: pam-auth-update
+Depends: libpam-modules, libpam-runtime, libpam0g
+Restrictions: needs-root, allow-stderr
+
+Tests: pam-test
+Depends: libpam-modules, libpam-runtime, libpam0g, python3-pam
+Restrictions: needs-root
diff --git a/debian/tests/pam-auth-update b/debian/tests/pam-auth-update
new file mode 100644
index 00000000..e4973bff
--- /dev/null
+++ b/debian/tests/pam-auth-update
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# Copyright 2023, Sam Hartman
+# This code may be redistributed under the same terms as Linux Pam
+# itself, or at your pution, under the GNU General Public License,
+# version 3.
+
+set -x
+
+fail() {
+ echo "$@" 2>&1
+ exit 1
+}
+
+
+# Confirm enabling pam_mkhomedir updates common-session
+grep mkhomedir /etc/pam.d/* && fail pam_mkhomedir already enabled
+pam-auth-update --enable mkhomedir ||fail pam-auth-update enable failed
+grep mkhomedir /etc/pam.d/common-session ||fail pam_mkhomedir was not enabled
+
+# and confirm that it makes a home directory
+useradd -s /bin/bash pam_test
+su -c date pam_test
+test -d ~pam_test || fail pam_test home directory not made
+
+# confirm added options are preserved
+grep -i rounds /etc/pam.d/common-password &&fail rounds parameter already specified
+sed -i -e 's/obscure yescrypt/obscure yescrypt rounds=3/' /etc/pam.d/common-password
+grep rounds /etc/pam.d/common-password ||fail sed did not update common password
+
+# Confirm removing mkhomedir preserves rounds parameter
+pam-auth-update --disable mkhomedir ||fail pam-auth-update disable failed
+grep mkhomedir /etc/pam.d/common-session &&fail pam_mkhomedir not removed
+grep rounds /etc/pam.d/common-password || fail rounds parameter not preserved
diff --git a/debian/tests/pam-test b/debian/tests/pam-test
new file mode 100644
index 00000000..dc97da4b
--- /dev/null
+++ b/debian/tests/pam-test
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright 2023, Sam Hartman
+# This code may be redistributed under the same terms as Linux Pam
+# itself, or at your pution, under the GNU General Public License,
+# version 3.
+
+set -e
+useradd -s /bin/bash pam_test 2>&1 || true
+python3 debian/tests/pam-test.py
+userdel pam_test ||true
diff --git a/debian/tests/pam-test.py b/debian/tests/pam-test.py
new file mode 100644
index 00000000..0024ca5c
--- /dev/null
+++ b/debian/tests/pam-test.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python3
+# Copyright 2023, Sam Hartman
+# This code may be redistributed under the same terms as Linux Pam
+# itself, or at your pution, under the GNU General Public License,
+# version 3.
+
+
+import PAM
+
+def conversation(auth, queries, userdata):
+ results = []
+ for prompt, type in queries:
+ if type == PAM.PAM_PROMPT_ECHO_OFF:
+ results.append(('ThisLongPasswordIsHardCoded', 0))
+ else: results.append(('',0))
+ return results
+# set a password
+
+auth = PAM.pam()
+auth.start('passwd')
+auth.set_item(PAM.PAM_USER, 'pam_test')
+auth.set_item(PAM.PAM_CONV, conversation)
+auth.chauthtok()
+
+# Now authenticate and session
+auth = PAM.pam()
+auth.start('login')
+auth.set_item(PAM.PAM_USER, 'pam_test')
+auth.set_item(PAM.PAM_CONV, conversation)
+auth.authenticate()
+auth.acct_mgmt()
+auth.open_session()
+auth.close_session()