aboutsummaryrefslogtreecommitdiff
path: root/debian/tests/pam-test.py
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/tests/pam-test.py
parentb33771f7a9f1a55ef082470a34a9c93e8b287535 (diff)
downloadpam-f50670072b02d355fdd54efd50e0388d1721b6ad.tar.gz
pam-f50670072b02d355fdd54efd50e0388d1721b6ad.tar.bz2
pam-f50670072b02d355fdd54efd50e0388d1721b6ad.zip
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/tests/pam-test.py')
-rw-r--r--debian/tests/pam-test.py33
1 files changed, 33 insertions, 0 deletions
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()